Bug 1346286 - Remove CPOWs from browser_history_persist.js draft
authorBlake Kaplan <mrbkap@gmail.com>
Thu, 09 Mar 2017 14:30:30 -0800
changeset 499551 705fbd00ac358ed170d4bd00f695adc05a340765
parent 499550 8b70f9886950e0caaefee35e2e3927315887e85f
child 499552 a65b68cce684c96065a72dbf7563914666c93679
push id49450
push userbmo:mrbkap@mozilla.com
push dateWed, 15 Mar 2017 23:51:54 +0000
bugs1346286
milestone55.0a1
Bug 1346286 - Remove CPOWs from browser_history_persist.js MozReview-Commit-ID: 22fQbSgMzQM
browser/components/sessionstore/test/browser_history_persist.js
--- a/browser/components/sessionstore/test/browser_history_persist.js
+++ b/browser/components/sessionstore/test/browser_history_persist.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/ */
 
 "use strict";
 
 /**
  * Ensure that history entries that should not be persisted are restored in the
  * same state.
@@ -12,68 +13,81 @@ add_task(function* check_history_not_per
   let tab = gBrowser.addTab("about:blank");
   let browser = tab.linkedBrowser;
   yield promiseBrowserLoaded(browser);
 
   // Retrieve the tab state.
   yield TabStateFlusher.flush(browser);
   let state = JSON.parse(ss.getTabState(tab));
   ok(!state.entries[0].persist, "Should have collected the persistence state");
-  gBrowser.removeTab(tab);
+  yield promiseRemoveTab(tab);
   browser = null;
 
   // Open a new tab to restore into.
   tab = gBrowser.addTab("about:blank");
   browser = tab.linkedBrowser;
   yield promiseTabState(tab, state);
-  let sessionHistory = browser.sessionHistory;
 
-  is(sessionHistory.count, 1, "Should be a single history entry");
-  is(sessionHistory.getEntryAtIndex(0, false).URI.spec, "about:blank", "Should be the right URL");
+  yield ContentTask.spawn(browser, null, function() {
+    let sessionHistory = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+                                 .getInterface(Ci.nsISHistory);
+
+    is(sessionHistory.count, 1, "Should be a single history entry");
+    is(sessionHistory.getEntryAtIndex(0, false).URI.spec, "about:blank", "Should be the right URL");
+  });
 
   // Load a new URL into the tab, it should replace the about:blank history entry
   browser.loadURI("about:robots");
   yield promiseBrowserLoaded(browser);
-  sessionHistory = browser.sessionHistory;
-  is(sessionHistory.count, 1, "Should be a single history entry");
-  is(sessionHistory.getEntryAtIndex(0, false).URI.spec, "about:robots", "Should be the right URL");
+  yield ContentTask.spawn(browser, null, function() {
+    let sessionHistory = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+                                 .getInterface(Ci.nsISHistory);
+    is(sessionHistory.count, 1, "Should be a single history entry");
+    is(sessionHistory.getEntryAtIndex(0, false).URI.spec, "about:robots", "Should be the right URL");
+  });
 
   // Cleanup.
-  gBrowser.removeTab(tab);
+  yield promiseRemoveTab(tab);
 });
 
 /**
  * Check that entries default to being persisted when the attribute doesn't
  * exist
  */
 add_task(function* check_history_default_persisted() {
   // Create an about:blank tab
   let tab = gBrowser.addTab("about:blank");
   let browser = tab.linkedBrowser;
   yield promiseBrowserLoaded(browser);
 
   // Retrieve the tab state.
   yield TabStateFlusher.flush(browser);
   let state = JSON.parse(ss.getTabState(tab));
   delete state.entries[0].persist;
-  gBrowser.removeTab(tab);
+  yield promiseRemoveTab(tab);
   browser = null;
 
   // Open a new tab to restore into.
   tab = gBrowser.addTab("about:blank");
   browser = tab.linkedBrowser;
   yield promiseTabState(tab, state);
-  let sessionHistory = browser.sessionHistory;
+  yield ContentTask.spawn(browser, null, function() {
+    let sessionHistory = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+                                 .getInterface(Ci.nsISHistory);
 
-  is(sessionHistory.count, 1, "Should be a single history entry");
-  is(sessionHistory.getEntryAtIndex(0, false).URI.spec, "about:blank", "Should be the right URL");
+    is(sessionHistory.count, 1, "Should be a single history entry");
+    is(sessionHistory.getEntryAtIndex(0, false).URI.spec, "about:blank", "Should be the right URL");
+  });
 
   // Load a new URL into the tab, it should replace the about:blank history entry
   browser.loadURI("about:robots");
   yield promiseBrowserLoaded(browser);
-  sessionHistory = browser.sessionHistory;
-  is(sessionHistory.count, 2, "Should be two history entries");
-  is(sessionHistory.getEntryAtIndex(0, false).URI.spec, "about:blank", "Should be the right URL");
-  is(sessionHistory.getEntryAtIndex(1, false).URI.spec, "about:robots", "Should be the right URL");
+  yield ContentTask.spawn(browser, null, function() {
+    let sessionHistory = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+                                 .getInterface(Ci.nsISHistory);
+    is(sessionHistory.count, 2, "Should be two history entries");
+    is(sessionHistory.getEntryAtIndex(0, false).URI.spec, "about:blank", "Should be the right URL");
+    is(sessionHistory.getEntryAtIndex(1, false).URI.spec, "about:robots", "Should be the right URL");
+  });
 
   // Cleanup.
-  gBrowser.removeTab(tab);
+  yield promiseRemoveTab(tab);
 });