|
1 /* vim: set ts=2 et sw=2 tw=80: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 // https rather than chrome to improve coverage |
|
6 const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html"; |
|
7 |
|
8 function test() |
|
9 { |
|
10 waitForExplicitFinish(); |
|
11 |
|
12 let count = 0; |
|
13 addTabAndOpenStyleEditors(2, function(panel) { |
|
14 // we test against first stylesheet after all are ready |
|
15 let UI = panel.UI; |
|
16 let editor = UI.editors[0]; |
|
17 editor.getSourceEditor().then(runTests.bind(this, UI, editor)); |
|
18 }); |
|
19 |
|
20 content.location = TESTCASE_URI; |
|
21 } |
|
22 |
|
23 function runTests(UI, editor) |
|
24 { |
|
25 testEnabledToggle(UI, editor); |
|
26 } |
|
27 |
|
28 function testEnabledToggle(UI, editor) |
|
29 { |
|
30 let summary = editor.summary; |
|
31 let enabledToggle = summary.querySelector(".stylesheet-enabled"); |
|
32 ok(enabledToggle, "enabled toggle button exists"); |
|
33 |
|
34 is(editor.styleSheet.disabled, false, |
|
35 "first stylesheet is initially enabled"); |
|
36 |
|
37 is(summary.classList.contains("disabled"), false, |
|
38 "first stylesheet is initially enabled, UI does not have DISABLED class"); |
|
39 |
|
40 let disabledToggleCount = 0; |
|
41 editor.on("property-change", function(event, property) { |
|
42 if (property != "disabled") { |
|
43 return; |
|
44 } |
|
45 disabledToggleCount++; |
|
46 |
|
47 if (disabledToggleCount == 1) { |
|
48 is(editor.styleSheet.disabled, true, "first stylesheet is now disabled"); |
|
49 is(summary.classList.contains("disabled"), true, |
|
50 "first stylesheet is now disabled, UI has DISABLED class"); |
|
51 |
|
52 // now toggle it back to enabled |
|
53 waitForFocus(function () { |
|
54 EventUtils.synthesizeMouseAtCenter(enabledToggle, {}, gPanelWindow); |
|
55 }, gPanelWindow); |
|
56 return; |
|
57 } |
|
58 |
|
59 // disabledToggleCount == 2 |
|
60 is(editor.styleSheet.disabled, false, "first stylesheet is now enabled again"); |
|
61 is(summary.classList.contains("disabled"), false, |
|
62 "first stylesheet is now enabled again, UI does not have DISABLED class"); |
|
63 |
|
64 finish(); |
|
65 }); |
|
66 |
|
67 waitForFocus(function () { |
|
68 EventUtils.synthesizeMouseAtCenter(enabledToggle, {}, gPanelWindow); |
|
69 }, gPanelWindow); |
|
70 } |