browser/devtools/styleeditor/test/browser_styleeditor_enabled.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/styleeditor/test/browser_styleeditor_enabled.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,70 @@
     1.4 +/* vim: set ts=2 et sw=2 tw=80: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +// https rather than chrome to improve coverage
     1.9 +const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html";
    1.10 +
    1.11 +function test()
    1.12 +{
    1.13 +  waitForExplicitFinish();
    1.14 +
    1.15 +  let count = 0;
    1.16 +  addTabAndOpenStyleEditors(2, function(panel) {
    1.17 +    // we test against first stylesheet after all are ready
    1.18 +    let UI = panel.UI;
    1.19 +    let editor = UI.editors[0];
    1.20 +    editor.getSourceEditor().then(runTests.bind(this, UI, editor));
    1.21 +  });
    1.22 +
    1.23 +  content.location = TESTCASE_URI;
    1.24 +}
    1.25 +
    1.26 +function runTests(UI, editor)
    1.27 +{
    1.28 +  testEnabledToggle(UI, editor);
    1.29 +}
    1.30 +
    1.31 +function testEnabledToggle(UI, editor)
    1.32 +{
    1.33 +  let summary = editor.summary;
    1.34 +  let enabledToggle = summary.querySelector(".stylesheet-enabled");
    1.35 +  ok(enabledToggle, "enabled toggle button exists");
    1.36 +
    1.37 +  is(editor.styleSheet.disabled, false,
    1.38 +     "first stylesheet is initially enabled");
    1.39 +
    1.40 +  is(summary.classList.contains("disabled"), false,
    1.41 +     "first stylesheet is initially enabled, UI does not have DISABLED class");
    1.42 +
    1.43 +  let disabledToggleCount = 0;
    1.44 +  editor.on("property-change", function(event, property) {
    1.45 +    if (property != "disabled") {
    1.46 +      return;
    1.47 +    }
    1.48 +    disabledToggleCount++;
    1.49 +
    1.50 +    if (disabledToggleCount == 1) {
    1.51 +      is(editor.styleSheet.disabled, true, "first stylesheet is now disabled");
    1.52 +      is(summary.classList.contains("disabled"), true,
    1.53 +         "first stylesheet is now disabled, UI has DISABLED class");
    1.54 +
    1.55 +      // now toggle it back to enabled
    1.56 +      waitForFocus(function () {
    1.57 +        EventUtils.synthesizeMouseAtCenter(enabledToggle, {}, gPanelWindow);
    1.58 +      }, gPanelWindow);
    1.59 +      return;
    1.60 +    }
    1.61 +
    1.62 +    // disabledToggleCount == 2
    1.63 +    is(editor.styleSheet.disabled, false, "first stylesheet is now enabled again");
    1.64 +    is(summary.classList.contains("disabled"), false,
    1.65 +       "first stylesheet is now enabled again, UI does not have DISABLED class");
    1.66 +
    1.67 +    finish();
    1.68 +  });
    1.69 +
    1.70 +  waitForFocus(function () {
    1.71 +    EventUtils.synthesizeMouseAtCenter(enabledToggle, {}, gPanelWindow);
    1.72 +  }, gPanelWindow);
    1.73 +}

mercurial