1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that sheets inside iframes are shown in the editor.
add_task(function* () {
function makeStylesheet(selector) {
return ("data:text/css;charset=UTF-8," +
encodeURIComponent(selector + " { }"));
}
function makeDocument(stylesheets, framedDocuments) {
stylesheets = stylesheets || [];
framedDocuments = framedDocuments || [];
return "data:text/html;charset=UTF-8," + encodeURIComponent(
Array.prototype.concat.call(
["<!DOCTYPE html>",
"<html>",
"<head>",
"<title>Bug 740541</title>"],
stylesheets.map(function (sheet) {
return '<link rel="stylesheet" type="text/css" href="' + sheet + '">';
}),
["</head>",
"<body>"],
framedDocuments.map(function (doc) {
return '<iframe src="' + doc + '"></iframe>';
}),
["</body>",
"</html>"]
).join("\n"));
}
const DOCUMENT_WITH_INLINE_STYLE = "data:text/html;charset=UTF-8," +
encodeURIComponent(
["<!DOCTYPE html>",
"<html>",
" <head>",
" <title>Bug 740541</title>",
' <style type="text/css">',
" .something {",
" }",
" </style>",
" </head>",
" <body>",
" </body>",
" </html>"
].join("\n"));
const FOUR = TEST_BASE_HTTP + "four.html";
const SIMPLE = TEST_BASE_HTTP + "simple.css";
const SIMPLE_DOCUMENT = TEST_BASE_HTTP + "simple.html";
const TESTCASE_URI = makeDocument(
[makeStylesheet(".a")],
[makeDocument([],
[FOUR,
DOCUMENT_WITH_INLINE_STYLE]),
makeDocument([makeStylesheet(".b"),
SIMPLE],
[makeDocument([makeStylesheet(".c")],
[])]),
makeDocument([SIMPLE], []),
SIMPLE_DOCUMENT
]);
const EXPECTED_STYLE_SHEET_COUNT = 12;
let { ui } = yield openStyleEditorForURL(TESTCASE_URI);
is(ui.editors.length, EXPECTED_STYLE_SHEET_COUNT,
"Got the expected number of style sheets.");
});
|