Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/ */
5 // https rather than chrome to improve coverage
6 const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html";
8 function test()
9 {
10 waitForExplicitFinish();
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 });
20 content.location = TESTCASE_URI;
21 }
23 function runTests(UI, editor)
24 {
25 testEnabledToggle(UI, editor);
26 }
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");
34 is(editor.styleSheet.disabled, false,
35 "first stylesheet is initially enabled");
37 is(summary.classList.contains("disabled"), false,
38 "first stylesheet is initially enabled, UI does not have DISABLED class");
40 let disabledToggleCount = 0;
41 editor.on("property-change", function(event, property) {
42 if (property != "disabled") {
43 return;
44 }
45 disabledToggleCount++;
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");
52 // now toggle it back to enabled
53 waitForFocus(function () {
54 EventUtils.synthesizeMouseAtCenter(enabledToggle, {}, gPanelWindow);
55 }, gPanelWindow);
56 return;
57 }
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");
64 finish();
65 });
67 waitForFocus(function () {
68 EventUtils.synthesizeMouseAtCenter(enabledToggle, {}, gPanelWindow);
69 }, gPanelWindow);
70 }