gates - Dave's Blog

Search
My timeline on Mastodon

GoBack/GoForward in Win10 UWP WebView

2018 Oct 23, 9:18

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'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.

If that doesn't make sense for your application and you want to navigate forward or back ignoring iframe navigates, unfortunately there's no perfect workaround.

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.

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.

PermalinkCommentsuri uwp webview

Win10 UWP WebView AddWebAllowedObject details

2017 Sep 4, 3:09

The x-ms-webview HTML element has the void addWebAllowedObject(string name, any value) method and the webview XAML element has the void AddWebAllowedObject(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.

Lifetime

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.

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.

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.

If called both before calling a navigate method and in the NavigationStarting event handler then the result is the aggregate of all those calls.

If called multiple times for the same document with the same name the last call wins and the previous are silently ignored.

If AddWebAllowedObject is called for a navigation and that navigation fails or redirects to a different URI, the AddWebAllowedObject call is silently ignored.

After successfully adding an object to a document, the object will no longer be projected once a navigation to a new document occurs.

WinRT access

If AddWebAllowedObject is called for a document with All WinRT access then projection will succeed and the object will be added.

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.

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.

Object requirements

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.

Property name

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.

Errors

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.

PermalinkComments

Application Content URI Rules wildcard syntax

2017 May 31, 4:48

Application Content URI Rules (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.

Rules

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 CreateUri 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.

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.

Asterisk

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.

Host

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.

Path

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

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/.

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.

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.

PermalinkCommentsapplication-content-uri-rules programming windows windows-store

Unicode Clock

2016 Jan 24, 2:00

I've made a Unicode Clock in JavaScript.

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.

Because the code points are all above 0xFFFF, I make use of some ES6 additions. I use the \u{XXXXXX} style escape sequence since the old style JavaScript escape sequence \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.

"🕛".codePointAt(0)
128347
"🕛".charCodeAt(0)
55357

🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧

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.

PermalinkCommentsjavascript Unicode

Retweet of evacide

2016 Jan 19, 8:00
EFF litigates the US governnent into still more transparency into how it decides to use 0days, by @agcrocker. https://www.eff.org/deeplinks/2016/01/eff-pries-more-transparency-zero-days-governments-grasp …
PermalinkComments

protolol

2011 Jun 10, 8:14Protolol aggregates protocol related tweet jokes: "The problem with TCP jokes is that people keep retelling them slower until you get them." - eigenrickPermalinkCommentshumor technical protocol tcp tcp-ip

zerodaythebook.com

2011 Jan 23, 4:49Sysinternals Mark Russinovich writes a novel (fiction) and gets a Bill Gates blurb for the cover: “Mark came to Microsoft in 2006 to help advance the state of the art of Windows, now in his latest compelling creation he is raising awareness of the all too real threat of cyberterrorism.” —Bill GatesPermalinkCommentsbook security microsoft sysinternals mark-russinovich novel fiction technical

Leaving the IE Team for Windows

2010 Feb 26, 8:40

I'm making a switch from the IE team to the Windows team where I'll be working on the next version of Windows. As a going away surprise Jen and Nick added me to my gallery of Bill Gates (discussed previously). Here's a close up of the photoshopped cover.

Before:
Diveristy in Numbers
After:
Diversity Inc Photoshopped Covers

PermalinkCommentsmicrosoft bill gates photoshop windows

Diversity Inc Photoshopped Covers

2010 Feb 26, 5:00

sequelguy posted a photo:

Diversity Inc Photoshopped Covers

Jen's going away surprise for me was to add to my Diversity Inc cover artwork with my own photoshopped cover.

PermalinkCommentsme photoshop office diversity microsoft billgates

Diversity Inc Photoshopped Cover Closeup

2010 Feb 26, 5:00

sequelguy posted a photo:

Diversity Inc Photoshopped Cover Closeup

Jen's going away surprise for me was to add to my Diversity Inc cover artwork with my own photoshopped cover. Note the attention to detail in the headlines.

PermalinkCommentsme photoshop office diversity microsoft billgates

Bill Gates on energy: Innovating to zero! | Video on TED.com

2010 Feb 18, 4:59"At TED2010, Bill Gates unveils his vision for the world's energy future, describing the need for "miracles" to avoid planetary catastrophe and explaining why he's backing a dramatically different type of nuclear reactor."PermalinkCommentsted bill-gates video environment energy

The Old New Thing : Can I talk to that William fellow? He was so helpful

2009 Nov 23, 11:47'Bill Gates is being taken on a guided tour of the product support department's new office building...Bill puts on a headset, sits down, and answers the phone. "Hello, this is Microsoft Product Support, William speaking. How can I help you?"'PermalinkCommentshumor microsoft bill-gates raymond-chen support history

Language Log » Google Books: A Metadata Train Wreck

2009 Sep 10, 8:22Geoff Nunberg investigates issues in Google Books and in the comments Google Book's team manager responds in the comments. Apparently metadata is bad everywhere and not an issue new to the Web and user generated content or tagging. Like finding Feynman lectures categorized as Death Metal on Napster back in the day.PermalinkCommentslanguage google library metadata catalog

Cambridge Cop Accidentally Arrests Henry Louis Gates Again During White House Meeting | The Onion - America's Finest News Source

2009 Aug 4, 7:19"Witnesses said that Sgt. Crowley, failing to recognize Gates on their flight to Logan Airport, arrested the tenured professor in midair, once again at the baggage claim, and twice during their shared cab ride back to Cambridge"PermalinkCommentshumor onion politics

IE8 Search Providers, Accelerators, and Local Applications Hack

2009 Jul 25, 3:23

There's no easy way to use local applications on a PC as the result of an accelerator or a search provider in IE8 but there is a hack-y/obvious way, that I'll describe here. Both accelerators and search providers in IE8 fill in URL templates and navigate to the resulting URL when an accelerator or search provider is executed by the user. These URLs are limited in scheme to http and https but those pages may do anything any other webpage may do. If your local application has an ActiveX control you could use that, or (as I will provide examples for) if the local application has registered for an application protocol you can redirect to that URL. In any case, unfortunately this means that you must put a webpage on the Internet in order to get an accelerator or search provider to use a local application.

For examples of the app protocol case, I've created a callto accelerator that uses whatever application is registered for the callto scheme on your system, and a Windows Search search provider that opens Explorer's search with your search query. The callto accelerator navigates to my redirection page with 'callto:' followed by the selected text in the fragment and the redirection page redirects to that callto URL. In the Windows Search search provider case the same thing happens except the fragment contains 'search-ms:query=' followed by the selected text, which starts Windows Search on your system with the selected text as the query. I've looked into app protocols previously.

PermalinkCommentstechnical callto hack accelerator search ie8

The Messenger Series - Microsoft Research

2009 Jul 15, 10:48"With a little help from Bill Gates (who secured the rights using personal funds), Microsoft is presenting a series of lectures on physics by Richard Feynman." The videos have subtitles, annotations and links.PermalinkCommentsrichard-feynman video bill-gates microsoft research physics education via:kottke

Chromium Blog: DNS Prefetching (or Pre-Resolving)

2009 Jun 22, 2:55"To speed up browsing, Google Chrome resolves domain names before the user navigates, typically while the user is viewing a web page." In addition to noting what and how they do it, and how web devs can control it, they give a few stats on how much it helps.PermalinkCommentsgoogle dns chrome dns-prefetching browser networking performance technical

Office with a View

2007 Jul 14, 3:12New OfficeI've been at Microsoft three years as of last Thursday. It makes me feel old but on the bright side I've upgraded offices. I now have an office with a window. Its actually a coincidence that I got this office at the time of my Microsoft anniversary but I like to pretend. I've had a single office for only four or five months now so its a nice surprise that I'm moving into a single window office so soon.

Hanging Pen HolderOf course this move means I'll be leaving some things behind. For instance the hanging dry erase pen holder that I created out of office supplies I will leave attached to my old white board. My new office has fancy whiteboards with trays built-in (sooo fancy) so I know the person coming into my old office will make better use of my hanging dry erase pen holder then I would. I explained to him that the rubber bands need to be replaced every eight months or so and not to exceed the maximum weight restrictions.

Diversity in NumbersAdditionally, the office art masterpiece I created I will also leave behind. When Bill Gates was featured on the cover of Diversity Inc. for his amazing philanthropic acts many of us got copies in our mailboxes. I collected mine and some from the recycling bins and put up five of the covers on the wall. Eventually others added to it which was my intent, but I only started this when I eventually checked my mailbox a week or so after the magazine arrived so there weren't as many covers left with which to work. At any rate I ended up with eleven on the wall. I'll leave the interpretation of the artwork up to the viewer.PermalinkCommentsmicrosoft personal office nontechnical

Movie Times

2007 May 1, 3:48The Sunday of the weekend before last I had friends over and we watched Antitrust and Sneakers. Watching Antitrust makes me wonder if Bill Gates has seen it. Tim Robbins plays a character that is essentially based on him but so over the top that its ridiculous.

A few days before that I watched The Prestige with Sarah. I can't tell if I was or wasn't supposed to know what was going on until the end but it was cool anyway. I didn't know until later but David Bowie plays Tesla which is just awesome all the way around.

We also watched The Illusionist sometime before. Both movies are adaptations of novels with stage magicians set in turn of the century England. And I enjoyed both of them. I thought one would be a rushed attempt by one studio to compete with the another on the same ground but that doesn't seem to be the case. I've noticed this before with those asteroid disaster movies and the two movies about Truman Capote. It turns out Wikipedia has a huge list of competing similar movies.PermalinkCommentspersonal movies nontechnical

Bill Gates for President!

2006 Dec 4, 4:13Why Bill Gates should be President. (Humor)PermalinkCommentspolitics microsoft humor bill-gates president
Older Entries Creative Commons License Some rights reserved.