michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // https rather than chrome to improve coverage michael@0: const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html"; michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: let count = 0; michael@0: addTabAndOpenStyleEditors(2, function(panel) { michael@0: // we test against first stylesheet after all are ready michael@0: let UI = panel.UI; michael@0: let editor = UI.editors[0]; michael@0: editor.getSourceEditor().then(runTests.bind(this, UI, editor)); michael@0: }); michael@0: michael@0: content.location = TESTCASE_URI; michael@0: } michael@0: michael@0: function runTests(UI, editor) michael@0: { michael@0: testEnabledToggle(UI, editor); michael@0: } michael@0: michael@0: function testEnabledToggle(UI, editor) michael@0: { michael@0: let summary = editor.summary; michael@0: let enabledToggle = summary.querySelector(".stylesheet-enabled"); michael@0: ok(enabledToggle, "enabled toggle button exists"); michael@0: michael@0: is(editor.styleSheet.disabled, false, michael@0: "first stylesheet is initially enabled"); michael@0: michael@0: is(summary.classList.contains("disabled"), false, michael@0: "first stylesheet is initially enabled, UI does not have DISABLED class"); michael@0: michael@0: let disabledToggleCount = 0; michael@0: editor.on("property-change", function(event, property) { michael@0: if (property != "disabled") { michael@0: return; michael@0: } michael@0: disabledToggleCount++; michael@0: michael@0: if (disabledToggleCount == 1) { michael@0: is(editor.styleSheet.disabled, true, "first stylesheet is now disabled"); michael@0: is(summary.classList.contains("disabled"), true, michael@0: "first stylesheet is now disabled, UI has DISABLED class"); michael@0: michael@0: // now toggle it back to enabled michael@0: waitForFocus(function () { michael@0: EventUtils.synthesizeMouseAtCenter(enabledToggle, {}, gPanelWindow); michael@0: }, gPanelWindow); michael@0: return; michael@0: } michael@0: michael@0: // disabledToggleCount == 2 michael@0: is(editor.styleSheet.disabled, false, "first stylesheet is now enabled again"); michael@0: is(summary.classList.contains("disabled"), false, michael@0: "first stylesheet is now enabled again, UI does not have DISABLED class"); michael@0: michael@0: finish(); michael@0: }); michael@0: michael@0: waitForFocus(function () { michael@0: EventUtils.synthesizeMouseAtCenter(enabledToggle, {}, gPanelWindow); michael@0: }, gPanelWindow); michael@0: }