|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 // This test makes sure that the style editor does not store any |
|
6 // content CSS files in the permanent cache when opened from PB mode. |
|
7 |
|
8 let gUI; |
|
9 |
|
10 function test() { |
|
11 waitForExplicitFinish(); |
|
12 let windowsToClose = []; |
|
13 let testURI = 'http://' + TEST_HOST + '/browser/browser/devtools/styleeditor/test/test_private.html'; |
|
14 |
|
15 function checkCache() { |
|
16 checkDiskCacheFor(TEST_HOST, function() { |
|
17 gUI = null; |
|
18 finish(); |
|
19 }); |
|
20 } |
|
21 |
|
22 function doTest(aWindow) { |
|
23 aWindow.gBrowser.selectedBrowser.addEventListener("load", function onLoad() { |
|
24 aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); |
|
25 cache.clear(); |
|
26 openStyleEditorInWindow(aWindow, function(panel) { |
|
27 gUI = panel.UI; |
|
28 gUI.on("editor-added", onEditorAdded); |
|
29 }); |
|
30 }, true); |
|
31 |
|
32 aWindow.gBrowser.selectedBrowser.loadURI(testURI); |
|
33 } |
|
34 |
|
35 function onEditorAdded(aEvent, aEditor) { |
|
36 aEditor.getSourceEditor().then(checkCache); |
|
37 } |
|
38 |
|
39 function testOnWindow(options, callback) { |
|
40 let win = OpenBrowserWindow(options); |
|
41 win.addEventListener("load", function onLoad() { |
|
42 win.removeEventListener("load", onLoad, false); |
|
43 windowsToClose.push(win); |
|
44 executeSoon(function() callback(win)); |
|
45 }, false); |
|
46 }; |
|
47 |
|
48 registerCleanupFunction(function() { |
|
49 windowsToClose.forEach(function(win) { |
|
50 win.close(); |
|
51 }); |
|
52 }); |
|
53 |
|
54 testOnWindow({private: true}, function(win) { |
|
55 doTest(win); |
|
56 }); |
|
57 } |