michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const TESTCASE_URI = TEST_BASE + "simple.html"; michael@0: michael@0: let gUI; michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: addTabAndCheckOnStyleEditorAdded(panel => gUI = panel.UI, testEditorAdded); michael@0: michael@0: content.location = TESTCASE_URI; michael@0: } michael@0: michael@0: let gEditorAddedCount = 0; michael@0: function testEditorAdded(aEditor) michael@0: { michael@0: if (aEditor.styleSheet.styleSheetIndex == 0) { michael@0: gEditorAddedCount++; michael@0: testFirstStyleSheetEditor(aEditor); michael@0: } michael@0: if (aEditor.styleSheet.styleSheetIndex == 1) { michael@0: gEditorAddedCount++; michael@0: testSecondStyleSheetEditor(aEditor); michael@0: } michael@0: michael@0: if (gEditorAddedCount == 2) { michael@0: gUI = null; michael@0: finish(); michael@0: } michael@0: } michael@0: michael@0: function testFirstStyleSheetEditor(aEditor) michael@0: { michael@0: // Note: the html contains charset="UTF-8". michael@0: ok(aEditor._state.text.indexOf("\u263a") >= 0, michael@0: "stylesheet is unicode-aware."); michael@0: michael@0: //testing TESTCASE's simple.css stylesheet michael@0: is(aEditor.styleSheet.styleSheetIndex, 0, michael@0: "first stylesheet is at index 0"); michael@0: michael@0: is(aEditor, gUI.editors[0], michael@0: "first stylesheet corresponds to StyleEditorChrome.editors[0]"); michael@0: michael@0: let summary = aEditor.summary; michael@0: michael@0: let name = summary.querySelector(".stylesheet-name > label").getAttribute("value"); michael@0: is(name, "simple.css", michael@0: "first stylesheet's name is `simple.css`"); michael@0: michael@0: let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent; michael@0: is(parseInt(ruleCount), 1, michael@0: "first stylesheet UI shows rule count as 1"); michael@0: michael@0: ok(summary.classList.contains("splitview-active"), michael@0: "first stylesheet UI is focused/active"); michael@0: } michael@0: michael@0: function testSecondStyleSheetEditor(aEditor) michael@0: { michael@0: //testing TESTCASE's inline stylesheet michael@0: is(aEditor.styleSheet.styleSheetIndex, 1, michael@0: "second stylesheet is at index 1"); michael@0: michael@0: is(aEditor, gUI.editors[1], michael@0: "second stylesheet corresponds to StyleEditorChrome.editors[1]"); michael@0: michael@0: let summary = aEditor.summary; michael@0: michael@0: let name = summary.querySelector(".stylesheet-name > label").getAttribute("value"); michael@0: ok(/^<.*>$/.test(name), michael@0: "second stylesheet's name is surrounded by `<>`"); michael@0: michael@0: let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent; michael@0: is(parseInt(ruleCount), 3, michael@0: "second stylesheet UI shows rule count as 3"); michael@0: michael@0: ok(!summary.classList.contains("splitview-active"), michael@0: "second stylesheet UI is NOT focused/active"); michael@0: }