toolkit/components/places/tests/browser/browser_favicon_privatebrowsing_perwindowpb.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/browser/browser_favicon_privatebrowsing_perwindowpb.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +function test() {
     1.9 +  waitForExplicitFinish();
    1.10 +
    1.11 +  const pageURI =
    1.12 +   "http://example.org/tests/toolkit/components/places/tests/browser/favicon.html";
    1.13 +  let windowsToClose = [];
    1.14 +
    1.15 +  registerCleanupFunction(function() {
    1.16 +    windowsToClose.forEach(function(aWin) {
    1.17 +      aWin.close();
    1.18 +    });
    1.19 +  });
    1.20 +
    1.21 +  function testOnWindow(aIsPrivate, aCallback) {
    1.22 +    whenNewWindowLoaded({private: aIsPrivate}, function(aWin) {
    1.23 +      windowsToClose.push(aWin);
    1.24 +      executeSoon(function() aCallback(aWin));
    1.25 +    });
    1.26 +  };
    1.27 +
    1.28 +  function waitForTabLoad(aWin, aCallback) {
    1.29 +    aWin.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
    1.30 +      aWin.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
    1.31 +      aCallback();
    1.32 +    }, true);
    1.33 +    aWin.gBrowser.selectedBrowser.loadURI(pageURI);
    1.34 +  }
    1.35 +
    1.36 +  testOnWindow(true, function(win) {
    1.37 +    waitForTabLoad(win, function() {
    1.38 +      PlacesUtils.favicons.getFaviconURLForPage(NetUtil.newURI(pageURI),
    1.39 +        function(uri, dataLen, data, mimeType) {
    1.40 +          is(uri, null, "No result should be found");
    1.41 +          finish();
    1.42 +        }
    1.43 +      );
    1.44 +    });
    1.45 +  });
    1.46 +}

mercurial