browser/devtools/styleeditor/test/browser_styleeditor_enabled.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial