gecko-dev/dom/bindings/test/test_forOf.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

88 lines
2.6 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=725907
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 725907</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=725907">Mozilla Bug 725907</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="basket">
<span id="egg0"></span>
<span id="egg1"><span id="duckling1"></span></span>
<span id="egg2"></span>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 725907 **/
function runTestsForDocument(document, msgSuffix) {
function is(a, b, msg) { SimpleTest.is(a, b, msg + msgSuffix); }
var basket = document.getElementById("basket");
var egg3 = document.createElement("span");
egg3.id = "egg3";
var log = "";
for (let x of basket.childNodes) {
if (x.nodeType != x.TEXT_NODE)
log += x.id + ";";
}
is(log, "egg0;egg1;egg2;", "'for (x of div.childNodes)' should iterate over child nodes");
log = "";
for (let x of basket.childNodes) {
if (x.nodeType != x.TEXT_NODE) {
log += x.id + ";";
if (x.id == "egg1")
basket.appendChild(egg3);
}
}
is(log, "egg0;egg1;egg2;egg3;", "'for (x of div.childNodes)' should see elements added during iteration");
log = "";
basket.appendChild(document.createTextNode("some text"));
for (let x of basket.children)
log += x.id + ";";
is(log, "egg0;egg1;egg2;egg3;", "'for (x of div.children)' should iterate over child elements");
var count = 0;
// eslint-disable-next-line no-unused-vars
for (let x of document.getElementsByClassName("hazardous-materials"))
count++;
is(count, 0, "'for (x of emptyNodeList)' loop should run zero times");
log = "";
for (let x of document.querySelectorAll("span"))
log += x.id + ";";
is(log, "egg0;egg1;duckling1;egg2;egg3;", "for-of loop should work with a querySelectorAll() NodeList");
}
/* All the tests run twice. First, in this document, so without any wrappers. */
runTestsForDocument(document, "");
/* And once using the document of an iframe, so working with cross-compartment wrappers. */
SimpleTest.waitForExplicitFinish();
function iframeLoaded(iframe) {
runTestsForDocument(iframe.contentWindow.document, " (in iframe)");
SimpleTest.finish();
}
</script>
<iframe src="forOf_iframe.html" onload="iframeLoaded(this)"></iframe>
</pre>
</body>
</html>