diff options
Diffstat (limited to 'toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js')
-rw-r--r-- | toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js b/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js deleted file mode 100644 index abde69a7d..000000000 --- a/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js +++ /dev/null @@ -1,73 +0,0 @@ -/* 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() { - // initialization - waitForExplicitFinish(); - let windowsToClose = []; - let initialURL = - "http://example.com/tests/toolkit/components/places/tests/browser/begin.html"; - let finalURL = - "http://example.com/tests/toolkit/components/places/tests/browser/final.html"; - let observer = null; - let enumerator = null; - let currentObserver = null; - let uri = null; - - function doTest(aIsPrivateMode, aWindow, aTestURI, aCallback) { - observer = { - observe: function(aSubject, aTopic, aData) { - // The uri-visit-saved topic should only work when on normal mode. - if (aTopic == "uri-visit-saved") { - // Remove the observers set on per window private mode and normal - // mode. - enumerator = aWindow.Services.obs.enumerateObservers("uri-visit-saved"); - while (enumerator.hasMoreElements()) { - currentObserver = enumerator.getNext(); - aWindow.Services.obs.removeObserver(currentObserver, "uri-visit-saved"); - } - - // The expected visit should be the finalURL because private mode - // should not register a visit with the initialURL. - uri = aSubject.QueryInterface(Ci.nsIURI); - is(uri.spec, finalURL, "Check received expected visit"); - } - } - }; - - aWindow.Services.obs.addObserver(observer, "uri-visit-saved", false); - - BrowserTestUtils.browserLoaded(aWindow.gBrowser.selectedBrowser).then(aCallback); - aWindow.gBrowser.selectedBrowser.loadURI(aTestURI); - } - - function testOnWindow(aOptions, aCallback) { - whenNewWindowLoaded(aOptions, function(aWin) { - windowsToClose.push(aWin); - // execute should only be called when need, like when you are opening - // web pages on the test. If calling executeSoon() is not necesary, then - // call whenNewWindowLoaded() instead of testOnWindow() on your test. - executeSoon(() => aCallback(aWin)); - }); - } - - // This function is called after calling finish() on the test. - registerCleanupFunction(function() { - windowsToClose.forEach(function(aWin) { - aWin.close(); - }); - }); - - // test first when on private mode - testOnWindow({private: true}, function(aWin) { - doTest(true, aWin, initialURL, function() { - // then test when not on private mode - testOnWindow({}, function(aWin2) { - doTest(false, aWin2, finalURL, function () { - PlacesTestUtils.clearHistory().then(finish); - }); - }); - }); - }); -} |