Bug 1561085 - Enable some ESLint rules for the rest of dom/base/test/**. r=smaug

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2019-06-25 07:12:51 +00:00
parent 6e6e460616
commit e11ca34a3a
34 changed files with 216 additions and 199 deletions

View file

@ -13,8 +13,6 @@ obj*/**
# dom/ exclusions which should be removed (aka ESLint enabled) # dom/ exclusions which should be removed (aka ESLint enabled)
dom/base/*.* dom/base/*.*
dom/base/test/*.*
dom/base/test/jsmodules/**
dom/media/test/** dom/media/test/**
!dom/media/test/marionette/yttest/*.js !dom/media/test/marionette/yttest/*.js
dom/promise/** dom/promise/**
@ -169,6 +167,7 @@ dom/svg/test/test_nonAnimStrings.xhtml
dom/svg/test/test_SVG_namespace_ids.html dom/svg/test/test_SVG_namespace_ids.html
# Strange encodings # Strange encodings
dom/base/test/file_bug687859-16.js
dom/encoding/test/test_utf16_files.html dom/encoding/test/test_utf16_files.html
dom/encoding/test/file_utf16_be_bom.js dom/encoding/test/file_utf16_be_bom.js
dom/encoding/test/file_utf16_le_bom.js dom/encoding/test/file_utf16_le_bom.js
@ -179,6 +178,12 @@ dom/html/test/test_bug677658.html
# Intentional broken files # Intentional broken files
dom/base/test/file_js_cache_syntax_error.js dom/base/test/file_js_cache_syntax_error.js
dom/base/test/jsmodules/test_syntaxError.html
dom/base/test/jsmodules/test_syntaxErrorAsync.html
dom/base/test/jsmodules/module_badSyntax.js
dom/base/test/jsmodules/test_syntaxErrorInline.html
dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html
dom/base/test/test_bug687859.html
dom/media/tests/mochitest/identity/idp-bad.js dom/media/tests/mochitest/identity/idp-bad.js
dom/serviceworkers/test/file_js_cache_syntax_error.js dom/serviceworkers/test/file_js_cache_syntax_error.js
dom/serviceworkers/test/parse_error_worker.js dom/serviceworkers/test/parse_error_worker.js

View file

@ -62,10 +62,12 @@ add_task(async function(){
// Navigate to a content page from the child side. // Navigate to a content page from the child side.
await BrowserTestUtils.switchTab(gBrowser, tab1); await BrowserTestUtils.switchTab(gBrowser, tab1);
/* eslint-disable no-shadow */
await ContentTask.spawn(tab1.linkedBrowser, null, async function() { await ContentTask.spawn(tab1.linkedBrowser, null, async function() {
const TEST_URL = "http://www.example.com/browser/dom/base/test/dummy.html"; const TEST_URL = "http://www.example.com/browser/dom/base/test/dummy.html";
content.location.href = TEST_URL; content.location.href = TEST_URL;
}); });
/* eslint-enable no-shadow */
await BrowserTestUtils.browserLoaded(tab1.linkedBrowser, false, TEST_URL); await BrowserTestUtils.browserLoaded(tab1.linkedBrowser, false, TEST_URL);
is(ppmm.childCount, originalChildCount + 2, is(ppmm.childCount, originalChildCount + 2,
"Navigating away from the preloaded browser (child side) should create a new content process.") "Navigating away from the preloaded browser (child side) should create a new content process.")
@ -106,4 +108,3 @@ add_task(async function preloaded_state_attribute() {
BrowserTestUtils.removeTab(gBrowser.selectedTab); BrowserTestUtils.removeTab(gBrowser.selectedTab);
NewTabPagePreloading.removePreloadedBrowser(window); NewTabPagePreloading.removePreloadedBrowser(window);
}); });

View file

@ -20,7 +20,7 @@ async function spawnNewAndTest(recur, pids) {
}; };
Services.obs.addObserver(observer, CONTENT_CREATED); Services.obs.addObserver(observer, CONTENT_CREATED);
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function(browser) { await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function() {
// If this new tab caused us to create a new process, the ok(false) // If this new tab caused us to create a new process, the ok(false)
// should have already happened. Therefore, if we get here, we've // should have already happened. Therefore, if we get here, we've
// passed. Simply remove the observer. // passed. Simply remove the observer.

View file

@ -22,6 +22,7 @@ async function runTest(input, url) {
is(data.inputStream.available(), input.length, "The length of the inputStream matches: " + input.length); is(data.inputStream.available(), input.length, "The length of the inputStream matches: " + input.length);
/* eslint-disable no-shadow */
let dataBack = await ContentTask.spawn(browser, data, function(data) { let dataBack = await ContentTask.spawn(browser, data, function(data) {
let dataBack = { let dataBack = {
inputStream: data.inputStream, inputStream: data.inputStream,
@ -34,6 +35,8 @@ async function runTest(input, url) {
return dataBack; return dataBack;
}); });
/* eslint-enable no-shadow */
ok(dataBack.check, "The inputStream is a nsIInputStream also on content."); ok(dataBack.check, "The inputStream is a nsIInputStream also on content.");
ok(data.inputStream instanceof Ci.nsIInputStream, "The original object was an inputStream"); ok(data.inputStream instanceof Ci.nsIInputStream, "The original object was an inputStream");

View file

@ -50,6 +50,7 @@ const receive = (topic, p, syncCallback) => {
} }
} }
}; };
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
const id = setTimeout(timeout, 90000); const id = setTimeout(timeout, 90000);
addObserver(observer, topic, false); addObserver(observer, topic, false);
queue.push(topic, resolve); queue.push(topic, resolve);
@ -59,6 +60,7 @@ receive.queue = [];
const openTab = uri => gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, uri); const openTab = uri => gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, uri);
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const isData = document => document.URL.startsWith("data:"); const isData = document => document.URL.startsWith("data:");

