Bug 1346286 - Remove CPOWs from browser_687710_2.js. r=Felipe draft
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 07 Mar 2017 18:09:42 -0800
changeset 499542 fe384727361de26a1d5a3c86132abb5bc319f68a
parent 499541 7becbc10bf920ed8e311d57d969e1a5a9a162fb3
child 499543 64eb63058b80c6aa01723cc54773263feb0e35d7
push id49450
push userbmo:mrbkap@mozilla.com
push dateWed, 15 Mar 2017 23:51:54 +0000
reviewersFelipe
bugs1346286
milestone55.0a1
Bug 1346286 - Remove CPOWs from browser_687710_2.js. r=Felipe MozReview-Commit-ID: Au09j3DGveY
browser/components/sessionstore/test/browser_687710_2.js
--- a/browser/components/sessionstore/test/browser_687710_2.js
+++ b/browser/components/sessionstore/test/browser_687710_2.js
@@ -1,8 +1,9 @@
+/* eslint-env mozilla/frame-script */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that the fix for bug 687710 isn't too aggressive -- shentries which are
 // cousins should be able to share bfcache entries.
 
 var stateBackup = ss.getBrowserState();
 
@@ -20,52 +21,48 @@ var state = {entries:[
     url: "http://example.com?1#a",
     triggeringPrincipal_base64,
     children: [{ docIdentifier: 10,
                  url: "http://example.com?10#aa",
                  triggeringPrincipal_base64 }]
   }
 ]};
 
-function test() {
-  waitForExplicitFinish();
+add_task(function* test() {
+  let tab = gBrowser.addTab("about:blank");
+  yield promiseTabState(tab, state);
+  yield ContentTask.spawn(tab.linkedBrowser, null, function() {
+    function compareEntries(i, j, history) {
+      let e1 = history.getEntryAtIndex(i, false)
+                      .QueryInterface(Ci.nsISHEntry)
+                      .QueryInterface(Ci.nsISHContainer);
+
+      let e2 = history.getEntryAtIndex(j, false)
+                      .QueryInterface(Ci.nsISHEntry)
+                      .QueryInterface(Ci.nsISHContainer);
 
-  registerCleanupFunction(function() {
-    ss.setBrowserState(stateBackup);
-  });
+      ok(e1.sharesDocumentWith(e2),
+         `${i} should share doc with ${j}`);
+      is(e1.childCount, e2.childCount,
+         `Child count mismatch (${i}, ${j})`);
 
-  let tab = gBrowser.addTab("about:blank");
-  promiseTabState(tab, state).then(() => {
-    let history = tab.linkedBrowser.webNavigation.sessionHistory;
+      for (let c = 0; c < e1.childCount; c++) {
+        let c1 = e1.GetChildAt(c);
+        let c2 = e2.GetChildAt(c);
+
+        ok(c1.sharesDocumentWith(c2),
+           `Cousins should share documents. (${i}, ${j}, ${c})`);
+      }
+    }
+
+    let history = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+                          .getInterface(Ci.nsISHistory);
 
     is(history.count, 2, "history.count");
     for (let i = 0; i < history.count; i++) {
       for (let j = 0; j < history.count; j++) {
         compareEntries(i, j, history);
       }
     }
-
-    finish();
   });
-}
-
-function compareEntries(i, j, history) {
-  let e1 = history.getEntryAtIndex(i, false)
-                  .QueryInterface(Ci.nsISHEntry)
-                  .QueryInterface(Ci.nsISHContainer);
-
-  let e2 = history.getEntryAtIndex(j, false)
-                  .QueryInterface(Ci.nsISHEntry)
-                  .QueryInterface(Ci.nsISHContainer);
 
-  ok(e1.sharesDocumentWith(e2),
-     i + " should share doc with " + j);
-  is(e1.childCount, e2.childCount,
-     "Child count mismatch (" + i + ", " + j + ")");
-
-  for (let c = 0; c < e1.childCount; c++) {
-    let c1 = e1.GetChildAt(c);
-    let c2 = e2.GetChildAt(c);
-
-    ok(c1.sharesDocumentWith(c2),
-       "Cousins should share documents. (" + i + ", " + j + ", " + c + ")");
-  }
-}
+  ss.setBrowserState(stateBackup);
+});