browser/devtools/styleeditor/test/browser_styleeditor_private_perwindowpb.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/styleeditor/test/browser_styleeditor_private_perwindowpb.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     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 +// This test makes sure that the style editor does not store any
     1.9 +// content CSS files in the permanent cache when opened from PB mode.
    1.10 +
    1.11 +let gUI;
    1.12 +
    1.13 +function test() {
    1.14 +  waitForExplicitFinish();
    1.15 +  let windowsToClose = [];
    1.16 +  let testURI = 'http://' + TEST_HOST + '/browser/browser/devtools/styleeditor/test/test_private.html';
    1.17 +
    1.18 +  function checkCache() {
    1.19 +    checkDiskCacheFor(TEST_HOST, function() {
    1.20 +      gUI = null;
    1.21 +      finish();
    1.22 +    });
    1.23 +  }
    1.24 +
    1.25 +  function doTest(aWindow) {
    1.26 +    aWindow.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
    1.27 +      aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
    1.28 +      cache.clear();
    1.29 +      openStyleEditorInWindow(aWindow, function(panel) {
    1.30 +        gUI = panel.UI;
    1.31 +        gUI.on("editor-added", onEditorAdded);
    1.32 +      });
    1.33 +    }, true);
    1.34 +
    1.35 +    aWindow.gBrowser.selectedBrowser.loadURI(testURI);
    1.36 +  }
    1.37 +
    1.38 +  function onEditorAdded(aEvent, aEditor) {
    1.39 +    aEditor.getSourceEditor().then(checkCache);
    1.40 +  }
    1.41 +
    1.42 +  function testOnWindow(options, callback) {
    1.43 +    let win = OpenBrowserWindow(options);
    1.44 +    win.addEventListener("load", function onLoad() {
    1.45 +      win.removeEventListener("load", onLoad, false);
    1.46 +      windowsToClose.push(win);
    1.47 +      executeSoon(function() callback(win));
    1.48 +    }, false);
    1.49 +  };
    1.50 +
    1.51 +  registerCleanupFunction(function() {
    1.52 +    windowsToClose.forEach(function(win) {
    1.53 +      win.close();
    1.54 +    });
    1.55 +  });
    1.56 +
    1.57 +  testOnWindow({private: true}, function(win) {
    1.58 +    doTest(win);
    1.59 +  });
    1.60 +}

mercurial