browser/devtools/styleeditor/test/browser_styleeditor_init.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:1049ac06b950
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/ */
4
5 const TESTCASE_URI = TEST_BASE + "simple.html";
6
7 let gUI;
8
9 function test()
10 {
11 waitForExplicitFinish();
12
13 addTabAndCheckOnStyleEditorAdded(panel => gUI = panel.UI, testEditorAdded);
14
15 content.location = TESTCASE_URI;
16 }
17
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 }
29
30 if (gEditorAddedCount == 2) {
31 gUI = null;
32 finish();
33 }
34 }
35
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.");
41
42 //testing TESTCASE's simple.css stylesheet
43 is(aEditor.styleSheet.styleSheetIndex, 0,
44 "first stylesheet is at index 0");
45
46 is(aEditor, gUI.editors[0],
47 "first stylesheet corresponds to StyleEditorChrome.editors[0]");
48
49 let summary = aEditor.summary;
50
51 let name = summary.querySelector(".stylesheet-name > label").getAttribute("value");
52 is(name, "simple.css",
53 "first stylesheet's name is `simple.css`");
54
55 let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent;
56 is(parseInt(ruleCount), 1,
57 "first stylesheet UI shows rule count as 1");
58
59 ok(summary.classList.contains("splitview-active"),
60 "first stylesheet UI is focused/active");
61 }
62
63 function testSecondStyleSheetEditor(aEditor)
64 {
65 //testing TESTCASE's inline stylesheet
66 is(aEditor.styleSheet.styleSheetIndex, 1,
67 "second stylesheet is at index 1");
68
69 is(aEditor, gUI.editors[1],
70 "second stylesheet corresponds to StyleEditorChrome.editors[1]");
71
72 let summary = aEditor.summary;
73
74 let name = summary.querySelector(".stylesheet-name > label").getAttribute("value");
75 ok(/^<.*>$/.test(name),
76 "second stylesheet's name is surrounded by `<>`");
77
78 let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent;
79 is(parseInt(ruleCount), 3,
80 "second stylesheet UI shows rule count as 3");
81
82 ok(!summary.classList.contains("splitview-active"),
83 "second stylesheet UI is NOT focused/active");
84 }

mercurial