fune/dom/base/test/test_style_cssText.html
Brian Grinstead 0d460e3432 Bug 1544322 - Part 2.2 - Remove the [type] attribute for one-liner <script> tags loading files in /tests/SimpleTest/ in dom/ r=bzbarsky
This is split from the previous changeset since if we include dom/ the file size is too
large for phabricator to handle.

This is an autogenerated commit to handle scripts loading mochitest harness files, in
the simple case where the script src is on the same line as the tag.

This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170
using the `--part 2` argument.

Differential Revision: https://phabricator.services.mozilla.com/D27457

--HG--
extra : moz-landing-system : lando
2019-04-16 03:53:28 +00:00

85 lines
1.8 KiB
HTML

<html>
<head>
<meta charset="UTF-8">
<title>Test for Bug 1391169</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style id="style"></style>
</head>
<body>
<pre id="log">
Log is:
</pre>
<script>
let styleElement = document.getElementById("style");
let logElement = document.getElementById("log");
console.log("logElement is " + logElement);
function log(text)
{
logElement.innerHTML += text + "\n";
}
function textContentToCssText(text)
{
// Pass input in via textContent.
styleElement.textContent = text;
// Read output from concatenated cssText of all rules.
let s = "";
let rules = document.styleSheets[1].cssRules;
for (let i = 0; i < rules.length; ++i) {
s += rules.item(i).cssText;
}
return s;
}
function noWhitespace(text)
{
return text.replace(/\s/g, "");
}
function testData(input)
{
let text;
let pass1Goal;
if (typeof(input) == "string") {
// Only text data, assume characters should be the same.
text = input;
pass1Goal = input;
} else {
[text, pass1Goal] = input;
}
let pass1Text = textContentToCssText(text);
is(noWhitespace(pass1Text), noWhitespace(pass1Goal), "textContent --> cssText correct characters emitted with input \"" + text + "\"");
let pass2Text = textContentToCssText(pass1Text);
is(pass2Text, pass1Text, "textContent --> cssText roundtrip with input \"" + text + "\"");
log(text + " --> " + pass1Text + " --> " + pass2Text);
}
let data = [
"*{}",
"* *{}",
"* > *{}",
"*>*{}",
"* * *{}",
"* > * > *{}",
"* + *{}",
"* ~ *{}",
["*|*{}", "*{}"],
["*|* > *{}", "* > *{}"],
"#tag{}",
"tag{}",
"@namespace tag url(\"fakeURL\"); tag|*{}",
"@namespace tag url(\"fakeURL\"); tag|* + *{}",
];
for (let i = 0; i < data.length; i++) {
testData(data[i]);
}
</script>
</body>
</html>