View file

@ -226,6 +226,8 @@
.bar. { background: red; color: yellow; } .bar. { background: red; color: yellow; }
</span> </span>
<script><![CDATA[ <script><![CDATA[
/* eslint-disable no-shadow */
window.onload = function() { window.onload = function() {
doTest(); doTest();
} }
@ -242,13 +244,13 @@
var cache = {}; var cache = {};
var css = document.getElementById("test").firstChild.nodeValue.split("\n"); var css = document.getElementById("test").firstChild.nodeValue.split("\n");
for ( var i = 0; i < css.length; i++ ) { for ( let i = 0; i < css.length; i++ ) {
css[i] = css[i].replace(/\/\*.*?\*\//g, "") css[i] = css[i].replace(/\/\*.*?\*\//g, "")
.replace(/^\s*|\s*$/g, "").split(/\s*{/); .replace(/^\s*|\s*$/g, "").split(/\s*{/);
} }
var ecss = document.getElementById("error").firstChild.nodeValue.split("\n"); var ecss = document.getElementById("error").firstChild.nodeValue.split("\n");
for ( var i = 0; i < ecss.length; i++ ) { for ( let i = 0; i < ecss.length; i++ ) {
ecss[i] = ecss[i].replace(/\/\*.*?\*\//g, "") ecss[i] = ecss[i].replace(/\/\*.*?\*\//g, "")
.replace(/^\s*|\s*$/g, "").split(/\s*{/); .replace(/^\s*|\s*$/g, "").split(/\s*{/);
} }
@ -320,7 +322,7 @@
li.appendChild( document.createTextNode( ": " + passed + " passed, " + (tests - passed) + " failed" ) ); li.appendChild( document.createTextNode( ": " + passed + " passed, " + (tests - passed) + " failed" ) );
r.appendChild( li ); r.appendChild( li );
for ( var i = 0; i < results.length; i++ ) { for ( let i = 0; i < results.length; i++ ) {
var li = document.createElement("li"); var li = document.createElement("li");
var span = document.createElement("span"); var span = document.createElement("span");
span.style.color = (results[i][0] === "FAIL" ? "red" : "green"); span.style.color = (results[i][0] === "FAIL" ? "red" : "green");
@ -404,7 +406,7 @@
} catch(e){ pass = true; } } catch(e){ pass = true; }
assert( pass, type + ".querySelector no value" ); assert( pass, type + ".querySelector no value" );
for ( var i = 0; i < css.length; i++ ) { for ( let i = 0; i < css.length; i++ ) {
var test = css[i]; var test = css[i];
if ( test.length == 2 ) { if ( test.length == 2 ) {
var query = test[0], color = test[1].match(/: ([^\s;]+)/)[1]; var query = test[0], color = test[1].match(/: ([^\s;]+)/)[1];

View file

@ -1 +1 @@
<script>function f() { history.length; } window.onload = function() { var f = window.f; document.open(); document.close(); parent.continueTest(f); }</script> <script>function f() { history.length; } window.onload = function() { var func = window.f; document.open(); document.close(); parent.continueTest(func); }</script>

View file

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"parserOptions": {
"sourceType": "module",
}
};

View file

@ -1,3 +1,6 @@
// This helper expects these globals to be defined.
/* global PARAMS, SJS, testCases */
/* /*
* common functionality for iframe, anchor, and area referrer attribute tests * common functionality for iframe, anchor, and area referrer attribute tests
*/ */
@ -80,22 +83,22 @@ var tests = (function*() {
} }
var actions = testCases[j].ACTION; var actions = testCases[j].ACTION;
var tests = testCases[j].TESTS; var subTests = testCases[j].TESTS;
for (var k = 0; k < actions.length; k++) { for (var k = 0; k < actions.length; k++) {
var actionString = actions[k]; var actionString = actions[k];
for (var i = 0; i < tests.length; i++) { for (var i = 0; i < subTests.length; i++) {
yield resetState(); yield resetState();
var searchParams = new URLSearchParams(); var searchParams = new URLSearchParams();
searchParams.append("ACTION", actionString); searchParams.append("ACTION", actionString);
searchParams.append("NAME", tests[i].NAME); searchParams.append("NAME", subTests[i].NAME);
for (var l of PARAMS) { for (var l of PARAMS) {
if (tests[i][l]) { if (subTests[i][l]) {
searchParams.append(l, tests[i][l]); searchParams.append(l, subTests[i][l]);
} }
} }
var schemeFrom = tests[i].SCHEME_FROM || "http"; var schemeFrom = subTests[i].SCHEME_FROM || "http";
yield iframe.src = schemeFrom + SJS + searchParams.toString(); yield iframe.src = schemeFrom + SJS + searchParams.toString();
yield checkIndividualResults(tests[i].DESC, tests[i].RESULT, tests[i].NAME); yield checkIndividualResults(subTests[i].DESC, subTests[i].RESULT, subTests[i].NAME);
}; };
}; };
}; };

View file

@ -110,17 +110,17 @@
compare_arrays(expect_f, found, 'filtered backward'); compare_arrays(expect_f, found, 'filtered backward');
function checkBadFilter(method, n) { function checkBadFilter(method, n) {
var iterator = var iter =
document.createNodeIterator(document, NodeFilter.SHOW_ALL, document.createNodeIterator(document, NodeFilter.SHOW_ALL,
function() { function() {
if (n < 0) if (n < 0)
iterator.detach(); iter.detach();
return NodeFilter.FILTER_ACCEPT; return NodeFilter.FILTER_ACCEPT;
}); });
while (--n >= 0) while (--n >= 0)
iterator.nextNode(); iter.nextNode();
try { try {
iterator[method](); iter[method]();
ok(true, "Able to call " + method + " on a NodeIterator after calling no-op detach()"); ok(true, "Able to call " + method + " on a NodeIterator after calling no-op detach()");
} catch (x) { ok(false, x) } } catch (x) { ok(false, x) }
} }
@ -131,7 +131,7 @@
// Implementing the scenario outlined in // Implementing the scenario outlined in
// http://bugzilla.mozilla.org/show_bug.cgi?id=552110#c4 // http://bugzilla.mozilla.org/show_bug.cgi?id=552110#c4
var iterator = (function(filter) { var iter = (function(filt) {
var grandparent = document.createElement("div"), var grandparent = document.createElement("div"),
parent = document.createElement("span"); parent = document.createElement("span");
@ -141,12 +141,12 @@
return document.createNodeIterator(grandparent, return document.createNodeIterator(grandparent,
NodeFilter.SHOW_ALL, NodeFilter.SHOW_ALL,
filter); filt);
})(function filter(n) { })(function(n) {
if (n.nodeName != "img") if (n.nodeName != "img")
return NodeFilter.FILTER_ACCEPT; return NodeFilter.FILTER_ACCEPT;
iterator.detach(); iter.detach();
n.parentNode.remove(); n.parentNode.remove();
// Drop any node references passed into this function. // Drop any node references passed into this function.
@ -162,13 +162,13 @@
return NodeFilter.FILTER_SKIP; return NodeFilter.FILTER_SKIP;
}); });
is(iterator.nextNode().nodeName, "div", is(iter.nextNode().nodeName, "div",
"iterator.nextNode() returned the wrong node"); "iter.nextNode() returned the wrong node");
is(iterator.nextNode().nodeName, "span", is(iter.nextNode().nodeName, "span",
"iterator.nextNode() returned the wrong node"); "iter.nextNode() returned the wrong node");
try { try {
var p = iterator.nextNode(); var p = iter.nextNode();
ok(false, "iterator.nextNode() should have thrown, but instead it returned <" + p.nodeName + ">"); ok(false, "iter.nextNode() should have thrown, but instead it returned <" + p.nodeName + ">");
} catch (x) { ok(true, x) } } catch (x) { ok(true, x) }
})(); })();

View file

@ -7,7 +7,6 @@
var is = window.parent.is; var is = window.parent.is;
var host; var host;
var sr;
var embed; var embed;
var object; var object;
var iframe; var iframe;
@ -34,7 +33,7 @@
function test() { function test() {
host = document.getElementById("host"); host = document.getElementById("host");
sr = host.attachShadow({mode: 'open'}); let sr = host.attachShadow({mode: 'open'});
embed = createResource(sr, "embed"); embed = createResource(sr, "embed");
object = createResource(sr, "object"); object = createResource(sr, "object");
iframe = createResource(sr, "iframe"); iframe = createResource(sr, "iframe");

View file

@ -43,7 +43,7 @@ function getTargetOrigin(i) {
} }
// Create the frames, and tell them which subframes to load. // Create the frames, and tell them which subframes to load.
for (var i = 0; i < numTests; i++) { for (let i = 0; i < numTests; i++) {
var frame = document.createElement("iframe"); var frame = document.createElement("iframe");
frame.src = getFrameOrigin(i) + frame.src = getFrameOrigin(i) +
"/tests/dom/base/test/file_bug1091883_frame.html#" + "/tests/dom/base/test/file_bug1091883_frame.html#" +
@ -53,7 +53,7 @@ for (var i = 0; i < numTests; i++) {
// Navigate all subframes to the target. // Navigate all subframes to the target.
window.onload = function() { window.onload = function() {
for (var i = 0; i < numTests; i++) { for (let i = 0; i < numTests; i++) {
frames[i].frames[0].location = getTargetOrigin(i) + frames[i].frames[0].location = getTargetOrigin(i) +
"/tests/dom/base/test/file_bug1091883_target.html#" + i; "/tests/dom/base/test/file_bug1091883_target.html#" + i;
} }

View file

@ -58,14 +58,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
doTest5, doTest5_b, doTest5_c, doTest5_e, doTest6, doTest7 doTest5, doTest5_b, doTest5_c, doTest5_e, doTest6, doTest7
]; ];
for (var test_id=0; test_id < all_tests.length; ++test_id) { for (let test_id=0; test_id < all_tests.length; ++test_id) {
gTestsHaveFinished[test_id] = false; gTestsHaveFinished[test_id] = false;
var fn = all_tests[test_id]; var fn = all_tests[test_id];
fn(test_id); fn(test_id);
} }
setTimeout(function() { setTimeout(function() {
for (var test_id=0; test_id < all_tests.length; ++test_id) { for (let test_id=0; test_id < all_tests.length; ++test_id) {
if (!gTestsHaveFinished[test_id]) { if (!gTestsHaveFinished[test_id]) {
ok(false, "Test " + test_id + " took too long"); ok(false, "Test " + test_id + " took too long");
setTestHasFinished(test_id); setTestHasFinished(test_id);
@ -663,4 +663,3 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
<span id=waitSpan>Wait please...</span> <span id=waitSpan>Wait please...</span>
</body> </body>
</html> </html>

View file

@ -19,6 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=409380
/** Test for Bug 409380 **/ /** Test for Bug 409380 **/
// eslint-disable-next-line complexity
function runRangeTest() function runRangeTest()
{ {
// Bug 336381 // Bug 336381
@ -375,4 +376,3 @@ addLoadEvent(runRangeTest);
<div id="connectedDiv">zz</div> <div id="connectedDiv">zz</div>
</body> </body>
</html> </html>

View file

@ -37,7 +37,7 @@ var docSources = [
"iframe7_bug431701.xml", "iframe7_bug431701.xml",
]; ];
for (var i = 0; i < docSources.length; ++i) { for (let i = 0; i < docSources.length; ++i) {
document.getElementsByTagName("iframe")[i].src = docSources[i]; document.getElementsByTagName("iframe")[i].src = docSources[i];
} }
@ -94,7 +94,7 @@ function startTest() {
// sanity check // sanity check
isnot("", null, "Shouldn't be equal!"); isnot("", null, "Shouldn't be equal!");
for (var i = 0; i < tests.length; ++i) { for (let i = 0; i < tests.length; ++i) {
doTest(i); doTest(i);
} }
@ -117,4 +117,3 @@ function startTest() {
</pre> </pre>
</body> </body>
</html> </html>

View file

@ -19,7 +19,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=435425
/** Test for Bug 435425 **/ /** Test for Bug 435425 **/
var xhr = null;
var upload = null; var upload = null;
var currentEvents = null; var currentEvents = null;
var expectedResponseText = null; var expectedResponseText = null;
@ -102,7 +101,7 @@ function openXHR(xhr, method, url, privileged) {
} }
function start(obj) { function start(obj) {
xhr = new XMLHttpRequest(); let xhr = new XMLHttpRequest();
upload = xhr.upload; upload = xhr.upload;
currentEvents = obj.expectedEvents; currentEvents = obj.expectedEvents;
expectedResponseText = obj.withUpload; expectedResponseText = obj.withUpload;
@ -429,4 +428,3 @@ addLoadEvent(runTest);
</pre> </pre>
</body> </body>
</html> </html>

View file

@ -60,9 +60,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=444546
evt.target.log.textContent = diff + "ms"; evt.target.log.textContent = diff + "ms";
evt.target.prevTime = time; evt.target.prevTime = time;
if (evt.lengthComputable) { if (evt.lengthComputable) {
var loaded = (evt.loaded / evt.total); var fractionLoaded = (evt.loaded / evt.total);
if (loaded < 1) { if (fractionLoaded < 1) {
evt.target.log.style.width = (loaded * 400) + "px"; evt.target.log.style.width = (fractionLoaded * 400) + "px";
} }
} }
} }

View file

@ -26,7 +26,7 @@ function testCancelInPhase4() {
// First request - should be loaded from server // First request - should be loaded from server
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function(e) { xhr.addEventListener("readystatechange", function() {
if (xhr.readyState < xhr.DONE) return; if (xhr.readyState < xhr.DONE) return;
is(xhr.readyState, xhr.DONE, "wrong readyState"); is(xhr.readyState, xhr.DONE, "wrong readyState");
xhr.abort(); xhr.abort();

View file

@ -26,7 +26,7 @@ function setAndTestProperty(prop, color) {
* Attempt to set legacy color properties before BODY exists, and verify that such * Attempt to set legacy color properties before BODY exists, and verify that such
* attempts are ignored. * attempts are ignored.
*/ */
for (var i = 0; i < legacyProps.length; i++) { for (let i = 0; i < legacyProps.length; i++) {
initialValues[i] = setAndTestProperty(legacyProps[i], testColors[i]); initialValues[i] = setAndTestProperty(legacyProps[i], testColors[i]);
} }
@ -35,13 +35,13 @@ for (var i = 0; i < legacyProps.length; i++) {
*/ */
addLoadEvent( function() { addLoadEvent( function() {
// Verify that the legacy color properties still have their original values. // Verify that the legacy color properties still have their original values.
for (var i = 0; i < legacyProps.length; i++) { for (let i = 0; i < legacyProps.length; i++) {
is(document[legacyProps[i]], initialValues[i], "document[" + legacyProps[i] + "] altered after body load"); is(document[legacyProps[i]], initialValues[i], "document[" + legacyProps[i] + "] altered after body load");
} }
// Verify that legacy color properties applied before BODY are really ignored when rendering. // Verify that legacy color properties applied before BODY are really ignored when rendering.
// Save current computed style colors for later use. // Save current computed style colors for later use.
for (i = 0; i < idPropList.length; i++) { for (let i = 0; i < idPropList.length; i++) {
var style = window.getComputedStyle(document.getElementById(idPropList[i].id)); var style = window.getComputedStyle(document.getElementById(idPropList[i].id));
var color = style.getPropertyValue(idPropList[i].prop); var color = style.getPropertyValue(idPropList[i].prop);
idPropList[i].initialComputedColor = color; idPropList[i].initialComputedColor = color;
@ -52,7 +52,7 @@ addLoadEvent( function() {
// Verify that setting legacy color props to undefined after BODY loads will cause them // Verify that setting legacy color props to undefined after BODY loads will cause them
// to be read as the string "undefined". // to be read as the string "undefined".
for (var i = 0; i < legacyProps.length; i++) { for (let i = 0; i < legacyProps.length; i++) {
document[legacyProps[i]] = undefined; document[legacyProps[i]] = undefined;
is(document[legacyProps[i]], "undefined", is(document[legacyProps[i]], "undefined",
"Unexpected value of " + legacyProps[i] + " after setting to undefined"); "Unexpected value of " + legacyProps[i] + " after setting to undefined");
@ -60,7 +60,7 @@ addLoadEvent( function() {
// Verify that setting legacy color props to undefined led to result // Verify that setting legacy color props to undefined led to result
// of parsing undefined as a color. // of parsing undefined as a color.
for (i = 0; i < idPropList.length; i++) { for (let i = 0; i < idPropList.length; i++) {
var style = window.getComputedStyle(document.getElementById(idPropList[i].id)); var style = window.getComputedStyle(document.getElementById(idPropList[i].id));
var color = style.getPropertyValue(idPropList[i].prop); var color = style.getPropertyValue(idPropList[i].prop);
is(color, "rgb(0, 239, 14)", is(color, "rgb(0, 239, 14)",

View file

@ -23,10 +23,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=682463
return document.createTextNode(s); return document.createTextNode(s);
} }
function div(l,r) { function div(l,r) {
var div = document.createElement("DIV"); var d = document.createElement("DIV");
if (l) div.appendChild(l); if (l) d.appendChild(l);
if (r) div.appendChild(r); if (r) d.appendChild(r);
return div; return d;
} }
function createRange(sn,so,en,eo) { function createRange(sn,so,en,eo) {
var r = document.createRange(); var r = document.createRange();

View file

@ -53,18 +53,18 @@ SimpleTest.requestLongerTimeout(4);
* This is the main test routine -- serialized by use of a generator. * This is the main test routine -- serialized by use of a generator.
* It performs all tests in sequence using four iframes. * It performs all tests in sequence using four iframes.
*/ */
function startTests(testName, testIframeUrls) { function startTests(testName, iframeUrls) {
testsGenerator[testName] = (function*() { testsGenerator[testName] = (function*() {
var testframe = document.getElementById(testName); var testframe = document.getElementById(testName);
testframe.onload = function() { testframe.onload = function() {
advance(testName); advance(testName);
} }
// load the test frame from testIframeUrls[url] // load the test frame from iframeUrls[url]
// it will call back into this function via postMessage when it finishes // it will call back into this function via postMessage when it finishes
// loading and continue beyond the yield. // loading and continue beyond the yield.
for(url in testIframeUrls) { for(url in iframeUrls) {
yield testframe.src = testIframeUrls[url]; yield testframe.src = iframeUrls[url];
// run test and check result for loaded test URL // run test and check result for loaded test URL
yield checkExpectedGlobalResults(testName); yield checkExpectedGlobalResults(testName);
} }

View file

@ -53,18 +53,18 @@ SimpleTest.requestLongerTimeout(4);
* This is the main test routine -- serialized by use of a generator. * This is the main test routine -- serialized by use of a generator.
* It performs all tests in sequence using four iframes. * It performs all tests in sequence using four iframes.
*/ */
function startTests(testName, testIframeUrls) { function startTests(testName, iframeUrls) {
testsGenerator[testName] = (function*() { testsGenerator[testName] = (function*() {
var testframe = document.getElementById(testName); var testframe = document.getElementById(testName);
testframe.onload = function() { testframe.onload = function() {
advance(testName); advance(testName);
} }
// load the test frame from testIframeUrls[url] // load the test frame from iframeUrls[url]
// it will call back into this function via postMessage when it finishes // it will call back into this function via postMessage when it finishes
// loading and continue beyond the yield. // loading and continue beyond the yield.
for(url in testIframeUrls) { for(url in iframeUrls) {
yield testframe.src = testIframeUrls[url]; yield testframe.src = iframeUrls[url];
// run test and check result for loaded test URL // run test and check result for loaded test URL
yield checkExpectedGlobalResults(testName); yield checkExpectedGlobalResults(testName);
} }

View file

@ -25,8 +25,8 @@ var xhr = new XMLHttpRequest();
xhr.open("GET", url, true); xhr.open("GET", url, true);
xhr.responseType = "blob"; xhr.responseType = "blob";
function checkHeaders(xhr) { function checkHeaders(xhrInner) {
var headers = xhr.getAllResponseHeaders(); var headers = xhrInner.getAllResponseHeaders();
dump(headers + "\n"); dump(headers + "\n");
var p = headers.split("\n"); var p = headers.split("\n");
@ -44,9 +44,9 @@ function checkHeaders(xhr) {
ok(contentLength == true, "Content-length is part of the headers!"); ok(contentLength == true, "Content-length is part of the headers!");
ok(contentType == true, "Content-type is part of the headers!"); ok(contentType == true, "Content-type is part of the headers!");
var ct = xhr.getResponseHeader('content-type'); var ct = xhrInner.getResponseHeader('content-type');
ok(ct.length > 0, 'Get Response Header - content type: ' + ct); ok(ct.length > 0, 'Get Response Header - content type: ' + ct);
var cl = xhr.getResponseHeader('content-length'); var cl = xhrInner.getResponseHeader('content-length');
ok(cl.length > 0, 'Get Response Header - content length: ' + cl); ok(cl.length > 0, 'Get Response Header - content length: ' + cl);
} }

View file

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=913761
transportChannel.port1.onmessage = function (event) { transportChannel.port1.onmessage = function (event) {
ok(true, 'Port Returned.'); ok(true, 'Port Returned.');
var portToService = event.data.port; var portToService = event.data.port;
portToService.onmessage = function (event) { portToService.onmessage = function () {
ok(true, "message received"); ok(true, "message received");
SimpleTest.finish(); SimpleTest.finish();
}; };

View file

@ -76,11 +76,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=922681
testInnerHTML(c, "<body>", ""); testInnerHTML(c, "<body>", "");
function testTableBody(tag) { function testTableBody(tag) {
var c = document.createElement(tag); var e = document.createElement(tag);
testInnerHTML(c, "abc", "abc"); testInnerHTML(e, "abc", "abc");
testInnerHTML(c, "<td>", "<tr><td></td></tr>"); testInnerHTML(e, "<td>", "<tr><td></td></tr>");
testInnerHTML(c, "</body>", ""); testInnerHTML(e, "</body>", "");
testInnerHTML(c, "<input>", "<input>"); testInnerHTML(e, "<input>", "<input>");
} }
testTableBody("thead"); testTableBody("thead");
testTableBody("tbody"); testTableBody("tbody");

View file

@ -52,23 +52,23 @@ function testSetFocus(aEventType, aCallback)
var movingFocus = false; var movingFocus = false;
button.addEventListener(aEventType, button.addEventListener(aEventType,
function (aEvent) { function (event) {
movingFocus = true; movingFocus = true;
input.focus(); input.focus();
aEvent.preventDefault(); event.preventDefault();
button.removeEventListener(aEventType, arguments.callee, true); button.removeEventListener(aEventType, arguments.callee, true);
}, true); }, true);
synthesizeMouseAtCenter(button, {}); synthesizeMouseAtCenter(button, {});
window.addEventListener("message", function (aEvent) { window.addEventListener("message", function (event) {
if (movingFocus) { if (movingFocus) {
is(aEvent.data, "input-value: blur", is(event.data, "input-value: blur",
description + "<input> in the iframe should get blur"); description + "<input> in the iframe should get blur");
is(input.value, "focus", is(input.value, "focus",
description + "<input> in the parent should get focus"); description + "<input> in the parent should get focus");
} else { } else {
is(aEvent.data, "input-value: focus", is(event.data, "input-value: focus",
description + "<input> in the iframe should keep having focus"); description + "<input> in the iframe should keep having focus");
} }

View file

@ -29,6 +29,7 @@ limitations under the License.
<p id="display"></p> <p id="display"></p>
<pre id="test"> <pre id="test">
<script type="application/javascript"> <script type="application/javascript">
/* eslint "no-shadow": ["error", {"allow": ["done", "next"]}] */
var tests = []; var tests = [];
var curDescribeMsg = ''; var curDescribeMsg = '';
var curItMsg = ''; var curItMsg = '';
@ -149,18 +150,18 @@ limitations under the License.
var sinon = { var sinon = {
spy: function () { spy: function () {
var callbacks = []; var cbs = [];
var fn = function () { var fn = function () {
fn.callCount++; fn.callCount++;
fn.lastCall = { args: arguments }; fn.lastCall = { args: arguments };
if (callbacks.length) { if (cbs.length) {
callbacks.shift()(); cbs.shift()();
} }
}; };
fn.callCount = 0; fn.callCount = 0;
fn.lastCall = { args: [] }; fn.lastCall = { args: [] };
fn.waitForNotification = (fn) => { fn.waitForNotification = (fn1) => {
callbacks.push(fn); cbs.push(fn1);
}; };
return fn; return fn;
} }

View file

@ -21,24 +21,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=912456
function receiveMessage(evt) { function receiveMessage(evt) {
ok(evt.data.port, "Port has been received!"); ok(evt.data.port, "Port has been received!");
var a = new MessageChannel(); var a1 = new MessageChannel();
ok(a, "MessageChannel created"); ok(a1, "MessageChannel created");
try { try {
evt.data.port.postMessage({port: a.port2}); evt.data.port.postMessage({port: a1.port2});
ok(false, "PostMessage should throw! - no transfered port"); ok(false, "PostMessage should throw! - no transfered port");
} catch(e) { } catch(e) {
ok(true, "PostMessage should throw! - no transfered port"); ok(true, "PostMessage should throw! - no transfered port");
} }
try { try {
evt.data.port.postMessage({port: a.port2}, [a.port2, a.port2]); evt.data.port.postMessage({port: a1.port2}, [a1.port2, a1.port2]);
ok(false, "PostMessage should throw - no duplicate!"); ok(false, "PostMessage should throw - no duplicate!");
} catch(e) { } catch(e) {
ok(true, "PostMessage should throw - no duplicate!"); ok(true, "PostMessage should throw - no duplicate!");
} }
evt.data.port.postMessage({port: a.port2}, [a.port2]); evt.data.port.postMessage({port: a1.port2}, [a1.port2]);
} }
a.port1.onmessage = function(evt) { a.port1.onmessage = function(evt) {
@ -74,10 +74,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=912456
ok(evt.ports, "Port is received"); ok(evt.ports, "Port is received");
is(evt.ports.length, 1, "Ports.length is 1"); is(evt.ports.length, 1, "Ports.length is 1");
var a = new MessageChannel(); var a1 = new MessageChannel();
ok(a, "MessageChannel created"); ok(a1, "MessageChannel created");
evt.ports[0].postMessage(42, [a.port2]); evt.ports[0].postMessage(42, [a1.port2]);
} }
a.port1.onmessage = function(evt) { a.port1.onmessage = function(evt) {
@ -112,4 +112,3 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=912456
</script> </script>
</body> </body>
</html> </html>

View file

@ -75,7 +75,7 @@
info("Third iframe loaded"); info("Third iframe loaded");
let doc3 = SpecialPowers.wrap(iframe3).contentDocument; let doc3 = SpecialPowers.wrap(iframe3).contentDocument;
let target = doc3.getElementById("target"); let target = doc3.getElementById("target");
target.addEventListener("test-event", function onEvent(e) { target.addEventListener("test-event", function onEvent() {
is(messageIndex, 2, is(messageIndex, 2,
"target should be the last one to receive the test event"); "target should be the last one to receive the test event");
messageIndex++; messageIndex++;

View file

@ -367,10 +367,10 @@ function testNestedMutations() {
is(records[0].type, "characterData", "Should have got characterData"); is(records[0].type, "characterData", "Should have got characterData");
observer.disconnect(); observer.disconnect();
m = null; m = null;
m3 = new M(function(records, observer) { m3 = new M(function(recordsInner, observerInnder) {
ok(m2WasCalled, "m2 should have been called before m3!"); ok(m2WasCalled, "m2 should have been called before m3!");
is(records[0].type, "characterData", "Should have got characterData"); is(recordsInner[0].type, "characterData", "Should have got characterData");
observer.disconnect(); observerInnder.disconnect();
then(testAdoptNode); then(testAdoptNode);
m3 = null; m3 = null;
}); });
@ -570,7 +570,7 @@ function testTakeRecords() {
} }
function testExpandos() { function testExpandos() {
var m2 = new M(function(records, observer) { m2 = new M(function(records, observer) {
is(observer.expandoProperty, true); is(observer.expandoProperty, true);
observer.disconnect(); observer.disconnect();
then(testOutsideShadowDOM); then(testOutsideShadowDOM);
@ -596,7 +596,7 @@ function testOutsideShadowDOM() {
then(testMarquee); then(testMarquee);
return; return;
} }
var m = new M(function(records, observer) { m = new M(function(records, observer) {
is(records.length, 1); is(records.length, 1);
is(records[0].type, "attributes", "Should have got attributes"); is(records[0].type, "attributes", "Should have got attributes");
observer.disconnect(); observer.disconnect();
@ -617,7 +617,7 @@ function testOutsideShadowDOM() {
} }
function testMarquee() { function testMarquee() {
var m = new M(function(records, observer) { m = new M(function(records, observer) {
is(records.length, 1); is(records.length, 1);
is(records[0].type, "attributes"); is(records[0].type, "attributes");
is(records[0].attributeName, "ok"); is(records[0].attributeName, "ok");
@ -724,7 +724,7 @@ function testStyleRemoveProperty2() {
function testAttributeRecordMerging1() { function testAttributeRecordMerging1() {
ok(true, "testAttributeRecordMerging1"); ok(true, "testAttributeRecordMerging1");
var m = new M(function(records, observer) { m = new M(function(records, observer) {
is(records.length, 2); is(records.length, 2);
is(records[0].type, "attributes"); is(records[0].type, "attributes");
is(records[0].target, div); is(records[0].target, div);
@ -757,7 +757,7 @@ function testAttributeRecordMerging1() {
function testAttributeRecordMerging2() { function testAttributeRecordMerging2() {
ok(true, "testAttributeRecordMerging2"); ok(true, "testAttributeRecordMerging2");
var m = new M(function(records, observer) { m = new M(function(records, observer) {
is(records.length, 2); is(records.length, 2);
is(records[0].type, "attributes"); is(records[0].type, "attributes");
is(records[0].target, div); is(records[0].target, div);
@ -794,7 +794,7 @@ function testAttributeRecordMerging2() {
function testAttributeRecordMerging3() { function testAttributeRecordMerging3() {
ok(true, "testAttributeRecordMerging3"); ok(true, "testAttributeRecordMerging3");
var m = new M(function(records, observer) { m = new M(function(records, observer) {
is(records.length, 4); is(records.length, 4);
is(records[0].type, "attributes"); is(records[0].type, "attributes");
is(records[0].target, div); is(records[0].target, div);
@ -845,7 +845,7 @@ function testAttributeRecordMerging3() {
function testAttributeRecordMerging4() { function testAttributeRecordMerging4() {
ok(true, "testAttributeRecordMerging4"); ok(true, "testAttributeRecordMerging4");
var m = new M(function(records, observer) { m = new M(function(records, observer) {
}); });
div.setAttribute("foo", "initial"); div.setAttribute("foo", "initial");

View file

@ -119,8 +119,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=889335
function* testEvents() { function* testEvents() {
for (var i = 0; i < testValues.length; ++i) { for (var i = 0; i < testValues.length; ++i) {
var data = testValues[i]; var data = testValues[i];
setTimeout(function(data) { setTimeout(function(d) {
SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', data.accept_languages]]}); SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', d.accept_languages]]});
}, 0, data); }, 0, data);
expectedLanguageChanges++; expectedLanguageChanges++;
yield undefined; yield undefined;

View file

@ -403,7 +403,7 @@ function test_workers() {
w.onmessage = function(e) { w.onmessage = function(e) {
is(e.data, 'ok', "Worker ready!"); is(e.data, 'ok', "Worker ready!");
w.onmessage = function(e) { w.onmessage = function(e1) {
if (!resolve) { if (!resolve) {
ok(false, "Unexpected message!"); ok(false, "Unexpected message!");
return; return;
@ -411,7 +411,7 @@ function test_workers() {
let tmp = resolve; let tmp = resolve;
resolve = null; resolve = null;
tmp({ data: e.data, ports: e.ports }); tmp({ data: e1.data, ports: e1.ports });
} }
runTests({ runTests({
@ -423,7 +423,7 @@ function test_workers() {
resolve = r; resolve = r;
try { try {
w.postMessage(what, ports); w.postMessage(what, ports);
} catch(e) { } catch(ex) {
resolve = null; resolve = null;
rr(); rr();
} }
@ -493,7 +493,7 @@ function test_broadcastChannel_inWorkers() {
w.onmessage = function(e) { w.onmessage = function(e) {
is(e.data, 'ok', "Worker ready!"); is(e.data, 'ok', "Worker ready!");
w.onmessage = function(e) { w.onmessage = function(e1) {
if (!resolve) { if (!resolve) {
ok(false, "Unexpected message!"); ok(false, "Unexpected message!");
return; return;
@ -501,7 +501,7 @@ function test_broadcastChannel_inWorkers() {
let tmp = resolve; let tmp = resolve;
resolve = null; resolve = null;
tmp({ data: e.data, ports: e.ports }); tmp({ data: e1.data, ports: e1.ports });
} }
runTests({ runTests({
@ -581,7 +581,7 @@ function test_messagePort_inWorkers() {
w.onmessage = function(e) { w.onmessage = function(e) {
is(e.data, 'ok', "Worker ready!"); is(e.data, 'ok', "Worker ready!");
w.onmessage = function(e) { w.onmessage = function(e1) {
if (!resolve) { if (!resolve) {
ok(false, "Unexpected message!"); ok(false, "Unexpected message!");
return; return;
@ -589,7 +589,7 @@ function test_messagePort_inWorkers() {
let tmp = resolve; let tmp = resolve;
resolve = null; resolve = null;
tmp({ data: e.data, ports: e.ports }); tmp({ data: e1.data, ports: e1.ports });
} }
runTests({ runTests({
@ -601,7 +601,7 @@ function test_messagePort_inWorkers() {
resolve = r; resolve = r;
try { try {
mc.port1.postMessage(what, ports); mc.port1.postMessage(what, ports);
} catch(e) { } catch(ex) {
resolve = null; resolve = null;
rr(); rr();
} }

View file

@ -90,8 +90,8 @@ function runATest(obj) {
//convert RectList to a real array //convert RectList to a real array
obj.rectList=Array.prototype.slice.call(obj.rectList, 0); obj.rectList=Array.prototype.slice.call(obj.rectList, 0);
} }
obj.rectList.forEach(function(rect,i) { obj.rectList.forEach(function(r,i) {
is(_getRect(rectlist[i]),_getRect(rect), is(_getRect(rectlist[i]),_getRect(r),
annotateName(testname+": item at "+i)); annotateName(testname+": item at "+i));
}); });
} }

View file

@ -20,10 +20,9 @@ SimpleTest.waitForExplicitFinish();
// nesting. // nesting.
function clearNestingLevel() { function clearNestingLevel() {
return new Promise(resolve => { return new Promise(resolve => {
window.addEventListener('message', function onMessage() { window.addEventListener('message', () => {
window.removeEventListener('message', onMessage);
resolve(); resolve();
}); }, {once: true});
postMessage('done', '*'); postMessage('done', '*');
}); });
} }