browser/devtools/styleeditor/test/browser_styleeditor_init.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.

     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 const TESTCASE_URI = TEST_BASE + "simple.html";
     7 let gUI;
     9 function test()
    10 {
    11   waitForExplicitFinish();
    13   addTabAndCheckOnStyleEditorAdded(panel => gUI = panel.UI, testEditorAdded);
    15   content.location = TESTCASE_URI;
    16 }
    18 let gEditorAddedCount = 0;
    19 function testEditorAdded(aEditor)
    20 {
    21   if (aEditor.styleSheet.styleSheetIndex == 0) {
    22     gEditorAddedCount++;
    23     testFirstStyleSheetEditor(aEditor);
    24   }
    25   if (aEditor.styleSheet.styleSheetIndex == 1) {
    26     gEditorAddedCount++;
    27     testSecondStyleSheetEditor(aEditor);
    28   }
    30   if (gEditorAddedCount == 2) {
    31     gUI = null;
    32     finish();
    33   }
    34 }
    36 function testFirstStyleSheetEditor(aEditor)
    37 {
    38   // Note: the html <link> contains charset="UTF-8".
    39   ok(aEditor._state.text.indexOf("\u263a") >= 0,
    40      "stylesheet is unicode-aware.");
    42   //testing TESTCASE's simple.css stylesheet
    43   is(aEditor.styleSheet.styleSheetIndex, 0,
    44      "first stylesheet is at index 0");
    46   is(aEditor, gUI.editors[0],
    47      "first stylesheet corresponds to StyleEditorChrome.editors[0]");
    49   let summary = aEditor.summary;
    51   let name = summary.querySelector(".stylesheet-name > label").getAttribute("value");
    52   is(name, "simple.css",
    53      "first stylesheet's name is `simple.css`");
    55   let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent;
    56   is(parseInt(ruleCount), 1,
    57      "first stylesheet UI shows rule count as 1");
    59   ok(summary.classList.contains("splitview-active"),
    60      "first stylesheet UI is focused/active");
    61 }
    63 function testSecondStyleSheetEditor(aEditor)
    64 {
    65   //testing TESTCASE's inline stylesheet
    66   is(aEditor.styleSheet.styleSheetIndex, 1,
    67      "second stylesheet is at index 1");
    69   is(aEditor, gUI.editors[1],
    70      "second stylesheet corresponds to StyleEditorChrome.editors[1]");
    72   let summary = aEditor.summary;
    74   let name = summary.querySelector(".stylesheet-name > label").getAttribute("value");
    75   ok(/^<.*>$/.test(name),
    76      "second stylesheet's name is surrounded by `<>`");
    78   let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent;
    79   is(parseInt(ruleCount), 3,
    80      "second stylesheet UI shows rule count as 3");
    82   ok(!summary.classList.contains("splitview-active"),
    83      "second stylesheet UI is NOT focused/active");
    84 }

mercurial