diff --git a/.eslintrc.js b/.eslintrc.js index cd70399fd4f8..c297cd901eb4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -45,7 +45,6 @@ module.exports = { "overrides": [{ "files": [ "devtools/**", - "widget/**", "xpcom/**", "xpfe/**", ], diff --git a/.prettierignore b/.prettierignore index 35681f0f97a1..e51d42a0d7f7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -40,7 +40,6 @@ toolkit/components/telemetry/datareporting-prefs.js toolkit/components/telemetry/healthreport-prefs.js # Ignore all top-level directories for now. -widget/** xpcom/** xpfe/** diff --git a/widget/headless/tests/test_headless.js b/widget/headless/tests/test_headless.js index 93f092f9d76d..4d5c707fa363 100644 --- a/widget/headless/tests/test_headless.js +++ b/widget/headless/tests/test_headless.js @@ -1,8 +1,8 @@ /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* vim: set sts=2 sw=2 et tw=80: */ "use strict"; -const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); -const {HttpServer} = ChromeUtils.import("resource://testing-common/httpd.js"); +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js"); const server = new HttpServer(); server.registerDirectory("/", do_get_cwd()); @@ -11,7 +11,9 @@ const ROOT = `http://localhost:${server.identity.primaryPort}`; const BASE = `${ROOT}/`; const HEADLESS_URL = `${BASE}/headless.html`; const HEADLESS_BUTTON_URL = `${BASE}/headless_button.html`; -registerCleanupFunction(() => { server.stop(() => {}); }); +registerCleanupFunction(() => { + server.stop(() => {}); +}); // Refrences to the progress listeners to keep them from being gc'ed // before they are called. @@ -24,8 +26,9 @@ function loadContentWindow(windowlessBrowser, uri) { }; windowlessBrowser.loadURI(uri, loadURIOptions); let docShell = windowlessBrowser.docShell; - let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebProgress); + let webProgress = docShell + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebProgress); let progressListener = { onLocationChange(progress, request, location, flags) { // Ignore inner-frame events @@ -39,16 +42,24 @@ function loadContentWindow(windowlessBrowser, uri) { let contentWindow = docShell.domWindow; webProgress.removeProgressListener(progressListener); progressListeners.delete(progressListener); - contentWindow.addEventListener("load", (event) => { - resolve(contentWindow); - }, { once: true }); + contentWindow.addEventListener( + "load", + event => { + resolve(contentWindow); + }, + { once: true } + ); }, - QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener", - "nsISupportsWeakReference"]), + QueryInterface: ChromeUtils.generateQI([ + "nsIWebProgressListener", + "nsISupportsWeakReference", + ]), }; progressListeners.set(progressListener, progressListener); - webProgress.addProgressListener(progressListener, - Ci.nsIWebProgress.NOTIFY_LOCATION); + webProgress.addProgressListener( + progressListener, + Ci.nsIWebProgress.NOTIFY_LOCATION + ); }); } @@ -63,22 +74,24 @@ add_task(async function test_snapshot() { equal(contentWindow.innerHeight, contentHeight); // Snapshot the test page. - let canvas = contentWindow.document.createElementNS("http://www.w3.org/1999/xhtml", "html:canvas"); + let canvas = contentWindow.document.createElementNS( + "http://www.w3.org/1999/xhtml", + "html:canvas" + ); let context = canvas.getContext("2d"); let width = contentWindow.innerWidth; let height = contentWindow.innerHeight; canvas.width = width; canvas.height = height; - context.drawWindow( - contentWindow, - 0, - 0, - width, - height, - "rgb(255, 255, 255)" - ); + context.drawWindow(contentWindow, 0, 0, width, height, "rgb(255, 255, 255)"); let imageData = context.getImageData(0, 0, width, height).data; - ok(imageData[0] === 0 && imageData[1] === 255 && imageData[2] === 0 && imageData[3] === 255, "Page is green."); + ok( + imageData[0] === 0 && + imageData[1] === 255 && + imageData[2] === 0 && + imageData[3] === 255, + "Page is green." + ); // Search for a blue pixel (a quick and dirty check to see if the blue text is // on the page) @@ -106,7 +119,10 @@ add_task(async function test_snapshot_widget_layers() { equal(contentWindow.innerHeight, contentHeight); // Snapshot the test page. - let canvas = contentWindow.document.createElementNS("http://www.w3.org/1999/xhtml", "html:canvas"); + let canvas = contentWindow.document.createElementNS( + "http://www.w3.org/1999/xhtml", + "html:canvas" + ); let context = canvas.getContext("2d"); let width = contentWindow.innerWidth; let height = contentWindow.innerHeight; @@ -119,7 +135,9 @@ add_task(async function test_snapshot_widget_layers() { width, height, "rgb(255, 255, 255)", - context.DRAWWINDOW_DRAW_CARET | context.DRAWWINDOW_DRAW_VIEW | context.DRAWWINDOW_USE_WIDGET_LAYERS + context.DRAWWINDOW_DRAW_CARET | + context.DRAWWINDOW_DRAW_VIEW | + context.DRAWWINDOW_USE_WIDGET_LAYERS ); ok(true, "Snapshot with widget layers didn't crash."); @@ -132,17 +150,31 @@ add_task(async function test_keydown() { // nsIWindowlessBrowser inherits from nsIWebNavigation. let contentWindow = await loadContentWindow(windowlessBrowser, HEADLESS_URL); - let keydown = new Promise((resolve) => { - contentWindow.addEventListener("keydown", () => { - resolve(); - }, { once: true }); + let keydown = new Promise(resolve => { + contentWindow.addEventListener( + "keydown", + () => { + resolve(); + }, + { once: true } + ); }); - let tip = Cc["@mozilla.org/text-input-processor;1"] - .createInstance(Ci.nsITextInputProcessor); + let tip = Cc["@mozilla.org/text-input-processor;1"].createInstance( + Ci.nsITextInputProcessor + ); let begun = tip.beginInputTransactionForTests(contentWindow); - ok(begun, "nsITextInputProcessor.beginInputTransactionForTests() should succeed"); - tip.keydown(new contentWindow.KeyboardEvent("", {key: "a", code: "KeyA", keyCode: contentWindow.KeyboardEvent.DOM_VK_A})); + ok( + begun, + "nsITextInputProcessor.beginInputTransactionForTests() should succeed" + ); + tip.keydown( + new contentWindow.KeyboardEvent("", { + key: "a", + code: "KeyA", + keyCode: contentWindow.KeyboardEvent.DOM_VK_A, + }) + ); await keydown; ok(true, "Send keydown didn't crash"); @@ -155,7 +187,10 @@ add_task(async function test_keydown() { add_task(async function test_mouse_drag() { let windowlessBrowser = Services.appShell.createWindowlessBrowser(false); // nsIWindowlessBrowser inherits from nsIWebNavigation. - let contentWindow = await loadContentWindow(windowlessBrowser, HEADLESS_BUTTON_URL); + let contentWindow = await loadContentWindow( + windowlessBrowser, + HEADLESS_BUTTON_URL + ); contentWindow.resizeTo(400, 400); let target = contentWindow.document.getElementById("btn"); @@ -168,7 +203,9 @@ add_task(async function test_mouse_drag() { utils.sendMouseEvent("mousemove", left, top, 0, 1, 0, false, 0, 0); // Wait for a turn of the event loop since the synthetic mouse event // that creates the drag service is processed during the refresh driver. - await new Promise((r) => { executeSoon(r); }); + await new Promise(r => { + executeSoon(r); + }); utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0); ok(true, "Send mouse event didn't crash"); diff --git a/widget/headless/tests/test_headless_clipboard.js b/widget/headless/tests/test_headless_clipboard.js index e11d41973eee..6c0ffcd5a1c1 100644 --- a/widget/headless/tests/test_headless_clipboard.js +++ b/widget/headless/tests/test_headless_clipboard.js @@ -7,8 +7,9 @@ function getString(clipboard) { var str = ""; // Create transferable that will transfer the text. - var trans = Cc["@mozilla.org/widget/transferable;1"] - .createInstance(Ci.nsITransferable); + var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance( + Ci.nsITransferable + ); trans.init(null); trans.addDataFlavor("text/unicode"); @@ -34,8 +35,9 @@ add_task(async function test_clipboard() { // Test copy. const data = "random number: " + Math.random(); - let helper = Cc["@mozilla.org/widget/clipboardhelper;1"] - .getService(Ci.nsIClipboardHelper); + let helper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService( + Ci.nsIClipboardHelper + ); helper.copyString(data); equal(getString(clipboard), data, "Data was successfully copied."); diff --git a/widget/tests/browser/browser_test_clipboardcache.js b/widget/tests/browser/browser_test_clipboardcache.js index 55bab532a285..208ec593586c 100644 --- a/widget/tests/browser/browser_test_clipboardcache.js +++ b/widget/tests/browser/browser_test_clipboardcache.js @@ -2,8 +2,9 @@ /* vim: set sts=2 sw=2 et tw=80: */ "use strict"; -const { AppConstants } = - ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); +const { AppConstants } = ChromeUtils.import( + "resource://gre/modules/AppConstants.jsm" +); // Note: widget/tests/test_bug1123480.xul checks whether nsTransferable behaves // as expected with regards to private browsing mode and the clipboard cache, @@ -45,8 +46,9 @@ function getClipboardCacheFDCount() { // handles, so if FILE_FLAG_DELETE_ON_CLOSE does the thing it promises, the // file is actually removed when the handle is closed. - let {FileUtils} = - ChromeUtils.import("resource://gre/modules/FileUtils.jsm"); + let { FileUtils } = ChromeUtils.import( + "resource://gre/modules/FileUtils.jsm" + ); // Path from nsAnonymousTemporaryFile.cpp, GetTempDir. dir = FileUtils.getFile("TmpD", ["mozilla-temp-files"]); } else { @@ -71,18 +73,18 @@ function getClipboardCacheFDCount() { } async function testCopyPaste(isPrivate) { - let win = await BrowserTestUtils.openNewBrowserWindow({private: isPrivate}); + let win = await BrowserTestUtils.openNewBrowserWindow({ private: isPrivate }); let tab = await BrowserTestUtils.openNewForegroundTab(win); let browser = tab.linkedBrowser; // Sanitize environment - await ContentTask.spawn(browser, SHORT_STRING_NO_CACHE, async (shortStr) => { + await ContentTask.spawn(browser, SHORT_STRING_NO_CACHE, async shortStr => { await content.navigator.clipboard.writeText(shortStr); }); let initialFdCount = getClipboardCacheFDCount(); - await ContentTask.spawn(browser, Ipsum, async (largeString) => { + await ContentTask.spawn(browser, Ipsum, async largeString => { await content.navigator.clipboard.writeText(largeString); }); @@ -94,13 +96,17 @@ async function testCopyPaste(isPrivate) { } let readStr = await ContentTask.spawn(browser, null, async () => { - let {document} = content; + let { document } = content; document.body.contentEditable = true; document.body.focus(); let pastePromise = new Promise(resolve => { - document.addEventListener("paste", e => { - resolve(e.clipboardData.getData("text/plain")); - }, {once: true}); + document.addEventListener( + "paste", + e => { + resolve(e.clipboardData.getData("text/plain")); + }, + { once: true } + ); }); document.execCommand("paste"); return pastePromise; @@ -117,7 +123,7 @@ async function testCopyPaste(isPrivate) { } // Cleanup. - await ContentTask.spawn(browser, SHORT_STRING_NO_CACHE, async (shortStr) => { + await ContentTask.spawn(browser, SHORT_STRING_NO_CACHE, async shortStr => { await content.navigator.clipboard.writeText(shortStr); }); is(getClipboardCacheFDCount(), initialFdCount, "Drop clipboard cache if any"); diff --git a/widget/tests/browser/browser_test_procinfo.js b/widget/tests/browser/browser_test_procinfo.js index a74c55bc131e..e1d67e68d680 100644 --- a/widget/tests/browser/browser_test_procinfo.js +++ b/widget/tests/browser/browser_test_procinfo.js @@ -4,13 +4,15 @@ const ROOT_URL = "http://example.com/browser/widget/tests/browser"; const DUMMY_URL = ROOT_URL + "/dummy.html"; -const { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); +const { AppConstants } = ChromeUtils.import( + "resource://gre/modules/AppConstants.jsm" +); const MAC = AppConstants.platform == "macosx"; - add_task(async function test_proc_info() { waitForExplicitFinish(); - await BrowserTestUtils.withNewTab({ gBrowser, url: DUMMY_URL}, + await BrowserTestUtils.withNewTab( + { gBrowser, url: DUMMY_URL }, async function(browser) { let cpuThreads = 0; let cpuUser = 0; @@ -35,5 +37,6 @@ add_task(async function test_proc_info() { Assert.ok(cpuThreads > 0, "Got some cpu time in the threads"); } Assert.ok(cpuUser > 0, "Got some cpu time"); - }); + } + ); }); diff --git a/widget/tests/unit/test_macsharingservice.js b/widget/tests/unit/test_macsharingservice.js index dd9aae2bc324..2bb21fe6ba87 100644 --- a/widget/tests/unit/test_macsharingservice.js +++ b/widget/tests/unit/test_macsharingservice.js @@ -6,8 +6,9 @@ // Basic tests to verify that MacSharingService returns expected data function test_getSharingProviders() { - let sharingService = Cc["@mozilla.org/widget/macsharingservice;1"]. - getService(Ci.nsIMacSharingService); + let sharingService = Cc["@mozilla.org/widget/macsharingservice;1"].getService( + Ci.nsIMacSharingService + ); let providers = sharingService.getSharingProviders("http://example.org"); Assert.ok(providers.length > 1, "There are providers returned"); providers.forEach(provider => { @@ -15,7 +16,11 @@ function test_getSharingProviders() { Assert.ok("menuItemTitle" in provider, "Provider has menuItemTitle"); Assert.ok("image" in provider, "Provider has image"); - Assert.notEqual(provider.title, "Mail", "Known filtered provider not returned"); + Assert.notEqual( + provider.title, + "Mail", + "Known filtered provider not returned" + ); }); } diff --git a/widget/tests/unit/test_macwebapputils.js b/widget/tests/unit/test_macwebapputils.js index f889679d8e09..8967f8a59342 100644 --- a/widget/tests/unit/test_macwebapputils.js +++ b/widget/tests/unit/test_macwebapputils.js @@ -6,8 +6,9 @@ // Basic tests to verify that MacWebAppUtils works function test_find_app() { - var mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]. - createInstance(Ci.nsIMacWebAppUtils); + var mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"].createInstance( + Ci.nsIMacWebAppUtils + ); let sig = "com.apple.TextEdit"; let path; @@ -17,8 +18,9 @@ function test_find_app() { } function test_dont_find_fake_app() { - var mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]. - createInstance(Ci.nsIMacWebAppUtils); + var mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"].createInstance( + Ci.nsIMacWebAppUtils + ); let sig = "calliope.penitentiary.dramamine"; let path; @@ -26,7 +28,6 @@ function test_dont_find_fake_app() { Assert.equal(path, ""); } - function run_test() { test_find_app(); test_dont_find_fake_app(); diff --git a/widget/tests/unit/test_taskbar_jumplistitems.js b/widget/tests/unit/test_taskbar_jumplistitems.js index 175a9e7857a4..0492397c9fa5 100644 --- a/widget/tests/unit/test_taskbar_jumplistitems.js +++ b/widget/tests/unit/test_taskbar_jumplistitems.js @@ -7,17 +7,21 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); function test_basics() { - var item = Cc["@mozilla.org/windows-jumplistitem;1"]. - createInstance(Ci.nsIJumpListItem); + var item = Cc["@mozilla.org/windows-jumplistitem;1"].createInstance( + Ci.nsIJumpListItem + ); - var sep = Cc["@mozilla.org/windows-jumplistseparator;1"]. - createInstance(Ci.nsIJumpListSeparator); + var sep = Cc["@mozilla.org/windows-jumplistseparator;1"].createInstance( + Ci.nsIJumpListSeparator + ); - var shortcut = Cc["@mozilla.org/windows-jumplistshortcut;1"]. - createInstance(Ci.nsIJumpListShortcut); + var shortcut = Cc["@mozilla.org/windows-jumplistshortcut;1"].createInstance( + Ci.nsIJumpListShortcut + ); - var link = Cc["@mozilla.org/windows-jumplistlink;1"]. - createInstance(Ci.nsIJumpListLink); + var link = Cc["@mozilla.org/windows-jumplistlink;1"].createInstance( + Ci.nsIJumpListLink + ); Assert.ok(!item.equals(sep)); Assert.ok(!item.equals(shortcut)); @@ -44,78 +48,127 @@ function test_basics() { function test_separator() { // separators: - var item = Cc["@mozilla.org/windows-jumplistseparator;1"]. - createInstance(Ci.nsIJumpListSeparator); + var item = Cc["@mozilla.org/windows-jumplistseparator;1"].createInstance( + Ci.nsIJumpListSeparator + ); Assert.ok(item.type == Ci.nsIJumpListItem.JUMPLIST_ITEM_SEPARATOR); } function test_hashes() { - var link = Cc["@mozilla.org/windows-jumplistlink;1"] - .createInstance(Ci.nsIJumpListLink); + var link = Cc["@mozilla.org/windows-jumplistlink;1"].createInstance( + Ci.nsIJumpListLink + ); var uri1 = Cc["@mozilla.org/network/simple-uri-mutator;1"] - .createInstance(Ci.nsIURIMutator) - .setSpec("http://www.123.com/") - .finalize(); + .createInstance(Ci.nsIURIMutator) + .setSpec("http://www.123.com/") + .finalize(); var uri2 = Cc["@mozilla.org/network/simple-uri-mutator;1"] - .createInstance(Ci.nsIURIMutator) - .setSpec("http://www.123.com/") - .finalize(); + .createInstance(Ci.nsIURIMutator) + .setSpec("http://www.123.com/") + .finalize(); link.uri = uri1; Assert.ok(link.compareHash(uri2)); - uri2 = uri2.mutate().setSpec("http://www.456.com/").finalize(); + uri2 = uri2 + .mutate() + .setSpec("http://www.456.com/") + .finalize(); Assert.ok(!link.compareHash(uri2)); - uri2 = uri2.mutate().setSpec("http://www.123.com/").finalize(); + uri2 = uri2 + .mutate() + .setSpec("http://www.123.com/") + .finalize(); Assert.ok(link.compareHash(uri2)); - uri2 = uri2.mutate().setSpec("https://www.123.com/").finalize(); + uri2 = uri2 + .mutate() + .setSpec("https://www.123.com/") + .finalize(); Assert.ok(!link.compareHash(uri2)); - uri2 = uri2.mutate().setSpec("http://www.123.com/test/").finalize(); + uri2 = uri2 + .mutate() + .setSpec("http://www.123.com/test/") + .finalize(); Assert.ok(!link.compareHash(uri2)); - uri1 = uri1.mutate().setSpec("http://www.123.com/test/").finalize(); + uri1 = uri1 + .mutate() + .setSpec("http://www.123.com/test/") + .finalize(); link.uri = uri1; - uri2 = uri2.mutate().setSpec("http://www.123.com/test/").finalize(); + uri2 = uri2 + .mutate() + .setSpec("http://www.123.com/test/") + .finalize(); Assert.ok(link.compareHash(uri2)); - uri1 = uri1.mutate().setSpec("https://www.123.com/test/").finalize(); + uri1 = uri1 + .mutate() + .setSpec("https://www.123.com/test/") + .finalize(); link.uri = uri1; - uri2 = uri2.mutate().setSpec("https://www.123.com/test/").finalize(); + uri2 = uri2 + .mutate() + .setSpec("https://www.123.com/test/") + .finalize(); Assert.ok(link.compareHash(uri2)); - uri2 = uri2.mutate().setSpec("ftp://www.123.com/test/").finalize(); + uri2 = uri2 + .mutate() + .setSpec("ftp://www.123.com/test/") + .finalize(); Assert.ok(!link.compareHash(uri2)); - uri2 = uri2.mutate().setSpec("http://123.com/test/").finalize(); + uri2 = uri2 + .mutate() + .setSpec("http://123.com/test/") + .finalize(); Assert.ok(!link.compareHash(uri2)); - uri1 = uri1.mutate().setSpec("https://www.123.com/test/").finalize(); + uri1 = uri1 + .mutate() + .setSpec("https://www.123.com/test/") + .finalize(); link.uri = uri1; - uri2 = uri2.mutate().setSpec("https://www.123.com/Test/").finalize(); + uri2 = uri2 + .mutate() + .setSpec("https://www.123.com/Test/") + .finalize(); Assert.ok(!link.compareHash(uri2)); - uri1 = uri1.mutate().setSpec("http://www.123.com/").finalize(); + uri1 = uri1 + .mutate() + .setSpec("http://www.123.com/") + .finalize(); link.uri = uri1; Assert.equal(link.uriHash, "QGLmWuwuTozr3tOfXSf5mg=="); - uri1 = uri1.mutate().setSpec("http://www.123.com/test/").finalize(); + uri1 = uri1 + .mutate() + .setSpec("http://www.123.com/test/") + .finalize(); link.uri = uri1; Assert.equal(link.uriHash, "AG87Ls+GmaUYSUJFETRr3Q=="); - uri1 = uri1.mutate().setSpec("https://www.123.com/").finalize(); + uri1 = uri1 + .mutate() + .setSpec("https://www.123.com/") + .finalize(); link.uri = uri1; Assert.equal(link.uriHash, "iSx6UH1a9enVPzUA9JZ42g=="); } function test_links() { // links: - var link1 = Cc["@mozilla.org/windows-jumplistlink;1"] - .createInstance(Ci.nsIJumpListLink); - var link2 = Cc["@mozilla.org/windows-jumplistlink;1"] - .createInstance(Ci.nsIJumpListLink); + var link1 = Cc["@mozilla.org/windows-jumplistlink;1"].createInstance( + Ci.nsIJumpListLink + ); + var link2 = Cc["@mozilla.org/windows-jumplistlink;1"].createInstance( + Ci.nsIJumpListLink + ); var uri1 = Cc["@mozilla.org/network/simple-uri-mutator;1"] - .createInstance(Ci.nsIURIMutator) - .setSpec("http://www.test.com/") - .finalize(); + .createInstance(Ci.nsIURIMutator) + .setSpec("http://www.test.com/") + .finalize(); var uri2 = Cc["@mozilla.org/network/simple-uri-mutator;1"] - .createInstance(Ci.nsIURIMutator) - .setSpec("http://www.test.com/") - .finalize(); + .createInstance(Ci.nsIURIMutator) + .setSpec("http://www.test.com/") + .finalize(); link1.uri = uri1; link1.uriTitle = "Test"; @@ -129,7 +182,10 @@ function test_links() { Assert.ok(!link1.equals(link2)); link2.uriTitle = "Test"; - uri2 = uri2.mutate().setSpec("http://www.testing.com/").finalize(); + uri2 = uri2 + .mutate() + .setSpec("http://www.testing.com/") + .finalize(); link2.uri = uri2; Assert.ok(!link1.equals(link2)); @@ -137,11 +193,13 @@ function test_links() { function test_shortcuts() { // shortcuts: - var sc = Cc["@mozilla.org/windows-jumplistshortcut;1"] - .createInstance(Ci.nsIJumpListShortcut); + var sc = Cc["@mozilla.org/windows-jumplistshortcut;1"].createInstance( + Ci.nsIJumpListShortcut + ); - var handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"] - .createInstance(Ci.nsILocalHandlerApp); + var handlerApp = Cc[ + "@mozilla.org/uriloader/local-handler-app;1" + ].createInstance(Ci.nsILocalHandlerApp); handlerApp.name = "TestApp"; handlerApp.detailedDescription = "TestApp detailed description."; @@ -151,9 +209,9 @@ function test_shortcuts() { Assert.equal(sc.iconIndex, 1); var faviconPageUri = Cc["@mozilla.org/network/simple-uri-mutator;1"] - .createInstance(Ci.nsIURIMutator) - .setSpec("http://www.123.com/") - .finalize(); + .createInstance(Ci.nsIURIMutator) + .setSpec("http://www.123.com/") + .finalize(); sc.faviconPageUri = faviconPageUri; Assert.equal(sc.faviconPageUri, faviconPageUri); @@ -176,11 +234,13 @@ async function test_jumplist() { // add a task item, and commit it. // not compiled in - if (Ci.nsIWinTaskbar == null) + if (Ci.nsIWinTaskbar == null) { return; + } - var taskbar = Cc["@mozilla.org/windows-taskbar;1"] - .getService(Ci.nsIWinTaskbar); + var taskbar = Cc["@mozilla.org/windows-taskbar;1"].getService( + Ci.nsIWinTaskbar + ); var builder = taskbar.createJumpListBuilder(); @@ -188,27 +248,29 @@ async function test_jumplist() { // Win7 and up only try { - var sysInfo = Cc["@mozilla.org/system-info;1"]. - getService(Ci.nsIPropertyBag2); + var sysInfo = Cc["@mozilla.org/system-info;1"].getService( + Ci.nsIPropertyBag2 + ); var ver = parseFloat(sysInfo.getProperty("version")); if (ver < 6.1) { Assert.ok(!builder.available); return; } - } catch (ex) { } + } catch (ex) {} Assert.ok(taskbar.available); builder.deleteActiveList(); - var items = Cc["@mozilla.org/array;1"] - .createInstance(Ci.nsIMutableArray); + var items = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray); - var sc = Cc["@mozilla.org/windows-jumplistshortcut;1"] - .createInstance(Ci.nsIJumpListShortcut); + var sc = Cc["@mozilla.org/windows-jumplistshortcut;1"].createInstance( + Ci.nsIJumpListShortcut + ); - var handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"] - .createInstance(Ci.nsILocalHandlerApp); + var handlerApp = Cc[ + "@mozilla.org/uriloader/local-handler-app;1" + ].createInstance(Ci.nsILocalHandlerApp); handlerApp.name = "Notepad"; handlerApp.detailedDescription = "Testing detailed description."; @@ -224,13 +286,12 @@ async function test_jumplist() { sc.app = handlerApp; items.appendElement(sc); - var removed = Cc["@mozilla.org/array;1"] - .createInstance(Ci.nsIMutableArray); + var removed = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray); Assert.ok(builder.initListBuild(removed)); Assert.ok(builder.addListToBuild(builder.JUMPLIST_CATEGORY_TASKS, items)); Assert.ok(builder.addListToBuild(builder.JUMPLIST_CATEGORY_RECENT)); Assert.ok(builder.addListToBuild(builder.JUMPLIST_CATEGORY_FREQUENT)); - let rv = new Promise((resolve) => { + let rv = new Promise(resolve => { builder.commitListBuild(resolve); }); Assert.ok(await rv); @@ -238,8 +299,14 @@ async function test_jumplist() { builder.deleteActiveList(); Assert.ok(builder.initListBuild(removed)); - Assert.ok(builder.addListToBuild(builder.JUMPLIST_CATEGORY_CUSTOMLIST, items, "Custom List")); - rv = new Promise((resolve) => { + Assert.ok( + builder.addListToBuild( + builder.JUMPLIST_CATEGORY_CUSTOMLIST, + items, + "Custom List" + ) + ); + rv = new Promise(resolve => { builder.commitListBuild(resolve); }); Assert.ok(await rv); diff --git a/widget/tests/utils.js b/widget/tests/utils.js index 3796c7d2b607..d2d68ce8d3d3 100644 --- a/widget/tests/utils.js +++ b/widget/tests/utils.js @@ -1,7 +1,7 @@ - function getTestPlugin(pluginName) { - var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] - .getService(SpecialPowers.Ci.nsIPluginHost); + var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"].getService( + SpecialPowers.Ci.nsIPluginHost + ); var tags = ph.getPluginTags(); var name = pluginName || "Test Plug-in"; for (var tag of tags) {