Bug 1087646 - Add a test. r=smaug
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 24 Feb 2015 12:54:40 -0800
changeset 230522 bc2be5c8ab2abc19df3617ac4e3d2395997aebeb
parent 230521 9f4da60dbfff7e506b2649011a755cff0a5ca7a0
child 230523 24c4bac4ad0509b8f6e43824a794bc2e34c4d01a
push id56028
push usermrbkap@mozilla.com
push dateTue, 24 Feb 2015 20:54:56 +0000
treeherdermozilla-inbound@bc2be5c8ab2a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1087646
milestone39.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 1087646 - Add a test. r=smaug
dom/ipc/tests/mochitest.ini
dom/ipc/tests/test_cpow_cookies.html
--- a/dom/ipc/tests/mochitest.ini
+++ b/dom/ipc/tests/mochitest.ini
@@ -1,14 +1,16 @@
 [test_blob_sliced_from_child_process.html]
 # This test is only supposed to run in the main process.
 skip-if = buildapp == 'b2g' || buildapp == 'mulet' || e10s
 [test_blob_sliced_from_parent_process.html]
 # This test is only supposed to run in the main process.
 skip-if = buildapp == 'b2g' || buildapp == 'mulet' || e10s
+[test_cpow_cookies.html]
+skip-if = buildapp == 'b2g' || buildapp == 'mulet'
 [test_NuwaProcessCreation.html]
 skip-if = toolkit != 'gonk'
 [test_NuwaProcessDeadlock.html]
 run-if = toolkit == 'gonk'
 [test_child_docshell.html]
 run-if = toolkit != 'cocoa' # disabled due to hangs, see changeset 6852e7c47edf
 [test_CrashService_crash.html]
 run-if = crashreporter && !e10s && (toolkit == 'gtk2' || toolkit == 'gtk3' || toolkit == 'cocoa' || toolkit == 'windows') && (buildapp != 'b2g' || toolkit == 'gonk')
new file mode 100644
--- /dev/null
+++ b/dom/ipc/tests/test_cpow_cookies.html
@@ -0,0 +1,89 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for recursive CPOW-getting-cookie bug</title>
+  <script type="application/javascript"
+          src="/tests/SimpleTest/SimpleTest.js">
+  </script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+
+  <script type="application/javascript;version=1.8">
+    "use strict";
+
+    SimpleTest.waitForExplicitFinish();
+
+    const childFrameURL =
+      "data:text/html,<!DOCTYPE HTML><html><body></body></html>";
+
+    function childFrameScript() {
+      "use strict";
+
+      const Ci = Components.interfaces;
+
+      function test1(message) {
+        // NB: This is a no-op because we're a data: document with a null
+        // principal.
+        content.document.cookie = "a=b";
+        message.target.sendAsyncMessage("testCPOWCookies:test1Finished", { pass: true });
+      }
+
+      addMessageListener("testCPOWCookies:test1", function(message) {
+        test1(message);
+      });
+    }
+
+    let test;
+    function* testStructure(mm) {
+      let lastResult;
+
+      function testDone(msg) {
+        test.next(msg.data);
+      }
+
+      mm.addMessageListener("testCPOWCookies:test1Finished", testDone);
+
+      mm.sendAsyncMessage("testCPOWCookies:test1", {});
+      lastResult = yield;
+      ok(lastResult.pass, "got the right answer and didn't crash");
+
+      SimpleTest.finish();
+    }
+
+    function runTests() {
+      info("Browser prefs set.");
+
+      let iframe = document.createElement("iframe");
+      SpecialPowers.wrap(iframe).mozbrowser = true;
+      iframe.id = "iframe";
+      iframe.src = childFrameURL;
+
+      iframe.addEventListener("mozbrowserloadend", function() {
+        info("Got iframe load event.");
+        let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
+        mm.loadFrameScript("data:,(" + encodeURI(childFrameScript.toString()) + ")();",
+                           false);
+
+        test = testStructure(mm);
+        test.next();
+      });
+
+      document.body.appendChild(iframe);
+    }
+
+    addEventListener("load", function() {
+      info("Got load event.");
+
+      SpecialPowers.addPermission("browser", true, document);
+      SpecialPowers.pushPrefEnv({
+        "set": [
+          ["dom.ipc.browser_frames.oop_by_default", true],
+          ["dom.mozBrowserFramesEnabled", true],
+          ["browser.pagethumbnails.capturing_disabled", true]
+        ]
+      }, runTests);
+    });
+  </script>
+</body>
+</html>