2011-10-26 02:52:17 -07:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
const TESTCASE_URI = TEST_BASE + "simple.html";
|
|
|
|
|
2013-04-25 09:46:13 -07:00
|
|
|
let gUI;
|
2011-10-26 02:52:17 -07:00
|
|
|
|
|
|
|
function test()
|
|
|
|
{
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2013-04-25 09:46:13 -07:00
|
|
|
addTabAndOpenStyleEditor(function(panel) {
|
|
|
|
gUI = panel.UI;
|
|
|
|
gUI.on("editor-added", testEditorAdded);
|
2011-10-26 02:52:17 -07:00
|
|
|
});
|
2013-04-24 17:17:39 -07:00
|
|
|
|
2013-04-25 09:46:13 -07:00
|
|
|
content.location = TESTCASE_URI;
|
2013-04-24 17:17:39 -07:00
|
|
|
}
|
|
|
|
|
2011-10-26 02:52:17 -07:00
|
|
|
let gEditorAddedCount = 0;
|
2013-04-25 09:46:13 -07:00
|
|
|
function testEditorAdded(aEvent, aEditor)
|
2011-10-26 02:52:17 -07:00
|
|
|
{
|
2013-04-25 09:46:13 -07:00
|
|
|
if (aEditor.styleSheet.styleSheetIndex == 0) {
|
2011-10-26 02:52:17 -07:00
|
|
|
gEditorAddedCount++;
|
2013-04-25 09:46:13 -07:00
|
|
|
testFirstStyleSheetEditor(aEditor);
|
2011-10-26 02:52:17 -07:00
|
|
|
}
|
2013-04-25 09:46:13 -07:00
|
|
|
if (aEditor.styleSheet.styleSheetIndex == 1) {
|
2011-10-26 02:52:17 -07:00
|
|
|
gEditorAddedCount++;
|
2013-04-25 09:46:13 -07:00
|
|
|
testSecondStyleSheetEditor(aEditor);
|
2011-10-26 02:52:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gEditorAddedCount == 2) {
|
2013-04-25 09:46:13 -07:00
|
|
|
gUI = null;
|
2011-10-26 02:52:17 -07:00
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-25 09:46:13 -07:00
|
|
|
function testFirstStyleSheetEditor(aEditor)
|
2011-10-26 02:52:17 -07:00
|
|
|
{
|
2012-09-06 02:43:50 -07:00
|
|
|
// Note: the html <link> contains charset="UTF-8".
|
|
|
|
ok(aEditor._state.text.indexOf("\u263a") >= 0,
|
|
|
|
"stylesheet is unicode-aware.");
|
|
|
|
|
2011-10-26 02:52:17 -07:00
|
|
|
//testing TESTCASE's simple.css stylesheet
|
2013-04-25 09:46:13 -07:00
|
|
|
is(aEditor.styleSheet.styleSheetIndex, 0,
|
2011-10-26 02:52:17 -07:00
|
|
|
"first stylesheet is at index 0");
|
|
|
|
|
2013-04-25 09:46:13 -07:00
|
|
|
is(aEditor, gUI.editors[0],
|
2011-10-26 02:52:17 -07:00
|
|
|
"first stylesheet corresponds to StyleEditorChrome.editors[0]");
|
|
|
|
|
2013-04-25 09:46:13 -07:00
|
|
|
let summary = aEditor.summary;
|
2011-10-26 02:52:17 -07:00
|
|
|
|
2012-01-23 11:26:03 -08:00
|
|
|
let name = summary.querySelector(".stylesheet-name > label").getAttribute("value");
|
2011-10-26 02:52:17 -07:00
|
|
|
is(name, "simple.css",
|
|
|
|
"first stylesheet's name is `simple.css`");
|
|
|
|
|
|
|
|
let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent;
|
|
|
|
is(parseInt(ruleCount), 1,
|
|
|
|
"first stylesheet UI shows rule count as 1");
|
|
|
|
|
|
|
|
ok(summary.classList.contains("splitview-active"),
|
|
|
|
"first stylesheet UI is focused/active");
|
|
|
|
}
|
|
|
|
|
2013-04-25 09:46:13 -07:00
|
|
|
function testSecondStyleSheetEditor(aEditor)
|
2011-10-26 02:52:17 -07:00
|
|
|
{
|
|
|
|
//testing TESTCASE's inline stylesheet
|
2013-04-25 09:46:13 -07:00
|
|
|
is(aEditor.styleSheet.styleSheetIndex, 1,
|
2011-10-26 02:52:17 -07:00
|
|
|
"second stylesheet is at index 1");
|
|
|
|
|
2013-04-25 09:46:13 -07:00
|
|
|
is(aEditor, gUI.editors[1],
|
2011-10-26 02:52:17 -07:00
|
|
|
"second stylesheet corresponds to StyleEditorChrome.editors[1]");
|
|
|
|
|
2013-04-25 09:46:13 -07:00
|
|
|
let summary = aEditor.summary;
|
2011-10-26 02:52:17 -07:00
|
|
|
|
2012-01-23 11:26:03 -08:00
|
|
|
let name = summary.querySelector(".stylesheet-name > label").getAttribute("value");
|
2011-10-26 02:52:17 -07:00
|
|
|
ok(/^<.*>$/.test(name),
|
|
|
|
"second stylesheet's name is surrounded by `<>`");
|
|
|
|
|
|
|
|
let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent;
|
|
|
|
is(parseInt(ruleCount), 3,
|
|
|
|
"second stylesheet UI shows rule count as 3");
|
|
|
|
|
|
|
|
ok(!summary.classList.contains("splitview-active"),
|
|
|
|
"second stylesheet UI is NOT focused/active");
|
|
|
|
}
|