Bug 1130560 - Fix intermittent browser_463206.js failures by rewriting the test to make use of ContentTasks instead of CPOWs r=smacleod
authorTim Taubert <ttaubert@mozilla.com>
Wed, 11 Mar 2015 14:11:23 +0100
changeset 233260 d8c4f1ecfe14378732421a2266493be0a7cf4968
parent 233259 fa2cd844dcc912a8f1463704d841a3f655cb713e
child 233261 d31ed2b383324a54fa23776084ec1381fd348716
push id28409
push userryanvm@gmail.com
push dateThu, 12 Mar 2015 21:55:43 +0000
treeherdermozilla-central@849053cb635d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmacleod
bugs1130560
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 1130560 - Fix intermittent browser_463206.js failures by rewriting the test to make use of ContentTasks instead of CPOWs r=smacleod
browser/components/sessionstore/test/browser_463206.js
--- a/browser/components/sessionstore/test/browser_463206.js
+++ b/browser/components/sessionstore/test/browser_463206.js
@@ -1,58 +1,57 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-function test() {
-  /** Test for Bug 463206 **/
+"use strict";
 
-  waitForExplicitFinish();
-
-  let testURL = "http://mochi.test:8888/browser/" +
-    "browser/components/sessionstore/test/browser_463206_sample.html";
+const TEST_URL = "http://mochi.test:8888/browser/" +
+                 "browser/components/sessionstore/test/browser_463206_sample.html";
 
-  var frameCount = 0;
-  let tab = gBrowser.addTab(testURL);
-  tab.linkedBrowser.addEventListener("load", function(aEvent) {
-    // wait for all frames to load completely
-    if (frameCount++ < 5)
-      return;
-    tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
+add_task(function* () {
+  // Add a new tab.
+  let tab = gBrowser.addTab(TEST_URL);
+  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
+  // "Type in" some random values.
+  yield ContentTask.spawn(tab.linkedBrowser, null, function* () {
     function typeText(aTextField, aValue) {
       aTextField.value = aValue;
 
       let event = aTextField.ownerDocument.createEvent("UIEvents");
       event.initUIEvent("input", true, true, aTextField.ownerDocument.defaultView, 0);
       aTextField.dispatchEvent(event);
     }
 
-    let doc = tab.linkedBrowser.contentDocument;
-    typeText(doc.getElementById("out1"), Date.now());
-    typeText(doc.getElementsByName("1|#out2")[0], Math.random());
-    typeText(doc.defaultView.frames[0].frames[1].document.getElementById("in1"), new Date());
+    typeText(content.document.getElementById("out1"), Date.now());
+    typeText(content.document.getElementsByName("1|#out2")[0], Math.random());
+    typeText(content.frames[0].frames[1].document.getElementById("in1"), new Date());
+  });
+
+  // Duplicate the tab.
+  let tab2 = gBrowser.duplicateTab(tab);
+  yield promiseTabRestored(tab2);
 
-    let tab2 = gBrowser.duplicateTab(tab);
-    promiseTabRestored(tab2).then(() => {
-      let doc = tab2.linkedBrowser.contentDocument;
-      let win = tab2.linkedBrowser.contentWindow;
-      isnot(doc.getElementById("out1").value,
-            win.frames[1].document.getElementById("out1").value,
-            "text isn't reused for frames");
-      isnot(doc.getElementsByName("1|#out2")[0].value, "",
-            "text containing | and # is correctly restored");
-      is(win.frames[1].document.getElementById("out2").value, "",
-            "id prefixes can't be faked");
-      // Disabled for now, Bug 588077
-      // isnot(win.frames[0].frames[1].document.getElementById("in1").value, "",
-      //       "id prefixes aren't mixed up");
-      is(win.frames[1].frames[0].document.getElementById("in1").value, "",
-            "id prefixes aren't mixed up");
+  // Query a few values from the top and its child frames.
+  let query = ContentTask.spawn(tab2.linkedBrowser, null, function* () {
+    return [
+      content.document.getElementById("out1").value,
+      content.frames[1].document.getElementById("out1").value,
+      content.document.getElementsByName("1|#out2")[0].value,
+      content.frames[1].document.getElementById("out2").value,
+      content.frames[0].frames[1].document.getElementById("in1").value,
+      content.frames[1].frames[0].document.getElementById("in1").value
+    ];
+  });
 
-      // clean up
-      gBrowser.removeTab(tab2);
-      gBrowser.removeTab(tab);
+  let [v1, v2, v3, v4, v5, v6] = yield query;
+  isnot(v1, v2, "text isn't reused for frames");
+  isnot(v3, "", "text containing | and # is correctly restored");
+  is(v4, "", "id prefixes can't be faked");
+  // Disabled for now, Bug 588077
+  //is(v5, "", "id prefixes aren't mixed up");
+  is(v6, "", "id prefixes aren't mixed up");
 
-      finish();
-    });
-  }, true);
-}
+  // Cleanup.
+  gBrowser.removeTab(tab2);
+  gBrowser.removeTab(tab);
+});