Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 2 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 4 | |
michael@0 | 5 | const TESTCASE_URI = TEST_BASE + "simple.html"; |
michael@0 | 6 | |
michael@0 | 7 | let gUI; |
michael@0 | 8 | |
michael@0 | 9 | function test() |
michael@0 | 10 | { |
michael@0 | 11 | waitForExplicitFinish(); |
michael@0 | 12 | |
michael@0 | 13 | addTabAndCheckOnStyleEditorAdded(panel => gUI = panel.UI, testEditorAdded); |
michael@0 | 14 | |
michael@0 | 15 | content.location = TESTCASE_URI; |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | let gEditorAddedCount = 0; |
michael@0 | 19 | function testEditorAdded(aEditor) |
michael@0 | 20 | { |
michael@0 | 21 | if (aEditor.styleSheet.styleSheetIndex == 0) { |
michael@0 | 22 | gEditorAddedCount++; |
michael@0 | 23 | testFirstStyleSheetEditor(aEditor); |
michael@0 | 24 | } |
michael@0 | 25 | if (aEditor.styleSheet.styleSheetIndex == 1) { |
michael@0 | 26 | gEditorAddedCount++; |
michael@0 | 27 | testSecondStyleSheetEditor(aEditor); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | if (gEditorAddedCount == 2) { |
michael@0 | 31 | gUI = null; |
michael@0 | 32 | finish(); |
michael@0 | 33 | } |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function testFirstStyleSheetEditor(aEditor) |
michael@0 | 37 | { |
michael@0 | 38 | // Note: the html <link> contains charset="UTF-8". |
michael@0 | 39 | ok(aEditor._state.text.indexOf("\u263a") >= 0, |
michael@0 | 40 | "stylesheet is unicode-aware."); |
michael@0 | 41 | |
michael@0 | 42 | //testing TESTCASE's simple.css stylesheet |
michael@0 | 43 | is(aEditor.styleSheet.styleSheetIndex, 0, |
michael@0 | 44 | "first stylesheet is at index 0"); |
michael@0 | 45 | |
michael@0 | 46 | is(aEditor, gUI.editors[0], |
michael@0 | 47 | "first stylesheet corresponds to StyleEditorChrome.editors[0]"); |
michael@0 | 48 | |
michael@0 | 49 | let summary = aEditor.summary; |
michael@0 | 50 | |
michael@0 | 51 | let name = summary.querySelector(".stylesheet-name > label").getAttribute("value"); |
michael@0 | 52 | is(name, "simple.css", |
michael@0 | 53 | "first stylesheet's name is `simple.css`"); |
michael@0 | 54 | |
michael@0 | 55 | let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent; |
michael@0 | 56 | is(parseInt(ruleCount), 1, |
michael@0 | 57 | "first stylesheet UI shows rule count as 1"); |
michael@0 | 58 | |
michael@0 | 59 | ok(summary.classList.contains("splitview-active"), |
michael@0 | 60 | "first stylesheet UI is focused/active"); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | function testSecondStyleSheetEditor(aEditor) |
michael@0 | 64 | { |
michael@0 | 65 | //testing TESTCASE's inline stylesheet |
michael@0 | 66 | is(aEditor.styleSheet.styleSheetIndex, 1, |
michael@0 | 67 | "second stylesheet is at index 1"); |
michael@0 | 68 | |
michael@0 | 69 | is(aEditor, gUI.editors[1], |
michael@0 | 70 | "second stylesheet corresponds to StyleEditorChrome.editors[1]"); |
michael@0 | 71 | |
michael@0 | 72 | let summary = aEditor.summary; |
michael@0 | 73 | |
michael@0 | 74 | let name = summary.querySelector(".stylesheet-name > label").getAttribute("value"); |
michael@0 | 75 | ok(/^<.*>$/.test(name), |
michael@0 | 76 | "second stylesheet's name is surrounded by `<>`"); |
michael@0 | 77 | |
michael@0 | 78 | let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent; |
michael@0 | 79 | is(parseInt(ruleCount), 3, |
michael@0 | 80 | "second stylesheet UI shows rule count as 3"); |
michael@0 | 81 | |
michael@0 | 82 | ok(!summary.classList.contains("splitview-active"), |
michael@0 | 83 | "second stylesheet UI is NOT focused/active"); |
michael@0 | 84 | } |