Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Document.evaluate for documents without namespaceURI crashes Microsoft Edge

Tested on Microsoft Edge from Windows 10 build 10240. Fixed in build 10586.

Synopsis

Running XMLDocument.prototype.evaluate on a document that has namespaceURI set to null crashes the current tab process in Microsoft Edge, leaves the developer tools for that tab unresponsive, sends debug information to watson.telemetry.microsoft.com, and force-reloads the page.

Repro

To reproduce, open any website in Microsoft Edge, hit F12 to open developer tools, select Console, and run these 3 lines of javascript:

var doc = document.implementation.createDocument(null, null, null);
var node = doc.createElement('A');
doc.evaluate('B', node, doc.createNSResolver(doc), 9, null);
like image 658
a553 Avatar asked Nov 24 '15 07:11

a553


1 Answers

Workaround

Access the baseURI property of the context node before running evaluate.

var doc = document.implementation.createDocument(null, null, null);
var node = doc.createElement('A');

node.baseURI; // Edge workaround http://stackoverflow.com/q/33887400/823663

doc.evaluate('B', node, doc.createNSResolver(doc), 9, null);
like image 85
a553 Avatar answered Nov 13 '22 06:11

a553