From 9bfa78108111efbd7cc7764c03b4b515d9c0f69f Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Thu, 17 Dec 2015 18:31:08 +0000 Subject: [PATCH] Bug 1233470 - make browser/modules eslintable, r=Mossop --- .eslintignore | 1 - browser/modules/BrowserUITelemetry.jsm | 8 +- browser/modules/Chat.jsm | 4 +- browser/modules/ContentClick.jsm | 2 +- browser/modules/ContentObservers.jsm | 7 +- browser/modules/ContentSearch.jsm | 2 +- browser/modules/ContentWebRTC.jsm | 7 +- browser/modules/DirectoryLinksProvider.jsm | 8 +- browser/modules/ProcessHangMonitor.jsm | 7 +- browser/modules/Social.jsm | 4 +- browser/modules/WindowsPreviewPerTab.jsm | 7 +- browser/modules/moz.build | 5 +- .../browser_BrowserUITelemetry_buckets.js | 199 +++++++++--------- .../xpcshell/test_DirectoryLinksProvider.js | 76 +++---- toolkit/modules/AppConstants.jsm | 7 + 15 files changed, 179 insertions(+), 165 deletions(-) diff --git a/.eslintignore b/.eslintignore index 23f2b3968e1..b018017d15d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -83,7 +83,6 @@ browser/extensions/pdfjs/** browser/extensions/shumway/** browser/fuel/** browser/locales/** -browser/modules/** # Loop specific exclusions diff --git a/browser/modules/BrowserUITelemetry.jsm b/browser/modules/BrowserUITelemetry.jsm index e30fea1a476..0fca7117516 100644 --- a/browser/modules/BrowserUITelemetry.jsm +++ b/browser/modules/BrowserUITelemetry.jsm @@ -534,8 +534,12 @@ this.BrowserUITelemetry = { // items are in there. let paletteItems = CustomizableUI.getUnusedWidgets(aWindow.gNavToolbox.palette); - let defaultRemoved = [item.id for (item of paletteItems) - if (DEFAULT_ITEMS.indexOf(item.id) != -1)]; + let defaultRemoved = []; + for (item of paletteItems) { + if (DEFAULT_ITEMS.indexOf(item.id) != -1) { + defaultRemoved.push(item.id); + } + } result.defaultKept = defaultKept; result.defaultMoved = defaultMoved; diff --git a/browser/modules/Chat.jsm b/browser/modules/Chat.jsm index 30ac29224bf..6a827c1e026 100644 --- a/browser/modules/Chat.jsm +++ b/browser/modules/Chat.jsm @@ -70,7 +70,7 @@ var Chat = { // Make a new array instead of the live NodeList so this iterator can be // used for closing/deleting. - let chatboxes = [c for (c of chatbar.children)]; + let chatboxes = [...chatbar.children]; for (let chatbox of chatboxes) { yield chatbox; } @@ -244,7 +244,7 @@ var Chat = { // When the buttonSet is coming from an XML attribute, it will be a string. if (typeof buttonSet == "string") { - buttonSet = [for (button of buttonSet.split(",")) button.trim()]; + buttonSet = buttonSet.split(",").map(button => button.trim()); } // Make sure to keep the current set around. diff --git a/browser/modules/ContentClick.jsm b/browser/modules/ContentClick.jsm index 8b024eb8f04..9f717f1146e 100644 --- a/browser/modules/ContentClick.jsm +++ b/browser/modules/ContentClick.jsm @@ -64,7 +64,7 @@ var ContentClick = { // This part is based on handleLinkClick. var where = window.whereToOpenLink(json); if (where == "current") - return false; + return; // Todo(903022): code for where == save diff --git a/browser/modules/ContentObservers.jsm b/browser/modules/ContentObservers.jsm index ed3478375b9..64c644d302b 100644 --- a/browser/modules/ContentObservers.jsm +++ b/browser/modules/ContentObservers.jsm @@ -35,8 +35,11 @@ function getMessageManagerForWindow(aContentWindow) { try { // If e10s is disabled, this throws NS_NOINTERFACE for closed tabs. return ir.getInterface(Ci.nsIContentFrameMessageManager); - } catch(e if e.result == Cr.NS_NOINTERFACE) { - return null; + } catch(e) { + if (e.result == Cr.NS_NOINTERFACE) { + return null; + } + throw e; } } diff --git a/browser/modules/ContentSearch.jsm b/browser/modules/ContentSearch.jsm index 12e6ddbdee5..77c41de449c 100644 --- a/browser/modules/ContentSearch.jsm +++ b/browser/modules/ContentSearch.jsm @@ -212,7 +212,7 @@ this.ContentSearch = { let event = this._eventQueue.shift(); - return this._currentEventPromise = Task.spawn(function* () { + this._currentEventPromise = Task.spawn(function* () { try { yield this["_on" + event.type](event.data); } catch (err) { diff --git a/browser/modules/ContentWebRTC.jsm b/browser/modules/ContentWebRTC.jsm index 2e57f309fd7..3f0fe220bc0 100644 --- a/browser/modules/ContentWebRTC.jsm +++ b/browser/modules/ContentWebRTC.jsm @@ -337,8 +337,11 @@ function getMessageManagerForWindow(aContentWindow) { try { // If e10s is disabled, this throws NS_NOINTERFACE for closed tabs. return ir.getInterface(Ci.nsIContentFrameMessageManager); - } catch(e if e.result == Cr.NS_NOINTERFACE) { - return null; + } catch(e) { + if (e.result == Cr.NS_NOINTERFACE) { + return null; + } + throw e; } } diff --git a/browser/modules/DirectoryLinksProvider.jsm b/browser/modules/DirectoryLinksProvider.jsm index cf0a9726a74..422d1f3d8d8 100644 --- a/browser/modules/DirectoryLinksProvider.jsm +++ b/browser/modules/DirectoryLinksProvider.jsm @@ -773,7 +773,7 @@ var DirectoryLinksProvider = { RemoteNewTabUtils.links.addObserver(this); } - return Task.spawn(function() { + return Task.spawn(function*() { // get the last modified time of the links file if it exists let doesFileExists = yield OS.File.exists(this._directoryFilePath); if (doesFileExists) { @@ -916,7 +916,7 @@ var DirectoryLinksProvider = { if (!sortedLinks) { // If NewTabUtils.links.resetCache() is called before getting here, // sortedLinks may be undefined. - return; + return undefined; } // Delete the current suggested tile, if one exists. @@ -939,7 +939,7 @@ var DirectoryLinksProvider = { // There are no potential suggested links we can show or not // enough history for a suggested tile, or suggested tile was // recently blocked and wait time interval has not decayed yet - return; + return undefined; } // Create a flat list of all possible links we can show as suggested. @@ -994,7 +994,7 @@ var DirectoryLinksProvider = { // We might have run out of possible links to show let numLinks = possibleLinks.size; if (numLinks == 0) { - return; + return undefined; } let flattenedLinks = [...possibleLinks.values()]; diff --git a/browser/modules/ProcessHangMonitor.jsm b/browser/modules/ProcessHangMonitor.jsm index b7ff0a54892..9cd502e2e5b 100644 --- a/browser/modules/ProcessHangMonitor.jsm +++ b/browser/modules/ProcessHangMonitor.jsm @@ -11,6 +11,7 @@ var Cu = Components.utils; this.EXPORTED_SYMBOLS = ["ProcessHangMonitor"]; +Cu.import("resource://gre/modules/AppConstants.jsm"); Cu.import("resource://gre/modules/Services.jsm"); /** @@ -176,7 +177,7 @@ var ProcessHangMonitor = { handleUserInput: function(win, func) { let report = this.findActiveReport(win.gBrowser.selectedBrowser); if (!report) { - return; + return null; } this.removeActiveReport(report); @@ -322,8 +323,7 @@ var ProcessHangMonitor = { } }]; -#ifdef MOZ_DEV_EDITION - if (report.hangType == report.SLOW_SCRIPT) { + if (AppConstants.MOZ_DEV_EDITION && report.hangType == report.SLOW_SCRIPT) { buttons.push({ label: bundle.getString("processHang.button_debug.label"), accessKey: bundle.getString("processHang.button_debug.accessKey"), @@ -332,7 +332,6 @@ var ProcessHangMonitor = { } }); } -#endif nb.appendNotification(bundle.getString("processHang.label"), "process-hang", diff --git a/browser/modules/Social.jsm b/browser/modules/Social.jsm index a7725335e12..0c46c4dd6a8 100644 --- a/browser/modules/Social.jsm +++ b/browser/modules/Social.jsm @@ -137,7 +137,9 @@ this.Social = { }, _updateWorkerState: function(enable) { - [p.enabled = enable for (p of Social.providers) if (p.enabled != enable)]; + for (let p of Social.providers) { + p.enabled = enable; + } }, // Called to update our cache of providers and set the current provider diff --git a/browser/modules/WindowsPreviewPerTab.jsm b/browser/modules/WindowsPreviewPerTab.jsm index 4bcd4aac247..44a15d9a8d6 100644 --- a/browser/modules/WindowsPreviewPerTab.jsm +++ b/browser/modules/WindowsPreviewPerTab.jsm @@ -543,7 +543,12 @@ TabWindow.prototype = { // Previews are internally stored using a map, so we need to iterate the // tabbrowser's array of tabs to retrieve previews in the same order. - let inorder = [previews.get(t) for (t of tabs) if (previews.has(t))]; + let inorder = []; + for (let t of tabs) { + if (previews.has(t)) { + inorder.push(previews.get(t)); + } + } // Since the internal taskbar array has not yet been updated we must force // on it the sorting order of our local array. To do so we must walk diff --git a/browser/modules/moz.build b/browser/modules/moz.build index 0db924f191b..f42f8b8894f 100644 --- a/browser/modules/moz.build +++ b/browser/modules/moz.build @@ -33,6 +33,7 @@ EXTRA_JS_MODULES += [ 'offlineAppCache.jsm', 'PanelFrame.jsm', 'PluginContent.jsm', + 'ProcessHangMonitor.jsm', 'ReaderParent.jsm', 'RecentWindow.jsm', 'RemotePrompt.jsm', @@ -46,10 +47,6 @@ EXTRA_JS_MODULES += [ 'webrtcUI.jsm', ] -EXTRA_PP_JS_MODULES += [ - 'ProcessHangMonitor.jsm' -] - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': EXTRA_JS_MODULES += [ 'Windows8WindowFrameColor.jsm', diff --git a/browser/modules/test/browser_BrowserUITelemetry_buckets.js b/browser/modules/test/browser_BrowserUITelemetry_buckets.js index 6daf687e037..f5576170501 100644 --- a/browser/modules/test/browser_BrowserUITelemetry_buckets.js +++ b/browser/modules/test/browser_BrowserUITelemetry_buckets.js @@ -1,102 +1,97 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* - WHERE'S MAH BUCKET?! - \ - ___ - .-9 9 `\ - =(:(::)= ; - |||| \ - |||| `-. - ,\|\| `, - / \ - ; `'---., - | `\ - ; / | - \ | / - ) \ __,.--\ / - .-' \,..._\ \` .-' .-' - `-=`` `: | /-/-/` - `.__/ -*/ - -"use strict"; - - -function generatorTest() { - let s = {}; - Components.utils.import("resource:///modules/BrowserUITelemetry.jsm", s); - let BUIT = s.BrowserUITelemetry; - - registerCleanupFunction(function() { - BUIT.setBucket(null); - }); - - - // setBucket - is(BUIT.currentBucket, BUIT.BUCKET_DEFAULT, "Bucket should be default bucket"); - BUIT.setBucket("mah-bucket"); - is(BUIT.currentBucket, BUIT.BUCKET_PREFIX + "mah-bucket", "Bucket should have correct name"); - BUIT.setBucket(null); - is(BUIT.currentBucket, BUIT.BUCKET_DEFAULT, "Bucket should be reset to default"); - - - // _toTimeStr - is(BUIT._toTimeStr(10), "10ms", "Checking time string reprentation, 10ms"); - is(BUIT._toTimeStr(1000 + 10), "1s10ms", "Checking time string reprentation, 1s10ms"); - is(BUIT._toTimeStr((20 * 1000) + 10), "20s10ms", "Checking time string reprentation, 20s10ms"); - is(BUIT._toTimeStr(60 * 1000), "1m", "Checking time string reprentation, 1m"); - is(BUIT._toTimeStr(3 * 60 * 1000), "3m", "Checking time string reprentation, 3m"); - is(BUIT._toTimeStr((3 * 60 * 1000) + 1), "3m1ms", "Checking time string reprentation, 3m1ms"); - is(BUIT._toTimeStr((60 * 60 * 1000) + (10 * 60 * 1000)), "1h10m", "Checking time string reprentation, 1h10m"); - is(BUIT._toTimeStr(100 * 60 * 60 * 1000), "100h", "Checking time string reprentation, 100h"); - - - // setExpiringBucket - BUIT.setExpiringBucket("walrus", [1001, 2001, 3001, 10001]); - is(BUIT.currentBucket, BUIT.BUCKET_PREFIX + "walrus" + BUIT.BUCKET_SEPARATOR + "1s1ms", - "Bucket should be expiring and have time step of 1s1ms"); - - waitForCondition(function() { - return BUIT.currentBucket == (BUIT.BUCKET_PREFIX + "walrus" + BUIT.BUCKET_SEPARATOR + "2s1ms"); - }, nextStep, "Bucket should be expiring and have time step of 2s1ms"); - yield undefined; - - waitForCondition(function() { - return BUIT.currentBucket == (BUIT.BUCKET_PREFIX + "walrus" + BUIT.BUCKET_SEPARATOR + "3s1ms"); - }, nextStep, "Bucket should be expiring and have time step of 3s1ms"); - yield undefined; - - - // Interupt previous expiring bucket - BUIT.setExpiringBucket("walrus2", [1002, 2002]); - is(BUIT.currentBucket, BUIT.BUCKET_PREFIX + "walrus2" + BUIT.BUCKET_SEPARATOR + "1s2ms", - "Should be new expiring bucket, with time step of 1s2ms"); - - waitForCondition(function() { - return BUIT.currentBucket == (BUIT.BUCKET_PREFIX + "walrus2" + BUIT.BUCKET_SEPARATOR + "2s2ms"); - }, nextStep, "Should be new expiring bucket, with time step of 2s2ms"); - yield undefined; - - - // Let expiring bucket expire - waitForCondition(function() { - return BUIT.currentBucket == BUIT.BUCKET_DEFAULT; - }, nextStep, "Bucket should have expired, default bucket should now be active"); - yield undefined; - - - // Interupt expiring bucket with normal bucket - BUIT.setExpiringBucket("walrus3", [1003, 2003]); - is(BUIT.currentBucket, BUIT.BUCKET_PREFIX + "walrus3" + BUIT.BUCKET_SEPARATOR + "1s3ms", - "Should be new expiring bucket, with time step of 1s3ms"); - - BUIT.setBucket("mah-bucket"); - is(BUIT.currentBucket, BUIT.BUCKET_PREFIX + "mah-bucket", "Bucket should have correct name"); - - waitForCondition(function() { - return BUIT.currentBucket == (BUIT.BUCKET_PREFIX + "mah-bucket"); - }, nextStep, "Next step of old expiring bucket shouldn't have progressed"); - yield undefined; -} +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* + WHERE'S MAH BUCKET?! + \ + ___ + .-9 9 `\ + =(:(::)= ; + |||| \ + |||| `-. + ,\|\| `, + / \ + ; `'---., + | `\ + ; / | + \ | / + ) \ __,.--\ / + .-' \,..._\ \` .-' .-' + `-=`` `: | /-/-/` + `.__/ +*/ + +"use strict"; + + +add_task(function* testBUIT() { + let s = {}; + Components.utils.import("resource:///modules/BrowserUITelemetry.jsm", s); + let BUIT = s.BrowserUITelemetry; + + registerCleanupFunction(function() { + BUIT.setBucket(null); + }); + + + // setBucket + is(BUIT.currentBucket, BUIT.BUCKET_DEFAULT, "Bucket should be default bucket"); + BUIT.setBucket("mah-bucket"); + is(BUIT.currentBucket, BUIT.BUCKET_PREFIX + "mah-bucket", "Bucket should have correct name"); + BUIT.setBucket(null); + is(BUIT.currentBucket, BUIT.BUCKET_DEFAULT, "Bucket should be reset to default"); + + + // _toTimeStr + is(BUIT._toTimeStr(10), "10ms", "Checking time string reprentation, 10ms"); + is(BUIT._toTimeStr(1000 + 10), "1s10ms", "Checking time string reprentation, 1s10ms"); + is(BUIT._toTimeStr((20 * 1000) + 10), "20s10ms", "Checking time string reprentation, 20s10ms"); + is(BUIT._toTimeStr(60 * 1000), "1m", "Checking time string reprentation, 1m"); + is(BUIT._toTimeStr(3 * 60 * 1000), "3m", "Checking time string reprentation, 3m"); + is(BUIT._toTimeStr((3 * 60 * 1000) + 1), "3m1ms", "Checking time string reprentation, 3m1ms"); + is(BUIT._toTimeStr((60 * 60 * 1000) + (10 * 60 * 1000)), "1h10m", "Checking time string reprentation, 1h10m"); + is(BUIT._toTimeStr(100 * 60 * 60 * 1000), "100h", "Checking time string reprentation, 100h"); + + + // setExpiringBucket + BUIT.setExpiringBucket("walrus", [1001, 2001, 3001, 10001]); + is(BUIT.currentBucket, BUIT.BUCKET_PREFIX + "walrus" + BUIT.BUCKET_SEPARATOR + "1s1ms", + "Bucket should be expiring and have time step of 1s1ms"); + + yield waitForConditionPromise(function() { + return BUIT.currentBucket == (BUIT.BUCKET_PREFIX + "walrus" + BUIT.BUCKET_SEPARATOR + "2s1ms"); + }, "Bucket should be expiring and have time step of 2s1ms"); + + yield waitForConditionPromise(function() { + return BUIT.currentBucket == (BUIT.BUCKET_PREFIX + "walrus" + BUIT.BUCKET_SEPARATOR + "3s1ms"); + }, "Bucket should be expiring and have time step of 3s1ms"); + + + // Interupt previous expiring bucket + BUIT.setExpiringBucket("walrus2", [1002, 2002]); + is(BUIT.currentBucket, BUIT.BUCKET_PREFIX + "walrus2" + BUIT.BUCKET_SEPARATOR + "1s2ms", + "Should be new expiring bucket, with time step of 1s2ms"); + + yield waitForConditionPromise(function() { + return BUIT.currentBucket == (BUIT.BUCKET_PREFIX + "walrus2" + BUIT.BUCKET_SEPARATOR + "2s2ms"); + }, "Should be new expiring bucket, with time step of 2s2ms"); + + + // Let expiring bucket expire + yield waitForConditionPromise(function() { + return BUIT.currentBucket == BUIT.BUCKET_DEFAULT; + }, "Bucket should have expired, default bucket should now be active"); + + + // Interupt expiring bucket with normal bucket + BUIT.setExpiringBucket("walrus3", [1003, 2003]); + is(BUIT.currentBucket, BUIT.BUCKET_PREFIX + "walrus3" + BUIT.BUCKET_SEPARATOR + "1s3ms", + "Should be new expiring bucket, with time step of 1s3ms"); + + BUIT.setBucket("mah-bucket"); + is(BUIT.currentBucket, BUIT.BUCKET_PREFIX + "mah-bucket", "Bucket should have correct name"); + + yield waitForConditionPromise(function() { + return BUIT.currentBucket == (BUIT.BUCKET_PREFIX + "mah-bucket"); + }, "Next step of old expiring bucket shouldn't have progressed"); +}); diff --git a/browser/modules/test/xpcshell/test_DirectoryLinksProvider.js b/browser/modules/test/xpcshell/test_DirectoryLinksProvider.js index 4ba076912a5..803cf10e607 100644 --- a/browser/modules/test/xpcshell/test_DirectoryLinksProvider.js +++ b/browser/modules/test/xpcshell/test_DirectoryLinksProvider.js @@ -200,7 +200,7 @@ function promiseDirectoryDownloadOnPrefChange(pref, newValue) { } function promiseSetupDirectoryLinksProvider(options = {}) { - return Task.spawn(function() { + return Task.spawn(function*() { let linksURL = options.linksURL || kTestURL; yield DirectoryLinksProvider.init(); yield promiseDirectoryDownloadOnPrefChange(kLocalePref, options.locale || "en-US"); @@ -211,7 +211,7 @@ function promiseSetupDirectoryLinksProvider(options = {}) { } function promiseCleanDirectoryLinksProvider() { - return Task.spawn(function() { + return Task.spawn(function*() { yield promiseDirectoryDownloadOnPrefChange(kLocalePref, "en-US"); yield promiseDirectoryDownloadOnPrefChange(kSourceUrlPref, kTestURL); yield DirectoryLinksProvider._clearFrequencyCap(); @@ -292,7 +292,7 @@ add_task(function test_shouldUpdateSuggestedTile() { DirectoryLinksProvider._getCurrentTopSiteCount = origCurrentTopSiteCount; }); -add_task(function test_updateSuggestedTile() { +add_task(function* test_updateSuggestedTile() { let topSites = ["site0.com", "1040.com", "site2.com", "hrblock.com", "site4.com", "freetaxusa.com", "site6.com"]; // Initial setup @@ -421,7 +421,7 @@ add_task(function test_updateSuggestedTile() { DirectoryLinksProvider._getCurrentTopSiteCount = origCurrentTopSiteCount; }); -add_task(function test_suggestedLinksMap() { +add_task(function* test_suggestedLinksMap() { let data = {"suggested": [suggestedTile1, suggestedTile2, suggestedTile3, suggestedTile4], "directory": [someOtherSite]}; let dataURI = 'data:application/json,' + JSON.stringify(data); @@ -460,7 +460,7 @@ add_task(function test_suggestedLinksMap() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_topSitesWithSuggestedLinks() { +add_task(function* test_topSitesWithSuggestedLinks() { let topSites = ["site0.com", "1040.com", "site2.com", "hrblock.com", "site4.com", "freetaxusa.com", "site6.com"]; let origIsTopPlacesSite = NewTabUtils.isTopPlacesSite; NewTabUtils.isTopPlacesSite = function(site) { @@ -512,7 +512,7 @@ add_task(function test_topSitesWithSuggestedLinks() { NewTabUtils.getProviderLinks = origGetProviderLinks; }); -add_task(function test_suggestedAttributes() { +add_task(function* test_suggestedAttributes() { let origIsTopPlacesSite = NewTabUtils.isTopPlacesSite; NewTabUtils.isTopPlacesSite = () => true; @@ -569,7 +569,7 @@ add_task(function test_suggestedAttributes() { DirectoryLinksProvider.removeObserver(gLinks); }); -add_task(function test_frequencyCappedSites_views() { +add_task(function* test_frequencyCappedSites_views() { Services.prefs.setCharPref(kPingUrlPref, ""); let origIsTopPlacesSite = NewTabUtils.isTopPlacesSite; NewTabUtils.isTopPlacesSite = () => true; @@ -646,7 +646,7 @@ add_task(function test_frequencyCappedSites_views() { Services.prefs.setCharPref(kPingUrlPref, kPingUrl); }); -add_task(function test_frequencyCappedSites_click() { +add_task(function* test_frequencyCappedSites_click() { Services.prefs.setCharPref(kPingUrlPref, ""); let origIsTopPlacesSite = NewTabUtils.isTopPlacesSite; NewTabUtils.isTopPlacesSite = () => true; @@ -716,7 +716,7 @@ add_task(function test_frequencyCappedSites_click() { Services.prefs.setCharPref(kPingUrlPref, kPingUrl); }); -add_task(function test_reportSitesAction() { +add_task(function* test_reportSitesAction() { yield DirectoryLinksProvider.init(); let deferred, expectedPath, expectedPost; let done = false; @@ -823,7 +823,7 @@ add_task(function test_reportSitesAction() { done = true; }); -add_task(function test_fetchAndCacheLinks_local() { +add_task(function* test_fetchAndCacheLinks_local() { yield DirectoryLinksProvider.init(); yield cleanJsonFile(); // Trigger cache of data or chrome uri files in profD @@ -832,7 +832,7 @@ add_task(function test_fetchAndCacheLinks_local() { isIdentical(data, kURLData); }); -add_task(function test_fetchAndCacheLinks_remote() { +add_task(function* test_fetchAndCacheLinks_remote() { yield DirectoryLinksProvider.init(); yield cleanJsonFile(); // this must trigger directory links json download and save it to cache file @@ -842,7 +842,7 @@ add_task(function test_fetchAndCacheLinks_remote() { isIdentical(data, kHttpHandlerData[kExamplePath]); }); -add_task(function test_fetchAndCacheLinks_malformedURI() { +add_task(function* test_fetchAndCacheLinks_malformedURI() { yield DirectoryLinksProvider.init(); yield cleanJsonFile(); let someJunk = "some junk"; @@ -858,7 +858,7 @@ add_task(function test_fetchAndCacheLinks_malformedURI() { isIdentical(data, ""); }); -add_task(function test_fetchAndCacheLinks_unknownHost() { +add_task(function* test_fetchAndCacheLinks_unknownHost() { yield DirectoryLinksProvider.init(); yield cleanJsonFile(); let nonExistentServer = "http://localhost:56789/"; @@ -874,7 +874,7 @@ add_task(function test_fetchAndCacheLinks_unknownHost() { isIdentical(data, ""); }); -add_task(function test_fetchAndCacheLinks_non200Status() { +add_task(function* test_fetchAndCacheLinks_non200Status() { yield DirectoryLinksProvider.init(); yield cleanJsonFile(); yield promiseDirectoryDownloadOnPrefChange(kSourceUrlPref, kFailURL); @@ -884,7 +884,7 @@ add_task(function test_fetchAndCacheLinks_non200Status() { }); // To test onManyLinksChanged observer, trigger a fetch -add_task(function test_DirectoryLinksProvider__linkObservers() { +add_task(function* test_DirectoryLinksProvider__linkObservers() { yield DirectoryLinksProvider.init(); let testObserver = new LinksChangeObserver(); @@ -899,7 +899,7 @@ add_task(function test_DirectoryLinksProvider__linkObservers() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider__prefObserver_url() { +add_task(function* test_DirectoryLinksProvider__prefObserver_url() { yield promiseSetupDirectoryLinksProvider({linksURL: kTestURL}); let links = yield fetchData(); @@ -928,7 +928,7 @@ add_task(function test_DirectoryLinksProvider__prefObserver_url() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider_getLinks_noDirectoryData() { +add_task(function* test_DirectoryLinksProvider_getLinks_noDirectoryData() { let data = { "directory": [], }; @@ -940,7 +940,7 @@ add_task(function test_DirectoryLinksProvider_getLinks_noDirectoryData() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider_getLinks_badData() { +add_task(function* test_DirectoryLinksProvider_getLinks_badData() { let data = { "en-US": { "en-US": [{url: "http://example.com", title: "US"}], @@ -966,7 +966,7 @@ add_task(function test_DirectoryLinksProvider_needsDownload() { DirectoryLinksProvider._lastDownloadMS = 0; }); -add_task(function test_DirectoryLinksProvider_fetchAndCacheLinksIfNecessary() { +add_task(function* test_DirectoryLinksProvider_fetchAndCacheLinksIfNecessary() { yield DirectoryLinksProvider.init(); yield cleanJsonFile(); // explicitly change source url to cause the download during setup @@ -1008,7 +1008,7 @@ add_task(function test_DirectoryLinksProvider_fetchAndCacheLinksIfNecessary() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider_fetchDirectoryOnPrefChange() { +add_task(function* test_DirectoryLinksProvider_fetchDirectoryOnPrefChange() { yield DirectoryLinksProvider.init(); let testObserver = new LinksChangeObserver(); @@ -1029,7 +1029,7 @@ add_task(function test_DirectoryLinksProvider_fetchDirectoryOnPrefChange() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider_fetchDirectoryOnShow() { +add_task(function* test_DirectoryLinksProvider_fetchDirectoryOnShow() { yield promiseSetupDirectoryLinksProvider(); // set lastdownload to 0 to make DirectoryLinksProvider want to download @@ -1043,7 +1043,7 @@ add_task(function test_DirectoryLinksProvider_fetchDirectoryOnShow() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider_fetchDirectoryOnInit() { +add_task(function* test_DirectoryLinksProvider_fetchDirectoryOnInit() { // ensure preferences are set to defaults yield promiseSetupDirectoryLinksProvider(); // now clean to provider, so we can init it again @@ -1057,7 +1057,7 @@ add_task(function test_DirectoryLinksProvider_fetchDirectoryOnInit() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider_getLinksFromCorruptedFile() { +add_task(function* test_DirectoryLinksProvider_getLinksFromCorruptedFile() { yield promiseSetupDirectoryLinksProvider(); // write bogus json to a file and attempt to fetch from it @@ -1069,7 +1069,7 @@ add_task(function test_DirectoryLinksProvider_getLinksFromCorruptedFile() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider_getAllowedLinks() { +add_task(function* test_DirectoryLinksProvider_getAllowedLinks() { let data = {"directory": [ {url: "ftp://example.com"}, {url: "http://example.net"}, @@ -1090,7 +1090,7 @@ add_task(function test_DirectoryLinksProvider_getAllowedLinks() { do_check_eq(links[1].url, data["directory"][3].url); }); -add_task(function test_DirectoryLinksProvider_getAllowedImages() { +add_task(function* test_DirectoryLinksProvider_getAllowedImages() { let data = {"directory": [ {url: "http://example.com", imageURI: "ftp://example.com"}, {url: "http://example.com", imageURI: "http://example.net"}, @@ -1111,7 +1111,7 @@ add_task(function test_DirectoryLinksProvider_getAllowedImages() { do_check_eq(links[1].imageURI, data["directory"][5].imageURI); }); -add_task(function test_DirectoryLinksProvider_getAllowedImages_base() { +add_task(function* test_DirectoryLinksProvider_getAllowedImages_base() { let data = {"directory": [ {url: "http://example1.com", imageURI: "https://example.com"}, {url: "http://example2.com", imageURI: "https://tiles.cdn.mozilla.net"}, @@ -1135,7 +1135,7 @@ add_task(function test_DirectoryLinksProvider_getAllowedImages_base() { do_check_eq(links[3].url, data["directory"][4].url); }); -add_task(function test_DirectoryLinksProvider_getAllowedEnhancedImages() { +add_task(function* test_DirectoryLinksProvider_getAllowedEnhancedImages() { let data = {"directory": [ {url: "http://example.com", enhancedImageURI: "ftp://example.com"}, {url: "http://example.com", enhancedImageURI: "http://example.net"}, @@ -1156,7 +1156,7 @@ add_task(function test_DirectoryLinksProvider_getAllowedEnhancedImages() { do_check_eq(links[1].enhancedImageURI, data["directory"][5].enhancedImageURI); }); -add_task(function test_DirectoryLinksProvider_getEnhancedLink() { +add_task(function* test_DirectoryLinksProvider_getEnhancedLink() { let data = {"enhanced": [ {url: "http://example.net", enhancedImageURI: "data:,net1"}, {url: "http://example.com", enhancedImageURI: "data:,com1"}, @@ -1208,7 +1208,7 @@ add_task(function test_DirectoryLinksProvider_getEnhancedLink() { checkEnhanced("http://example.com", "data:,fresh"); }); -add_task(function test_DirectoryLinksProvider_enhancedURIs() { +add_task(function* test_DirectoryLinksProvider_enhancedURIs() { let origIsTopPlacesSite = NewTabUtils.isTopPlacesSite; NewTabUtils.isTopPlacesSite = () => true; let origCurrentTopSiteCount = DirectoryLinksProvider._getCurrentTopSiteCount; @@ -1279,7 +1279,7 @@ add_task(function test_DirectoryLinksProvider_setDefaultEnhanced() { Services.prefs.clearUserPref("privacy.donottrackheader.value"); }); -add_task(function test_timeSensetiveSuggestedTiles() { +add_task(function* test_timeSensetiveSuggestedTiles() { // make tile json with start and end dates let testStartTime = Date.now(); // start date is now + 1 seconds @@ -1450,7 +1450,7 @@ add_task(function test_setupStartEndTime() { do_check_false(link.startTime); }); -add_task(function test_DirectoryLinksProvider_frequencyCapSetup() { +add_task(function* test_DirectoryLinksProvider_frequencyCapSetup() { yield promiseSetupDirectoryLinksProvider(); yield DirectoryLinksProvider.init(); @@ -1526,7 +1526,7 @@ add_task(function test_DirectoryLinksProvider_frequencyCapSetup() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider_getFrequencyCapLogic() { +add_task(function* test_DirectoryLinksProvider_getFrequencyCapLogic() { yield promiseSetupDirectoryLinksProvider(); yield DirectoryLinksProvider.init(); @@ -1577,7 +1577,7 @@ add_task(function test_DirectoryLinksProvider_getFrequencyCapLogic() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider_getFrequencyCapReportSiteAction() { +add_task(function* test_DirectoryLinksProvider_getFrequencyCapReportSiteAction() { yield promiseSetupDirectoryLinksProvider(); yield DirectoryLinksProvider.init(); @@ -1605,7 +1605,7 @@ add_task(function test_DirectoryLinksProvider_getFrequencyCapReportSiteAction() yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_DirectoryLinksProvider_ClickRemoval() { +add_task(function* test_DirectoryLinksProvider_ClickRemoval() { yield promiseSetupDirectoryLinksProvider(); yield DirectoryLinksProvider.init(); let landingUrl = "http://foo.com"; @@ -1709,7 +1709,7 @@ add_task(function test_DirectoryLinksProvider_anonymous() { do_check_true(DirectoryLinksProvider._newXHR().mozAnon); }); -add_task(function test_sanitizeExplanation() { +add_task(function* test_sanitizeExplanation() { // Note: this is a basic test to ensure we applied sanitization to the link explanation. // Full testing for appropriate sanitization is done in parser/xml/test/unit/test_sanitizer.js. let data = {"suggested": [suggestedTile5]}; @@ -1727,7 +1727,7 @@ add_task(function test_sanitizeExplanation() { do_check_eq(suggestedLink.targetedName, "WE ARE EVIL "); }); -add_task(function test_inadjecentSites() { +add_task(function* test_inadjecentSites() { let suggestedTile = Object.assign({ check_inadjacency: true }, suggestedTile1); @@ -1901,7 +1901,7 @@ add_task(function test_inadjecentSites() { yield promiseCleanDirectoryLinksProvider(); }); -add_task(function test_reportPastImpressions() { +add_task(function* test_reportPastImpressions() { let origIsTopPlacesSite = NewTabUtils.isTopPlacesSite; NewTabUtils.isTopPlacesSite = () => true; let origCurrentTopSiteCount = DirectoryLinksProvider._getCurrentTopSiteCount; @@ -2005,7 +2005,7 @@ add_task(function test_reportPastImpressions() { DirectoryLinksProvider._getCurrentTopSiteCount = origCurrentTopSiteCount; }); -add_task(function test_blockSuggestedTiles() { +add_task(function* test_blockSuggestedTiles() { // Initial setup let suggestedTile = suggestedTile1; let topSites = ["site0.com", "1040.com", "site2.com", "hrblock.com", "site4.com", "freetaxusa.com", "site6.com"]; diff --git a/toolkit/modules/AppConstants.jsm b/toolkit/modules/AppConstants.jsm index 126707556c3..8c802cd5bd3 100644 --- a/toolkit/modules/AppConstants.jsm +++ b/toolkit/modules/AppConstants.jsm @@ -52,6 +52,13 @@ this.AppConstants = Object.freeze({ false, #endif + MOZ_DEV_EDITION: +#ifdef MOZ_DEV_EDITION + true, +#else + false, +#endif + MOZ_SERVICES_HEALTHREPORT: #ifdef MOZ_SERVICES_HEALTHREPORT true,