browser/devtools/styleeditor/test/browser_styleeditor_init.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_init.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,84 @@
     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 +const TESTCASE_URI = TEST_BASE + "simple.html";
     1.9 +
    1.10 +let gUI;
    1.11 +
    1.12 +function test()
    1.13 +{
    1.14 +  waitForExplicitFinish();
    1.15 +
    1.16 +  addTabAndCheckOnStyleEditorAdded(panel => gUI = panel.UI, testEditorAdded);
    1.17 +
    1.18 +  content.location = TESTCASE_URI;
    1.19 +}
    1.20 +
    1.21 +let gEditorAddedCount = 0;
    1.22 +function testEditorAdded(aEditor)
    1.23 +{
    1.24 +  if (aEditor.styleSheet.styleSheetIndex == 0) {
    1.25 +    gEditorAddedCount++;
    1.26 +    testFirstStyleSheetEditor(aEditor);
    1.27 +  }
    1.28 +  if (aEditor.styleSheet.styleSheetIndex == 1) {
    1.29 +    gEditorAddedCount++;
    1.30 +    testSecondStyleSheetEditor(aEditor);
    1.31 +  }
    1.32 +
    1.33 +  if (gEditorAddedCount == 2) {
    1.34 +    gUI = null;
    1.35 +    finish();
    1.36 +  }
    1.37 +}
    1.38 +
    1.39 +function testFirstStyleSheetEditor(aEditor)
    1.40 +{
    1.41 +  // Note: the html <link> contains charset="UTF-8".
    1.42 +  ok(aEditor._state.text.indexOf("\u263a") >= 0,
    1.43 +     "stylesheet is unicode-aware.");
    1.44 +
    1.45 +  //testing TESTCASE's simple.css stylesheet
    1.46 +  is(aEditor.styleSheet.styleSheetIndex, 0,
    1.47 +     "first stylesheet is at index 0");
    1.48 +
    1.49 +  is(aEditor, gUI.editors[0],
    1.50 +     "first stylesheet corresponds to StyleEditorChrome.editors[0]");
    1.51 +
    1.52 +  let summary = aEditor.summary;
    1.53 +
    1.54 +  let name = summary.querySelector(".stylesheet-name > label").getAttribute("value");
    1.55 +  is(name, "simple.css",
    1.56 +     "first stylesheet's name is `simple.css`");
    1.57 +
    1.58 +  let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent;
    1.59 +  is(parseInt(ruleCount), 1,
    1.60 +     "first stylesheet UI shows rule count as 1");
    1.61 +
    1.62 +  ok(summary.classList.contains("splitview-active"),
    1.63 +     "first stylesheet UI is focused/active");
    1.64 +}
    1.65 +
    1.66 +function testSecondStyleSheetEditor(aEditor)
    1.67 +{
    1.68 +  //testing TESTCASE's inline stylesheet
    1.69 +  is(aEditor.styleSheet.styleSheetIndex, 1,
    1.70 +     "second stylesheet is at index 1");
    1.71 +
    1.72 +  is(aEditor, gUI.editors[1],
    1.73 +     "second stylesheet corresponds to StyleEditorChrome.editors[1]");
    1.74 +
    1.75 +  let summary = aEditor.summary;
    1.76 +
    1.77 +  let name = summary.querySelector(".stylesheet-name > label").getAttribute("value");
    1.78 +  ok(/^<.*>$/.test(name),
    1.79 +     "second stylesheet's name is surrounded by `<>`");
    1.80 +
    1.81 +  let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent;
    1.82 +  is(parseInt(ruleCount), 3,
    1.83 +     "second stylesheet UI shows rule count as 3");
    1.84 +
    1.85 +  ok(!summary.classList.contains("splitview-active"),
    1.86 +     "second stylesheet UI is NOT focused/active");
    1.87 +}

mercurial