1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/* 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() {
/** Test for Bug 408470 **/
waitForExplicitFinish();
let pendingCount = 1;
let rootDir = getRootDirectory(gTestPath);
let testURL = rootDir + "browser_408470_sample.html";
let tab = getBrowser().addTab(testURL);
let window = tab.ownerDocument.defaultView;
tab.linkedBrowser.addEventListener("load", function loadListener1(aEvent) {
tab.linkedBrowser.removeEventListener("load", loadListener1, true);
// enable all stylesheets and verify that they're correctly persisted
Array.from(tab.linkedBrowser.contentDocument.styleSheets).forEach(function(aSS, aIx) {
pendingCount++;
let ssTitle = aSS.title;
stylesheetSwitchAll(tab.linkedBrowser.contentWindow, ssTitle);
let newTab = ss.duplicateTab(window,tab);
newTab.linkedBrowser.addEventListener("load", function loadListener2(aEvent) {
newTab.linkedBrowser.removeEventListener("load", loadListener2, true);
let states = Array.from(newTab.linkedBrowser.contentDocument.styleSheets,
aSS => !aSS.disabled);
let correct = states.indexOf(true) == aIx && !states.includes(true, aIx + 1);
if (/^fail_/.test(ssTitle))
ok(!correct, "didn't restore stylesheet " + ssTitle);
else
ok(correct, "restored stylesheet " + ssTitle);
getBrowser().removeTab(newTab);
if (--pendingCount == 0)
finish();
}, true);
});
// disable all styles and verify that this is correctly persisted
tab.linkedBrowser.markupDocumentViewer.authorStyleDisabled = true;
let newTab = ss.duplicateTab(window,tab);
newTab.linkedBrowser.addEventListener("load", function loadListener3(aEvent) {
newTab.linkedBrowser.removeEventListener("load", loadListener3, true);
is(newTab.linkedBrowser.markupDocumentViewer.authorStyleDisabled, true,
"disabled all stylesheets");
getBrowser().removeTab(newTab);
if (--pendingCount == 0)
finish();
}, true);
getBrowser().removeTab(tab);
}, true);
}
|