Bug 1385223 - Convert tests within dom/plugins/test/mochitest/ to comply with new data: URI inheritance model. r=bsmedberg
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Fri, 28 Jul 2017 11:35:46 +0200
changeset 422839 63182061f15b06933aa6755d47c67ef700671355
parent 422838 270ed5e9ce20133d88d0129df412d112c35a6a04
child 422840 af9a5f0846e62b1e37bbb8a0218cd10e87eef2e5
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs1385223
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1385223 - Convert tests within dom/plugins/test/mochitest/ to comply with new data: URI inheritance model. r=bsmedberg
dom/plugins/test/mochitest/test_pluginstream_err.html
dom/plugins/test/mochitest/test_pluginstream_src_referer.html
dom/plugins/test/mochitest/test_twostreams.html
--- a/dom/plugins/test/mochitest/test_pluginstream_err.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_err.html
@@ -83,21 +83,24 @@ var tests = [
     "streammode": "normal",
     "functiontofail": "npp_destroystream",
     "failurecode": "1",
     "frame": "testframe"
   },
 ];
 
 function iframeonload(evt) {
-  var contentLength = evt.target.contentDocument.body.innerHTML.length;
+  // We have to use SpecialPowers because nptest.cpp prepends
+  // data: whichs makes the frame cross origin with the including page.
+  var wrappedDoc = SpecialPowers.wrap(evt.target).contentDocument;
+  var contentLength = wrappedDoc.body.innerHTML.length;
   var plugin = gTestWindow.document.getElementById("embedtest");
   var functionToFail = plugin.getAttribute("functiontofail");
   if (contentLength > 0) {
-    is(evt.target.contentDocument.body.innerHTML, "pass",
+    is(wrappedDoc.body.innerHTML, "pass",
       "test frame has unexpected content");
     setTimeout(function() {
       // This verifies that the plugin hasn't been unloaded, and that
       // no calls to NPP_ functions have been made unexpectedly.
       is(plugin.getError(), "pass", "plugin reported an error");
       gTestWindow.close();
       setTimeout(runNextTest, 10);
     }, functionToFail == "npp_newstream" ? 500 : 10);
--- a/dom/plugins/test/mochitest/test_pluginstream_src_referer.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_src_referer.html
@@ -10,17 +10,20 @@
   <p id="display"></p>
 
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
   setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   function frameLoaded() {
     var testframe = document.getElementById('pluginframe');
-    var content = testframe.contentDocument.body.innerHTML;
+    // We have to use SpecialPowers because nptest.cpp prepends
+    // data: whichs makes the frame cross origin with the including page.
+    var wrappedDoc = SpecialPowers.wrap(testframe).contentDocument;
+    var content = wrappedDoc.body.innerHTML;
     if (!content.length)
       return;
 
     is(content, "Referer found: " + window.location);
     SimpleTest.finish();
   }
   </script>
 
--- a/dom/plugins/test/mochitest/test_twostreams.html
+++ b/dom/plugins/test/mochitest/test_twostreams.html
@@ -14,23 +14,31 @@
   SimpleTest.expectAssertions(0, 2);
 
   SimpleTest.waitForExplicitFinish();
   setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var framesToLoad = 2;
   function frameLoaded(id) {
     var frame = document.getElementById('testframe' + id);
-    if (!frame.contentDocument.body.innerHTML.length)
+    // We have to use SpecialPowers because nptest.cpp prepends
+    // data: whichs makes the frame cross origin with the including page.
+    var wrappedDoc = SpecialPowers.wrap(frame).contentDocument;
+
+    if (!wrappedDoc.body.innerHTML.length)
       return;
 
     --framesToLoad;
     if (0 == framesToLoad) {
-      is(document.getElementById('testframe1').contentDocument.body.innerHTML,
-         document.getElementById('testframe2').contentDocument.body.innerHTML,
+      var frame1 = document.getElementById('testframe1');
+      var frame2 = document.getElementById('testframe2');
+      var wrappedDocFrame1 = SpecialPowers.wrap(frame1).contentDocument;
+      var wrappedDocFrame2 = SpecialPowers.wrap(frame2).contentDocument;
+
+      is(wrappedDocFrame1.body.innerHTML, wrappedDocFrame2.body.innerHTML,
          "Frame contents should match");
       SimpleTest.finish();
     }
   }
   </script>
 
   <iframe id="testframe1" name="testframe1" onload="frameLoaded(1)"></iframe>
   <iframe id="testframe2" name="testframe2" onload="frameLoaded(2)"></iframe>