dom/plugins/test/mochitest/pluginstream.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 SimpleTest.waitForExplicitFinish();
michael@0 2
michael@0 3 function frameLoaded() {
michael@0 4 var testframe = document.getElementById('testframe');
michael@0 5 var embed = document.getElementsByTagName('embed')[0];
michael@0 6 if (undefined === embed)
michael@0 7 embed = document.getElementsByTagName('object')[0];
michael@0 8
michael@0 9 // In the file:// URI case, this ends up being cross-origin.
michael@0 10 // Skip these checks in that case.
michael@0 11 if (testframe.contentDocument) {
michael@0 12 var content = testframe.contentDocument.body.innerHTML;
michael@0 13 if (!content.length)
michael@0 14 return;
michael@0 15
michael@0 16 var filename = embed.getAttribute("src") ||
michael@0 17 embed.getAttribute("geturl") ||
michael@0 18 embed.getAttribute("geturlnotify") ||
michael@0 19 embed.getAttribute("data");
michael@0 20
michael@0 21 var req = new XMLHttpRequest();
michael@0 22 req.open('GET', filename, false);
michael@0 23 req.overrideMimeType('text/plain; charset=x-user-defined');
michael@0 24 req.send(null);
michael@0 25 is(req.status, 200, "bad XMLHttpRequest status");
michael@0 26 is(content, req.responseText.replace(/\r\n/g, "\n"),
michael@0 27 "content doesn't match");
michael@0 28 }
michael@0 29
michael@0 30 is(embed.getError(), "pass", "plugin reported error");
michael@0 31 SimpleTest.finish();
michael@0 32 }

mercurial