Bug 1086684 - Add a mochitest. r=mconley
☠☠ backed out by 2fd02f191756 ☠ ☠
authorBlake Kaplan <mrbkap@gmail.com>
Fri, 20 Mar 2015 12:04:58 -0700
changeset 252103 992c504934d3cd580a0239983e0926bae8007b99
parent 252102 5832c2042614f3831651193058847ce485e5e5c1
child 252104 6ef7ca8f1db3f984dfa255ff6222edca6dc890d6
push id1174
push usernsm.nikhil@gmail.com
push dateSun, 22 Mar 2015 01:24:25 +0000
reviewersmconley
bugs1086684
milestone39.0a1
Bug 1086684 - Add a mochitest. r=mconley
dom/ipc/tests/file_bug1086684.html
dom/ipc/tests/mochitest.ini
dom/ipc/tests/test_bug1086684.html
new file mode 100644
--- /dev/null
+++ b/dom/ipc/tests/file_bug1086684.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1086684
+-->
+<head>
+  <title>Test for Bug 1086684</title>
+  <meta charset="UTF-8">
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1086684">Mozilla Bug 1086684</a>
+<div id="content">
+    <input type="file" id="f">
+</div>
+</body>
+</html>
--- a/dom/ipc/tests/mochitest.ini
+++ b/dom/ipc/tests/mochitest.ini
@@ -1,14 +1,21 @@
+[DEFAULT]
+support-files =
+  file_bug1086684.html
+
 [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_bug1086684.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]
 skip-if = toolkit != 'gonk'
 [test_child_docshell.html]
 skip-if = toolkit == 'cocoa' # disabled due to hangs, see changeset 6852e7c47edf
new file mode 100644
--- /dev/null
+++ b/dom/ipc/tests/test_bug1086684.html
@@ -0,0 +1,106 @@
+<!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 =
+      "http://mochi.test:8888/tests/dom/ipc/tests/file_bug1086684.html";
+
+    function childFrameScript() {
+      "use strict";
+
+      let { MockFilePicker } =
+        Components.utils.import("resource://specialpowers/MockFilePicker.jsm", {});
+
+      function parentReady(message) {
+        MockFilePicker.init(content);
+        MockFilePicker.returnFiles = [message.data.file];
+        MockFilePicker.returnValue = MockFilePicker.returnOK;
+
+        let input = content.document.getElementById("f");
+        input.addEventListener("change", () => {
+          MockFilePicker.cleanup();
+          message.target.sendAsyncMessage("testBug1086684:childDone", { },
+                                          { elt: input });
+        });
+
+        input.focus();
+        input.click();
+      }
+
+      addMessageListener("testBug1086684:parentReady", function(message) {
+        parentReady(message);
+      });
+    }
+
+    let test;
+    function* testStructure(mm) {
+      let lastResult;
+
+      function testDone(msg) {
+        test.next(msg.objects);
+      }
+
+      mm.addMessageListener("testBug1086684:childDone", testDone);
+
+      let blob = new Blob([]);
+      let file = new File([blob], "helloworld.txt", { type: "text/plain" });
+
+      mm.sendAsyncMessage("testBug1086684:parentReady", { file });
+      lastResult = yield;
+
+      // Note that the "helloworld.txt" passed in above doesn't affect the
+      // 'value' getter. Because we're mocking a file using a blob, we ask the
+      // blob for its path, which is the empty string.
+      is(SpecialPowers.wrap(lastResult.elt).value, "", "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>