From 1a8fd9262f67cad09c75e99b71eddaf5d37a6a7e Mon Sep 17 00:00:00 2001 From: "adam.kolodko" Date: Thu, 13 Dec 2018 00:43:55 +0000 Subject: [PATCH] Bug 1508990 - Enable ESLint for dom/ipc/ (automatic changes) r=Standard8,mrbkap Differential Revision: https://phabricator.services.mozilla.com/D13887 --HG-- extra : moz-landing-system : lando --- .eslintignore | 1 - dom/ipc/ManifestMessagesChild.jsm | 4 +- dom/ipc/tests/browser_domainPolicy.js | 66 +++++++++---------- .../browser_memory_distribution_telemetry.js | 6 +- ...owser_remote_navigation_delay_telemetry.js | 4 +- dom/ipc/tests/test_CrashService_crash.html | 21 +++--- dom/ipc/tests/test_Preallocated.html | 18 ++--- .../test_blob_sliced_from_child_process.html | 6 +- .../test_blob_sliced_from_parent_process.html | 12 ++-- dom/ipc/tests/test_bug1086684.html | 4 +- dom/ipc/tests/test_child_docshell.html | 16 ++--- dom/ipc/tests/test_cpow_cookies.html | 2 +- dom/ipc/tests/test_temporaryfile_stream.html | 8 +-- 13 files changed, 83 insertions(+), 85 deletions(-) diff --git a/.eslintignore b/.eslintignore index 7fa97c239d35..a4ee00f84f6f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -190,7 +190,6 @@ dom/file/** dom/flex/** dom/grid/** dom/html/** -dom/ipc/** dom/jsurl/** dom/localstorage/** dom/manifest/** diff --git a/dom/ipc/ManifestMessagesChild.jsm b/dom/ipc/ManifestMessagesChild.jsm index 2c4876055a1b..d007056d49f1 100644 --- a/dom/ipc/ManifestMessagesChild.jsm +++ b/dom/ipc/ManifestMessagesChild.jsm @@ -113,7 +113,7 @@ function serializeError(aError) { "columnNumber": aError.columnNumber, "stack": aError.stack, "message": aError.message, - "name": aError.name + "name": aError.name, }; return clone; } @@ -122,6 +122,6 @@ function makeMsgResponse(aId) { return { id: aId, success: false, - result: undefined + result: undefined, }; } diff --git a/dom/ipc/tests/browser_domainPolicy.js b/dom/ipc/tests/browser_domainPolicy.js index ad04c4076962..f517464e8380 100644 --- a/dom/ipc/tests/browser_domainPolicy.js +++ b/dom/ipc/tests/browser_domainPolicy.js @@ -20,7 +20,7 @@ async function test_domainPolicy() { {set: [["dom.ipc.browser_frames.oop_by_default", false], ["browser.pagethumbnails.capturing_disabled", false], ["dom.mozBrowserFramesEnabled", false]]}, - () => { return deferred.resolve()}); + () => { return deferred.resolve(); }); await currentTask; // Create tab @@ -38,10 +38,10 @@ async function test_domainPolicy() { let listener = (event) => { removeEventListener("DOMDocElementInserted", listener, true); let listener2 = (event) => { - content.removeEventListener('load', listener2); + content.removeEventListener("load", listener2); deferred.resolve(); - } - content.addEventListener('load', listener2); + }; + content.addEventListener("load", listener2); }; addEventListener("DOMDocElementInserted", listener, true); return deferred.promise; @@ -60,26 +60,26 @@ async function test_domainPolicy() { function initUtils(obj) { obj.checkScriptEnabled = function(win, expectEnabled) { win.wrappedJSObject.gFiredOnclick = false; - win.document.body.dispatchEvent(new win.Event('click')); + win.document.body.dispatchEvent(new win.Event("click")); return { passed: win.wrappedJSObject.gFiredOnclick == expectEnabled, msg: `Checking script-enabled for ${win.name} (${win.location})`}; - } + }; obj.navigateFrame = function(ifr, src) { let deferred = PromiseUtils.defer(); function onload() { - ifr.removeEventListener('load', onload); + ifr.removeEventListener("load", onload); deferred.resolve(); } - ifr.addEventListener('load', onload); - ifr.setAttribute('src', src); + ifr.addEventListener("load", onload); + ifr.setAttribute("src", src); return deferred.promise; - } - }; + }; + } function runTest(test) { return ContentTask.spawn(tab.linkedBrowser, - 'ipcArgs = ' + JSON.stringify(ipcArgs) + '; (' + initUtils.toSource() + ')(utils)', test); + "ipcArgs = " + JSON.stringify(ipcArgs) + "; (" + initUtils.toSource() + ")(utils)", test); } function checkAndCleanup(result) { @@ -99,14 +99,14 @@ async function test_domainPolicy() { var utils = {}; eval(aUtils); - let path = '/browser/dom/ipc/tests/file_disableScript.html'; + let path = "/browser/dom/ipc/tests/file_disableScript.html"; let deferred = PromiseUtils.defer(); - var rootFrame = content.document.getElementById('root'); + var rootFrame = content.document.getElementById("root"); utils.navigateFrame(rootFrame, ipcArgs.domain + path).then(() => { deferred.resolve(utils.checkScriptEnabled(rootFrame.contentWindow, false)); }); return deferred.promise; - } + }; } info("Testing simple blocklist policy"); @@ -116,14 +116,14 @@ async function test_domainPolicy() { await currentTask; activateDomainPolicy(); var bl = policy.blocklist; - bl.add(Services.io.newURI('http://example.com')); + bl.add(Services.io.newURI("http://example.com")); currentTask = runTest(testDomain("http://example.com")); checkAndCleanup(await currentTask); info("Activating domainPolicy first, creating child process after"); activateDomainPolicy(); var bl = policy.blocklist; - bl.add(Services.io.newURI('http://example.com')); + bl.add(Services.io.newURI("http://example.com")); currentTask = initProcess(); await currentTask; currentTask = runTest(testDomain("http://example.com")); @@ -142,9 +142,9 @@ async function test_domainPolicy() { var testListInternal = function(expectEnabled, list, idx) { idx = idx || 0; let deferred = PromiseUtils.defer(); - let path = '/browser/dom/ipc/tests/file_disableScript.html'; + let path = "/browser/dom/ipc/tests/file_disableScript.html"; let target = list[idx] + path; - var rootFrame = content.document.getElementById('root'); + var rootFrame = content.document.getElementById("root"); utils.navigateFrame(rootFrame, target).then(function() { results.push(utils.checkScriptEnabled(rootFrame.contentWindow, expectEnabled)); if (idx == list.length - 1) @@ -153,20 +153,20 @@ async function test_domainPolicy() { testListInternal(expectEnabled, list, idx + 1).then(function(retArg) { deferred.resolve(retArg); }); }); return deferred.promise; - } + }; return testListInternal(ipcArgs.expectEnabled, ipcArgs.list); - } + }; } let testPolicy = { - exceptions: ['http://test1.example.com', 'http://example.com'], - superExceptions: ['http://test2.example.org', 'https://test1.example.com'], - exempt: ['http://test1.example.com', 'http://example.com', - 'http://test2.example.org', 'http://sub1.test2.example.org', - 'https://sub1.test1.example.com'], - notExempt: ['http://test2.example.com', 'http://sub1.test1.example.com', - 'http://www.example.com', 'https://test2.example.com', - 'https://example.com', 'http://test1.example.org'], + exceptions: ["http://test1.example.com", "http://example.com"], + superExceptions: ["http://test2.example.org", "https://test1.example.com"], + exempt: ["http://test1.example.com", "http://example.com", + "http://test2.example.org", "http://sub1.test2.example.org", + "https://sub1.test1.example.com"], + notExempt: ["http://test2.example.com", "http://sub1.test1.example.com", + "http://www.example.com", "https://test2.example.com", + "https://example.com", "http://test1.example.org"], }; function activate(isBlock, exceptions, superExceptions) { @@ -177,7 +177,7 @@ async function test_domainPolicy() { set.add(makeURI(e)); for (var e of superExceptions) superSet.add(makeURI(e)); - }; + } info("Testing Blocklist-style Domain Policy"); info("Activating domainPolicy first, creating child process after"); @@ -205,7 +205,7 @@ async function test_domainPolicy() { info("Testing Allowlist-style Domain Policy"); deferred = Promise.defer(); currentTask = deferred.promise; - SpecialPowers.pushPrefEnv({set:[["javascript.enabled", false]]}, () => { return deferred.resolve()}); + SpecialPowers.pushPrefEnv({set: [["javascript.enabled", false]]}, () => { return deferred.resolve(); }); await currentTask; info("Activating domainPolicy first, creating child process after"); @@ -235,6 +235,6 @@ async function test_domainPolicy() { add_task(test_domainPolicy); -registerCleanupFunction(()=>{ +registerCleanupFunction(() => { deactivateDomainPolicy(); -}) +}); diff --git a/dom/ipc/tests/browser_memory_distribution_telemetry.js b/dom/ipc/tests/browser_memory_distribution_telemetry.js index 72c08280fcb4..90407b2c786e 100644 --- a/dom/ipc/tests/browser_memory_distribution_telemetry.js +++ b/dom/ipc/tests/browser_memory_distribution_telemetry.js @@ -36,10 +36,10 @@ add_task(async function test_memory_distribution() { let tab3 = await BrowserTestUtils.openNewForegroundTab(gBrowser, DUMMY_PAGE_DATA_URI); let finishedGathering = new Promise(resolve => { - let obs = function () { + let obs = function() { Services.obs.removeObserver(obs, "gather-memory-telemetry-finished"); resolve(); - } + }; Services.obs.addObserver(obs, "gather-memory-telemetry-finished"); }); @@ -48,7 +48,7 @@ add_task(async function test_memory_distribution() { await finishedGathering; let s = histogram.snapshot(); - ok("0 - 10 tabs" in s, "We should have some samples by now in this bucket.") + ok("0 - 10 tabs" in s, "We should have some samples by now in this bucket."); for (var key in s) { is(key, "0 - 10 tabs"); let fewTabsSnapshot = s[key]; diff --git a/dom/ipc/tests/browser_remote_navigation_delay_telemetry.js b/dom/ipc/tests/browser_remote_navigation_delay_telemetry.js index 8510c0002c0a..8d95b1fcf8d1 100644 --- a/dom/ipc/tests/browser_remote_navigation_delay_telemetry.js +++ b/dom/ipc/tests/browser_remote_navigation_delay_telemetry.js @@ -28,11 +28,11 @@ add_task(async function test_memory_distribution() { // There is no good way to make sure that the parent received the histogram entries from the child processes. // Let's stick to the ugly, spinning the event loop until we have a good approach (Bug 1357509). await BrowserTestUtils.waitForCondition(() => { - let s = Services.telemetry.getSnapshotForKeyedHistograms("main", false).content["FX_TAB_REMOTE_NAVIGATION_DELAY_MS"]; + let s = Services.telemetry.getSnapshotForKeyedHistograms("main", false).content.FX_TAB_REMOTE_NAVIGATION_DELAY_MS; return s && "WebNavigation:LoadURI" in s && "SessionStore:restoreTabContent" in s; }); - let s = Services.telemetry.getSnapshotForKeyedHistograms("main", false).content["FX_TAB_REMOTE_NAVIGATION_DELAY_MS"]; + let s = Services.telemetry.getSnapshotForKeyedHistograms("main", false).content.FX_TAB_REMOTE_NAVIGATION_DELAY_MS; let restoreTabSnapshot = s["SessionStore:restoreTabContent"]; ok(restoreTabSnapshot.sum > 0, "Zero delay for the restoreTabContent case is unlikely."); ok(restoreTabSnapshot.sum < 10000, "More than 10 seconds delay for the restoreTabContent case is unlikely."); diff --git a/dom/ipc/tests/test_CrashService_crash.html b/dom/ipc/tests/test_CrashService_crash.html index 98e87834b9a9..605cc1ead832 100644 --- a/dom/ipc/tests/test_CrashService_crash.html +++ b/dom/ipc/tests/test_CrashService_crash.html @@ -16,13 +16,13 @@ Ensures that content crashes are reported to the crash service SimpleTest.waitForExplicitFinish(); SimpleTest.requestFlakyTimeout("untriaged"); SpecialPowers.addPermission("browser", true, document); -SpecialPowers.pushPrefEnv({'set':[ +SpecialPowers.pushPrefEnv({"set": [ ["dom.mozBrowserFramesEnabled", true], ["network.disable.ipc.security", true], - ["dom.ipc.tabs.disabled", false] -]}, function () { + ["dom.ipc.tabs.disabled", false], +]}, function() { - var iframe = document.createElementNS('http://www.w3.org/1999/xhtml', 'iframe'); + var iframe = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe"); iframe.setAttribute("remote", "true"); SpecialPowers.wrap(iframe).mozbrowser = true; document.documentElement.appendChild(iframe); @@ -36,13 +36,13 @@ SpecialPowers.pushPrefEnv({'set':[ // First, clear the crash record store. info("Waiting for pruneOldCrashes"); var future = new Date(Date.now() + 1000 * 60 * 60 * 24); - crashMan.pruneOldCrashes(future).then(function () { + crashMan.pruneOldCrashes(future).then(function() { var crashDateMS = Date.now(); // Inject a frame script that crashes the content process. var mm = SpecialPowers.getBrowserFrameMessageManager(iframe); - mm.loadFrameScript('data:,new ' + function ContentScriptScope() { + mm.loadFrameScript("data:,new " + function ContentScriptScope() { ChromeUtils.import("resource://gre/modules/ctypes.jsm"); let crash = function() { let zero = new ctypes.intptr_t(8); @@ -56,7 +56,7 @@ SpecialPowers.pushPrefEnv({'set':[ // Finally, poll for the new crash record. function tryGetCrash() { info("Waiting for getCrashes"); - crashMan.getCrashes().then(SpecialPowers.wrapCallback(function (crashes) { + crashMan.getCrashes().then(SpecialPowers.wrapCallback(function(crashes) { if (crashes.length) { is(crashes.length, 1, "There should be only one record"); var crash = crashes[0]; @@ -72,18 +72,17 @@ SpecialPowers.pushPrefEnv({'set':[ "Record's crash date should be nowish: " + "now=" + crashDateMS + " recordDate=" + dateMS); SimpleTest.finish(); - } - else { + } else { setTimeout(tryGetCrash, 1000); } - }), function (err) { + }), function(err) { ok(false, "Error getting crashes: " + err); SimpleTest.finish(); }); } setTimeout(tryGetCrash, 1000); - }, function () { + }, function() { ok(false, "pruneOldCrashes error"); SimpleTest.finish(); }); diff --git a/dom/ipc/tests/test_Preallocated.html b/dom/ipc/tests/test_Preallocated.html index e372f824de8e..bbc7dba4529d 100644 --- a/dom/ipc/tests/test_Preallocated.html +++ b/dom/ipc/tests/test_Preallocated.html @@ -18,18 +18,18 @@ SimpleTest.waitForExplicitFinish(); function expectProcessCreated() { return new Promise(resolve => { function parentExpectProcessCreated() { - ChromeUtils.import('resource://gre/modules/Services.jsm'); + ChromeUtils.import("resource://gre/modules/Services.jsm"); let topic = "ipc:content-initializing"; - let obs = { observe: function() { + let obs = { observe() { Services.obs.removeObserver(obs, topic); - sendAsyncMessage('process-created'); - }} + sendAsyncMessage("process-created"); + }}; Services.obs.addObserver(obs, topic); } let helper = SpecialPowers.loadChromeScript(parentExpectProcessCreated); - SimpleTest.registerCleanupFunction(function() { helper.destroy() }); - helper.addMessageListener('process-created', resolve); + SimpleTest.registerCleanupFunction(function() { helper.destroy(); }); + helper.addMessageListener("process-created", resolve); }); } @@ -39,11 +39,11 @@ expectProcessCreated().then(() => { }); // Kill existing preallocated process. -SpecialPowers.pushPrefEnv({'set':[["dom.ipc.processPrelaunch.enabled", false]]}).then(() => { +SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processPrelaunch.enabled", false]]}).then(() => { // Make sure we have the capacity to launch preallocated process. - SpecialPowers.pushPrefEnv({'set':[["dom.ipc.processCount", 100]]}).then(() => { + SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 100]]}).then(() => { // Enable preallocated process and run the test. - SpecialPowers.pushPrefEnv({'set':[["dom.ipc.processPrelaunch.enabled", true]]}); + SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processPrelaunch.enabled", true]]}); }); }); diff --git a/dom/ipc/tests/test_blob_sliced_from_child_process.html b/dom/ipc/tests/test_blob_sliced_from_child_process.html index 5f0164b15c24..ec045ded7569 100644 --- a/dom/ipc/tests/test_blob_sliced_from_child_process.html +++ b/dom/ipc/tests/test_blob_sliced_from_child_process.html @@ -35,8 +35,8 @@ function childFrameScript() { slice = slice.slice(secondSliceStart, secondSliceEnd, blobType); - sendAsyncMessage(messageName, { blob: blob }); - sendAsyncMessage(messageName, { slice: slice }); + sendAsyncMessage(messageName, { blob }); + sendAsyncMessage(messageName, { slice }); } function parentFrameScript(mm) { @@ -168,7 +168,7 @@ function setup() { iframe.addEventListener("mozbrowserloadend", function() { info("Starting tests"); - let mm = SpecialPowers.getBrowserFrameMessageManager(iframe) + let mm = SpecialPowers.getBrowserFrameMessageManager(iframe); parentFrameScript(mm); }); diff --git a/dom/ipc/tests/test_blob_sliced_from_parent_process.html b/dom/ipc/tests/test_blob_sliced_from_parent_process.html index 79a405f86d60..a5b1e7a6395c 100644 --- a/dom/ipc/tests/test_blob_sliced_from_parent_process.html +++ b/dom/ipc/tests/test_blob_sliced_from_parent_process.html @@ -21,15 +21,15 @@ function childFrameScript() { const sliceText = "an"; function info(msg) { - sendAsyncMessage(messageName, { op: "info", msg: msg }); + sendAsyncMessage(messageName, { op: "info", msg }); } function ok(condition, name, diag) { sendAsyncMessage(messageName, { op: "ok", - condition: condition, - name: name, - diag: diag }); + condition, + name, + diag }); } function is(a, b, name) { @@ -39,7 +39,7 @@ function childFrameScript() { } function finish(result) { - sendAsyncMessage(messageName, { op: "done", result: result }); + sendAsyncMessage(messageName, { op: "done", result }); } function grabAndContinue(arg) { @@ -190,7 +190,7 @@ function setup() { iframe.addEventListener("mozbrowserloadend", function() { info("Starting tests"); - let mm = SpecialPowers.getBrowserFrameMessageManager(iframe) + let mm = SpecialPowers.getBrowserFrameMessageManager(iframe); parentFrameScript(mm); }); diff --git a/dom/ipc/tests/test_bug1086684.html b/dom/ipc/tests/test_bug1086684.html index 64cddf89d3d0..c41399fefbb4 100644 --- a/dom/ipc/tests/test_bug1086684.html +++ b/dom/ipc/tests/test_bug1086684.html @@ -99,8 +99,8 @@ ["dom.ipc.browser_frames.oop_by_default", true], ["dom.mozBrowserFramesEnabled", true], ["network.disable.ipc.security", true], - ["browser.pagethumbnails.capturing_disabled", true] - ] + ["browser.pagethumbnails.capturing_disabled", true], + ], }, runTests); }); diff --git a/dom/ipc/tests/test_child_docshell.html b/dom/ipc/tests/test_child_docshell.html index 638a4a72aef9..fccb08045baf 100644 --- a/dom/ipc/tests/test_child_docshell.html +++ b/dom/ipc/tests/test_child_docshell.html @@ -13,19 +13,19 @@ SimpleTest.waitForExplicitFinish(); SpecialPowers.addPermission("browser", true, document); -SpecialPowers.pushPrefEnv({'set':[ +SpecialPowers.pushPrefEnv({"set": [ ["dom.mozBrowserFramesEnabled", true], ["network.disable.ipc.security", true], - ["dom.ipc.tabs.disabled", false] -]}, function () { + ["dom.ipc.tabs.disabled", false], +]}, function() { - var iframe = document.createElementNS('http://www.w3.org/1999/xhtml', 'iframe'); + var iframe = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe"); iframe.setAttribute("remote", "true"); SpecialPowers.wrap(iframe).mozbrowser = true; document.documentElement.appendChild(iframe); var mm = SpecialPowers.getBrowserFrameMessageManager(iframe); - mm.addMessageListener("chromeEventHandler", function (msg) { + mm.addMessageListener("chromeEventHandler", function(msg) { msg = SpecialPowers.wrap(msg); var result = msg.json; is(result.processType, SpecialPowers.Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT, @@ -35,7 +35,7 @@ SpecialPowers.pushPrefEnv({'set':[ }); - mm.addMessageListener("DOMWindowCreatedReceived", function (msg) { + mm.addMessageListener("DOMWindowCreatedReceived", function(msg) { msg = SpecialPowers.wrap(msg); ok(true, "the chrome event handler looks functional"); var result = msg.json; @@ -45,7 +45,7 @@ SpecialPowers.pushPrefEnv({'set':[ SimpleTest.finish(); }); // Inject a frame script in the child process: - mm.loadFrameScript('data:,new ' + function ContentScriptScope() { + mm.loadFrameScript("data:,new " + function ContentScriptScope() { var processType = Cc["@mozilla.org/xre/runtime;1"] .getService(Ci.nsIXULRuntime) .processType; @@ -70,7 +70,7 @@ SpecialPowers.pushPrefEnv({'set':[ sendAsyncMessage("DOMWindowCreatedReceived", { stableChromeEventHandler: chromeEventHandler === docShell.chromeEventHandler, iframeHasNewDocShell: new_docShell !== docShell, - iframeHasSameChromeEventHandler: new_docShell.chromeEventHandler === chromeEventHandler + iframeHasSameChromeEventHandler: new_docShell.chromeEventHandler === chromeEventHandler, }); }); diff --git a/dom/ipc/tests/test_cpow_cookies.html b/dom/ipc/tests/test_cpow_cookies.html index daeea7e12dae..a7f25ffcaa0b 100644 --- a/dom/ipc/tests/test_cpow_cookies.html +++ b/dom/ipc/tests/test_cpow_cookies.html @@ -82,7 +82,7 @@ ["network.disable.ipc.security", true], ["browser.pagethumbnails.capturing_disabled", true], ["security.data_uri.block_toplevel_data_uri_navigations", false], - ] + ], }, runTests); }); diff --git a/dom/ipc/tests/test_temporaryfile_stream.html b/dom/ipc/tests/test_temporaryfile_stream.html index a49b8c9d67ec..7e09ff5c099a 100644 --- a/dom/ipc/tests/test_temporaryfile_stream.html +++ b/dom/ipc/tests/test_temporaryfile_stream.html @@ -46,7 +46,7 @@ function startTest() { info("Got 'stop' event"); ok(blob, "Should have gotten a data blob"); var xhr = new XMLHttpRequest(); - xhr.open('POST', 'blob_verify.sjs', true); + xhr.open("POST", "blob_verify.sjs", true); xhr.onload = () => { var video = document.createElement("video"); video.id = "recorded-video"; @@ -59,13 +59,13 @@ function startTest() { document.getElementById("content").appendChild(video); helper.pixelMustBecome(video, helper.red, { threshold: 128, - infoString: "Should become red" + infoString: "Should become red", }).then(SimpleTest.finish); }; xhr.onerror = () => { ok(false, "XHR error"); SimpleTest.finish(); - } + }; xhr.responseType = "blob"; xhr.send(blob); }; @@ -75,7 +75,7 @@ function startTest() { } SimpleTest.waitForExplicitFinish(); -SpecialPowers.pushPrefEnv({set:[["media.recorder.max_memory", 1]]}, startTest); +SpecialPowers.pushPrefEnv({set: [["media.recorder.max_memory", 1]]}, startTest);