diff --git a/.eslintignore b/.eslintignore index 9c53635d1dcc..51bba90ec978 100644 --- a/.eslintignore +++ b/.eslintignore @@ -193,6 +193,7 @@ toolkit/modules/tests/xpcshell/test_task.js toolkit/components/osfile/** # External code: +toolkit/components/microformats/test/** toolkit/components/reader/Readability.js toolkit/components/reader/JSDOMParser.js diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index bacacf638d3c..6498722fafaf 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -304,7 +304,7 @@ pref("browser.urlbar.matchBehavior", 1); pref("browser.urlbar.filter.javascript", true); // the maximum number of results to show in autocomplete when doing richResults -pref("browser.urlbar.maxRichResults", 12); +pref("browser.urlbar.maxRichResults", 10); // The amount of time (ms) to wait after the user has stopped typing // before starting to perform autocomplete. 50 is the default set in // autocomplete.xml. diff --git a/browser/base/content/browser-addons.js b/browser/base/content/browser-addons.js index b0ee29f1f704..1a8c260d5948 100644 --- a/browser/base/content/browser-addons.js +++ b/browser/base/content/browser-addons.js @@ -660,6 +660,7 @@ var LightweightThemeListener = { if (sheet.href == "chrome://browser/skin/browser-lightweightTheme.css") return sheet; } + return undefined; }); Services.obs.addObserver(this, "lightweight-theme-styling-update", false); diff --git a/browser/base/content/browser-plugins.js b/browser/base/content/browser-plugins.js index e82161a96a26..4e3d056e9c6a 100644 --- a/browser/base/content/browser-plugins.js +++ b/browser/base/content/browser-plugins.js @@ -11,7 +11,6 @@ var gPluginHandler = { "PluginContent:RemoveNotification", "PluginContent:UpdateHiddenPluginUI", "PluginContent:HideNotificationBar", - "PluginContent:ShowInstallNotification", "PluginContent:InstallSinglePlugin", "PluginContent:ShowPluginCrashedNotification", "PluginContent:SubmitReport", @@ -56,8 +55,6 @@ var gPluginHandler = { case "PluginContent:HideNotificationBar": this.hideNotificationBar(msg.target, msg.data.name); break; - case "PluginContent:ShowInstallNotification": - return this.showInstallNotification(msg.target, msg.data.pluginInfo); case "PluginContent:InstallSinglePlugin": this.installSinglePlugin(msg.data.pluginInfo); break; diff --git a/browser/base/content/browser-syncui.js b/browser/base/content/browser-syncui.js index dc513a6cbe8f..ea4c51538e01 100644 --- a/browser/base/content/browser-syncui.js +++ b/browser/base/content/browser-syncui.js @@ -251,7 +251,7 @@ var gSyncUI = { if (needsSetup || this._loginFailed()) { this.openSetup(); } else { - return this.doSync(); + this.doSync(); } }).catch(err => { this.log.error("Failed to handle toolbar button command", err); diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 20d515ab9c9a..8e8c67129987 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3387,7 +3387,7 @@ const DOMLinkHandler = { addSearch: function(aBrowser, aEngine, aURL) { let tab = gBrowser.getTabForBrowser(aBrowser); if (!tab) - return false; + return; BrowserSearch.addEngine(aBrowser, aEngine, makeURI(aURL)); }, diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 3f9ab642ea92..647f0fc93c64 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -698,7 +698,7 @@ showcommentcolumn="true" showimagecolumn="true" enablehistory="true" - maxrows="6" + maxrows="10" newlines="stripsurroundingwhitespace" ontextentered="this.handleCommand(param);" ontextreverted="return this.handleRevert();" diff --git a/browser/base/content/pageinfo/pageInfo.js b/browser/base/content/pageinfo/pageInfo.js index 07b8f922b436..096d3c66251e 100644 --- a/browser/base/content/pageinfo/pageInfo.js +++ b/browser/base/content/pageinfo/pageInfo.js @@ -268,6 +268,7 @@ function getClipboardHelper() { return Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper); } catch(e) { // do nothing, later code will handle the error + return null; } } const gClipboardHelper = getClipboardHelper(); diff --git a/browser/base/content/sanitize.js b/browser/base/content/sanitize.js index e330cfd73270..0eaa57e9f66f 100644 --- a/browser/base/content/sanitize.js +++ b/browser/base/content/sanitize.js @@ -603,6 +603,7 @@ Sanitizer.prototype = { aWindow.skipNextCanClose = true; return true; } + return false; }, _resetAllWindowClosures: function(aWindowList) { for (let win of aWindowList) { @@ -665,6 +666,7 @@ Sanitizer.prototype = { e.stopPropagation(); return false; } + return undefined; } newWindow.addEventListener("fullscreen", onFullScreen); } diff --git a/browser/base/content/sync/genericChange.js b/browser/base/content/sync/genericChange.js index 08cd086e4d44..f7afdef1aa1a 100644 --- a/browser/base/content/sync/genericChange.js +++ b/browser/base/content/sync/genericChange.js @@ -147,6 +147,7 @@ var Change = { return this.doChangePassword(); break; } + return undefined; }, doGeneratePassphrase: function () { diff --git a/browser/base/content/sync/setup.js b/browser/base/content/sync/setup.js index 568a50fcf48b..d5e460f40e26 100644 --- a/browser/base/content/sync/setup.js +++ b/browser/base/content/sync/setup.js @@ -123,14 +123,14 @@ var gSyncSetup = { startNewAccountSetup: function () { if (!Weave.Utils.ensureMPUnlocked()) - return false; + return; this._settingUpNew = true; this.wizard.pageIndex = NEW_ACCOUNT_START_PAGE; }, useExistingAccount: function () { if (!Weave.Utils.ensureMPUnlocked()) - return false; + return; this._settingUpNew = false; if (this.wizardType == "pair") { // We're already pairing, so there's no point in pairing again. diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index b02f25ed835b..6197233ba182 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -1824,6 +1824,99 @@ + + + + + + into the DOM if necessary. + if (!notificationbox.parentNode) { + // NB: this appendChild call causes us to run constructors for the + // browser element, which fires off a bunch of notifications. Some + // of those notifications can cause code to run that inspects our + // state, so it is important that the tab element is fully + // initialized by this point. + this.mPanelContainer.appendChild(notificationbox); + } + + // wire up a progress listener for the new browser object. + let tabListener = this.mTabProgressListener(aTab, browser, uriIsAboutBlank, usingPreloadedContent); + const filter = Cc["@mozilla.org/appshell/component/browser-status-filter;1"] + .createInstance(Ci.nsIWebProgress); + filter.addProgressListener(tabListener, Ci.nsIWebProgress.NOTIFY_ALL); + browser.webProgress.addProgressListener(filter, Ci.nsIWebProgress.NOTIFY_ALL); + this._tabListeners.set(aTab, tabListener); + this._tabFilters.set(aTab, filter); + + browser.droppedLinkHandler = handleDroppedLink; + + // We start our browsers out as inactive, and then maintain + // activeness in the tab switcher. + browser.docShellIsActive = false; + + // When addTab() is called with an URL that is not "about:blank" we + // set the "nodefaultsrc" attribute that prevents a frameLoader + // from being created as soon as the linked is inserted + // into the DOM. We thus have to register the new outerWindowID + // for non-remote browsers after we have called browser.loadURI(). + if (!remote) { + this._outerWindowIDBrowserMap.set(browser.outerWindowID, browser); + } + + return { usingPreloadedContent: usingPreloadedContent }; + ]]> + + + @@ -1833,6 +1926,8 @@ into the DOM if necessary. - if (!notificationbox.parentNode) { - // NB: this appendChild call causes us to run constructors for the - // browser element, which fires off a bunch of notifications. Some - // of those notifications can cause code to run that inspects our - // state, so it is important that the tab element is fully - // initialized by this point. - this.mPanelContainer.appendChild(notificationbox); - } - this.tabContainer.updateVisibility(); - // wire up a progress listener for the new browser object. - var tabListener = this.mTabProgressListener(t, b, uriIsAboutBlank, usingPreloadedContent); - const filter = Components.classes["@mozilla.org/appshell/component/browser-status-filter;1"] - .createInstance(Components.interfaces.nsIWebProgress); - filter.addProgressListener(tabListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); - b.webProgress.addProgressListener(filter, Components.interfaces.nsIWebProgress.NOTIFY_ALL); - this._tabListeners.set(t, tabListener); - this._tabFilters.set(t, filter); + let options = { + referrerURI : aReferrerURI, + referrerPolicy : aReferrerPolicy, + charset : aCharset, + postData : aPostData, + allowThirdPartyFixup : aAllowThirdPartyFixup, + fromExternal : aFromExternal, + allowMixedContent : aAllowMixedContent, + forceNotRemote : aForceNotRemote, + noReferrer : aNoReferrer, + userContextId : aUserContextId + }; - b.droppedLinkHandler = handleDroppedLink; + // Currently in this incarnation of bug 906076, we are forcing the + // browser to immediately be linked. In future incarnations of this + // bug this will be removed so we can leave the tab in its "lazy" + // state to be exploited for startup optimization. Note that for + // now this must occur before "TabOpen" event is fired, as that will + // trigger SessionStore.jsm to run code that expects the existence + // of tab.linkedBrowser. + let { usingPreloadedContent } = this._linkBrowserToTab(t, aURI, options); + let b = t.linkedBrowser; // Dispatch a new tab notification. We do this once we're // entirely done, so that things are in a consistent state @@ -2005,23 +2070,6 @@ } } - // We start our browsers out as inactive, and then maintain - // activeness in the tab switcher. - b.docShellIsActive = false; - - // When addTab() is called with an URL that is not "about:blank" we - // set the "nodefaultsrc" attribute that prevents a frameLoader - // from being created as soon as the linked is inserted - // into the DOM. We thus have to register the new outerWindowID - // for non-remote browsers after we have called browser.loadURI(). - // - // Note: Only do this of we still have a docShell. The TabOpen - // event was dispatched above and a gBrowser.removeTab() call from - // one of its listeners could cause us to fail here. - if (!remote && b.docShell) { - this._outerWindowIDBrowserMap.set(b.outerWindowID, b); - } - // Check if we're opening a tab related to the current tab and // move it to after the current tab. // aReferrerURI is null or undefined if the tab is opened from @@ -4266,6 +4314,7 @@ } } + return undefined; ]]> diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index f613a9d12efc..926132d22c6f 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -321,7 +321,7 @@ skip-if = !datareporting [browser_devices_get_user_media.js] skip-if = buildapp == 'mulet' || (os == "linux" && debug) # linux: bug 976544 [browser_devices_get_user_media_about_urls.js] -skip-if = e10s # Bug 1071623 +skip-if = e10s && debug [browser_devices_get_user_media_in_frame.js] [browser_discovery.js] [browser_double_close_tab.js] diff --git a/browser/base/content/test/general/browser_autocomplete_autoselect.js b/browser/base/content/test/general/browser_autocomplete_autoselect.js index dac78675a657..3cacf6475521 100644 --- a/browser/base/content/test/general/browser_autocomplete_autoselect.js +++ b/browser/base/content/test/general/browser_autocomplete_autoselect.js @@ -16,12 +16,14 @@ add_task(function*() { Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref); }); + let maxResults = Services.prefs.getIntPref("browser.urlbar.maxRichResults"); + registerCleanupFunction(function* () { yield PlacesTestUtils.clearHistory(); }); let visits = []; - repeat(10, i => { + repeat(maxResults, i => { visits.push({ uri: makeURI("http://example.com/autocomplete/?" + i), }); @@ -34,20 +36,20 @@ add_task(function*() { let popup = gURLBar.popup; let results = popup.richlistbox.children; - // 1 extra for the current search engine match - is(results.length, 11, "Should get 11 results"); + is(results.length, maxResults, + "Should get maxResults=" + maxResults + " results"); is_selected(0); info("Key Down to select the next item"); EventUtils.synthesizeKey("VK_DOWN", {}); is_selected(1); - info("Key Down 11 times should wrap around all the way around"); - repeat(11, () => EventUtils.synthesizeKey("VK_DOWN", {})); + info("Key Down maxResults times should wrap around all the way around"); + repeat(maxResults, () => EventUtils.synthesizeKey("VK_DOWN", {})); is_selected(1); - info("Key Up 11 times should wrap around the other way"); - repeat(11, () => EventUtils.synthesizeKey("VK_UP", {})); + info("Key Up maxResults times should wrap around the other way"); + repeat(maxResults, () => EventUtils.synthesizeKey("VK_UP", {})); is_selected(1); info("Page Up will go up the list, but not wrap"); @@ -56,7 +58,7 @@ add_task(function*() { info("Page Up again will wrap around to the end of the list"); EventUtils.synthesizeKey("VK_PAGE_UP", {}) - is_selected(10); + is_selected(maxResults - 1); EventUtils.synthesizeKey("VK_ESCAPE", {}); yield promisePopupHidden(gURLBar.popup); diff --git a/browser/base/content/test/general/browser_contextmenu.js b/browser/base/content/test/general/browser_contextmenu.js index b888b224f654..308a2d992ed6 100644 --- a/browser/base/content/test/general/browser_contextmenu.js +++ b/browser/base/content/test/general/browser_contextmenu.js @@ -11,6 +11,8 @@ let LOGIN_FILL_ITEMS = [ ], null, ]; +let hasPocket = Services.prefs.getBoolPref("extensions.pocket.enabled"); + add_task(function* test_setup() { const example_base = "http://example.com/browser/browser/base/content/test/general/"; const url = example_base + "subtst_contextmenu.html"; @@ -38,6 +40,7 @@ add_task(function* test_plaintext() { "context-bookmarkpage", true], null, "---", null, "context-savepage", true, + ...(hasPocket ? ["context-pocket", true] : []), "---", null, "context-viewbgimage", false, "context-selectall", true, @@ -56,6 +59,7 @@ add_task(function* test_link() { "---", null, "context-bookmarklink", true, "context-savelink", true, + ...(hasPocket ? ["context-savelinktopocket", true] : []), "context-copylink", true, "context-searchselect", true ] @@ -196,6 +200,7 @@ add_task(function* test_iframe() { "context-bookmarkpage", true], null, "---", null, "context-savepage", true, + ...(hasPocket ? ["context-pocket", true] : []), "---", null, "context-viewbgimage", false, "context-selectall", true, @@ -460,6 +465,7 @@ add_task(function* test_pagemenu() { "+Checkbox", {type: "checkbox", icon: "", checked: false, disabled: false}], null, "---", null, "context-savepage", true, + ...(hasPocket ? ["context-pocket", true] : []), "---", null, "context-viewbgimage", false, "context-selectall", true, @@ -490,6 +496,7 @@ add_task(function* test_dom_full_screen() { "context-leave-dom-fullscreen", true, "---", null, "context-savepage", true, + ...(hasPocket ? ["context-pocket", true] : []), "---", null, "context-viewbgimage", false, "context-selectall", true, @@ -535,6 +542,7 @@ add_task(function* test_pagemenu2() { "context-bookmarkpage", true], null, "---", null, "context-savepage", true, + ...(hasPocket ? ["context-pocket", true] : []), "---", null, "context-viewbgimage", false, "context-selectall", true, @@ -603,6 +611,7 @@ add_task(function* test_imagelink() { "---", null, "context-bookmarklink", true, "context-savelink", true, + ...(hasPocket ? ["context-savelinktopocket", true] : []), "context-copylink", true, "---", null, "context-viewimage", true, @@ -701,6 +710,7 @@ add_task(function* test_click_to_play_blocked_plugin() { "context-ctp-hide", true, "---", null, "context-savepage", true, + ...(hasPocket ? ["context-pocket", true] : []), "---", null, "context-viewbgimage", false, "context-selectall", true, @@ -744,6 +754,7 @@ add_task(function* test_srcdoc() { "context-bookmarkpage", true], null, "---", null, "context-savepage", true, + ...(hasPocket ? ["context-pocket", true] : []), "---", null, "context-viewbgimage", false, "context-selectall", true, diff --git a/browser/base/content/test/general/browser_contextmenu_input.js b/browser/base/content/test/general/browser_contextmenu_input.js index 390723e54f49..330e4aece645 100644 --- a/browser/base/content/test/general/browser_contextmenu_input.js +++ b/browser/base/content/test/general/browser_contextmenu_input.js @@ -1,6 +1,8 @@ "use strict"; let contextMenu; +let hasPocket = Services.prefs.getBoolPref("extensions.pocket.enabled"); + add_task(function* test_setup() { const example_base = "http://example.com/browser/browser/base/content/test/general/"; const url = example_base + "subtst_contextmenu_input.html"; @@ -187,6 +189,7 @@ add_task(function* test_date_time_color_range_input() { "context-bookmarkpage", true], null, "---", null, "context-savepage", true, + ...(hasPocket ? ["context-pocket", true] : []), "---", null, "context-viewbgimage", false, "context-selectall", null, diff --git a/browser/base/content/test/general/browser_devices_get_user_media_about_urls.js b/browser/base/content/test/general/browser_devices_get_user_media_about_urls.js index 19de9df24b08..f758de27c6c2 100644 --- a/browser/base/content/test/general/browser_devices_get_user_media_about_urls.js +++ b/browser/base/content/test/general/browser_devices_get_user_media_about_urls.js @@ -58,37 +58,8 @@ function loadPage(aUrl) { return deferred.promise; } -// A fake about module to map get_user_media.html to different about urls. -function fakeLoopAboutModule() { -} - -fakeLoopAboutModule.prototype = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]), - newChannel: function (aURI, aLoadInfo) { - let rootDir = getRootDirectory(gTestPath); - let uri = Services.io.newURI(rootDir + "get_user_media.html", null, null); - let chan = Services.io.newChannelFromURIWithLoadInfo(uri, aLoadInfo); - - chan.owner = Services.scriptSecurityManager.getSystemPrincipal(); - return chan; - }, - getURIFlags: function (aURI) { - return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT | - Ci.nsIAboutModule.ALLOW_SCRIPT | - Ci.nsIAboutModule.URI_CAN_LOAD_IN_CHILD | - Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT; - } -}; - -var factory = XPCOMUtils._getFactory(fakeLoopAboutModule); -var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); - -var classIDLoopconversation, classIDEvil; - registerCleanupFunction(function() { gBrowser.removeCurrentTab(); - registrar.unregisterFactory(classIDLoopconversation, factory); - registrar.unregisterFactory(classIDEvil, factory); }); const permissionError = "error: SecurityError: The operation is insecure."; @@ -181,19 +152,46 @@ function test() { gTab.linkedBrowser.messageManager.loadFrameScript(CONTENT_SCRIPT_HELPER, true); - classIDLoopconversation = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator).generateUUID(); - registrar.registerFactory(classIDLoopconversation, "", - "@mozilla.org/network/protocol/about;1?what=loopconversation", - factory); - - classIDEvil = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator).generateUUID(); - registrar.registerFactory(classIDEvil, "", - "@mozilla.org/network/protocol/about;1?what=evil", - factory); - Task.spawn(function () { + yield ContentTask.spawn(gBrowser.selectedBrowser, + getRootDirectory(gTestPath) + "get_user_media.html", + function* (url) { + const Ci = Components.interfaces; + Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + Components.utils.import("resource://gre/modules/Services.jsm"); + + /* A fake about module to map get_user_media.html to different about urls. */ + function fakeLoopAboutModule() { + } + + fakeLoopAboutModule.prototype = { + QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]), + newChannel: function (aURI, aLoadInfo) { + let uri = Services.io.newURI(url, null, null); + let chan = Services.io.newChannelFromURIWithLoadInfo(uri, aLoadInfo); + chan.owner = Services.scriptSecurityManager.getSystemPrincipal(); + return chan; + }, + getURIFlags: function (aURI) { + return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT | + Ci.nsIAboutModule.ALLOW_SCRIPT | + Ci.nsIAboutModule.URI_CAN_LOAD_IN_CHILD | + Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT; + } + }; + + var factory = XPCOMUtils._getFactory(fakeLoopAboutModule); + var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); + let UUIDGenerator = Components.classes["@mozilla.org/uuid-generator;1"] + .getService(Ci.nsIUUIDGenerator); + registrar.registerFactory(UUIDGenerator.generateUUID(), "", + "@mozilla.org/network/protocol/about;1?what=loopconversation", + factory); + registrar.registerFactory(UUIDGenerator.generateUUID(), "", + "@mozilla.org/network/protocol/about;1?what=evil", + factory); + }); + yield new Promise(resolve => SpecialPowers.pushPrefEnv({ "set": [[PREF_PERMISSION_FAKE, true], ["media.getusermedia.screensharing.enabled", true]], @@ -206,6 +204,19 @@ function test() { // Cleanup before the next test expectNoObserverCalled(); } + + yield ContentTask.spawn(gBrowser.selectedBrowser, null, + function* () { + const Ci = Components.interfaces; + const Cc = Components.classes; + var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); + let cid = Cc["@mozilla.org/network/protocol/about;1?what=loopconversation"]; + registrar.unregisterFactory(cid, + registrar.getClassObject(cid, Ci.nsIFactory)); + cid = Cc["@mozilla.org/network/protocol/about;1?what=evil"]; + registrar.unregisterFactory(cid, + registrar.getClassObject(cid, Ci.nsIFactory)); + }); }).then(finish, ex => { ok(false, "Unexpected Exception: " + ex); finish(); diff --git a/browser/base/content/test/general/browser_urlbarEnterAfterMouseOver.js b/browser/base/content/test/general/browser_urlbarEnterAfterMouseOver.js index 79c8137ff27f..7a82b2e3136d 100644 --- a/browser/base/content/test/general/browser_urlbarEnterAfterMouseOver.js +++ b/browser/base/content/test/general/browser_urlbarEnterAfterMouseOver.js @@ -15,6 +15,8 @@ function is_selected(index) { is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`); } +let gMaxResults; + add_task(function*() { registerCleanupFunction(function* () { yield PlacesTestUtils.clearHistory(); @@ -23,8 +25,10 @@ add_task(function*() { yield PlacesTestUtils.clearHistory(); let tabCount = gBrowser.tabs.length; + gMaxResults = Services.prefs.getIntPref("browser.urlbar.maxRichResults"); + let visits = []; - repeat(10, i => { + repeat(gMaxResults, i => { visits.push({ uri: makeURI("http://example.com/autocomplete/?" + i), }); @@ -44,7 +48,8 @@ function* do_test() { let popup = gURLBar.popup; let results = popup.richlistbox.children; - is(results.length, 11, "Should get 11 results"); + is(results.length, gMaxResults, + "Should get gMaxResults=" + gMaxResults + " results"); let initiallySelected = gURLBar.popup.richlistbox.selectedIndex; diff --git a/browser/base/content/test/general/contextmenu_common.js b/browser/base/content/test/general/contextmenu_common.js index 97610340ae56..768a52fa58a8 100644 --- a/browser/base/content/test/general/contextmenu_common.js +++ b/browser/base/content/test/general/contextmenu_common.js @@ -62,6 +62,7 @@ function getVisibleMenuItems(aMenu, aData) { } else if (item.id.indexOf("spell-check-dictionary-") != 0 && item.id != "spell-no-suggestions" && item.id != "spell-add-dictionaries-main" && + item.id != "context-savelinktopocket" && item.id != "fill-login-saved-passwords" && item.id != "fill-login-no-logins") { ok(key, "menuitem " + item.id + " has an access key"); diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index 5b3a90b9a874..ca01e9747cf7 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -1360,9 +1360,16 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. var popupDirection = aElement.ownerDocument.defaultView.getComputedStyle(aElement).direction; this.style.direction = popupDirection; - // Move left margin to the window border. + // Make the popup's starting margin negaxtive so that the start of the + // popup aligns with the window border. let elementRect = aElement.getBoundingClientRect(); - this.style.marginLeft = "-" + (elementRect.left - rect.left) + "px"; + if (popupDirection == "rtl") { + let offset = elementRect.right - rect.right + this.style.marginRight = offset + "px"; + } else { + let offset = rect.left - elementRect.left; + this.style.marginLeft = offset + "px"; + } // Position the popup below the navbar. To get the y-coordinate, // which is an offset from the bottom of the input, subtract the diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm index dd37e5d0031f..a387d9ea0855 100644 --- a/browser/components/customizableui/CustomizableUI.jsm +++ b/browser/components/customizableui/CustomizableUI.jsm @@ -2134,7 +2134,8 @@ var CustomizableUIInternal = { dispatchToolboxEvent: function(aEventType, aDetails={}, aWindow=null) { if (aWindow) { - return this._dispatchToolboxEventToWindow(aEventType, aDetails, aWindow); + this._dispatchToolboxEventToWindow(aEventType, aDetails, aWindow); + return; } for (let [win, ] of gBuildWindows) { this._dispatchToolboxEventToWindow(aEventType, aDetails, win); @@ -2418,6 +2419,7 @@ var CustomizableUIInternal = { aArgs); } catch (e) { Cu.reportError(e); + return undefined; } }; }, @@ -3912,7 +3914,7 @@ function XULWidgetGroupWrapper(aWidgetId) { }); this.__defineGetter__("instances", function() { - return Array.from(gBuildWindows, ([win,]) => this.forWindow(win)); + return Array.from(gBuildWindows, (wins) => this.forWindow(wins[0])); }); Object.freeze(this); diff --git a/browser/components/customizableui/test/browser_984455_bookmarks_items_reparenting.js b/browser/components/customizableui/test/browser_984455_bookmarks_items_reparenting.js index 48bfad82bdba..44e94f63d11b 100644 --- a/browser/components/customizableui/test/browser_984455_bookmarks_items_reparenting.js +++ b/browser/components/customizableui/test/browser_984455_bookmarks_items_reparenting.js @@ -128,6 +128,7 @@ function checkBookmarksItemsChevronContextMenu() { if (child.style.visibility != "hidden") return true; } + return false; }); yield checkPlacesContextMenu(chevronPopup); info("Waiting for bookmark toolbar item chevron popup to close"); diff --git a/browser/components/extensions/ext-commands.js b/browser/components/extensions/ext-commands.js index 8a6228375332..c6276c9882c4 100644 --- a/browser/components/extensions/ext-commands.js +++ b/browser/components/extensions/ext-commands.js @@ -195,11 +195,11 @@ CommandList.prototype = { */ getModifiersAttribute(chromeModifiers) { let modifiersMap = { - "Alt" : "alt", - "Command" : "accel", - "Ctrl" : "accel", - "MacCtrl" : "control", - "Shift" : "shift", + "Alt": "alt", + "Command": "accel", + "Ctrl": "accel", + "MacCtrl": "control", + "Shift": "shift", }; return Array.from(chromeModifiers, modifier => { return modifiersMap[modifier]; diff --git a/browser/components/extensions/test/browser/browser.ini b/browser/components/extensions/test/browser/browser.ini index 9872870612e7..40c92761e4f8 100644 --- a/browser/components/extensions/test/browser/browser.ini +++ b/browser/components/extensions/test/browser/browser.ini @@ -58,6 +58,7 @@ support-files = [browser_ext_windows_create.js] tags = fullscreen [browser_ext_windows_create_tabId.js] +[browser_ext_windows_events.js] [browser_ext_windows.js] [browser_ext_windows_size.js] skip-if = os == 'mac' # Fails when windows are randomly opened in fullscreen mode diff --git a/browser/components/extensions/test/browser/browser_ext_currentWindow.js b/browser/components/extensions/test/browser/browser_ext_currentWindow.js index f8026235c903..8ef9df1c45a4 100644 --- a/browser/components/extensions/test/browser/browser_ext_currentWindow.js +++ b/browser/components/extensions/test/browser/browser_ext_currentWindow.js @@ -122,11 +122,11 @@ add_task(function* () { // Set focus to some other window. yield focusWindow(window); - yield triggerPopup(win1, function*() { + yield triggerPopup(win1, function* () { yield checkWindow("popup", winId1, "win1"); }); - yield triggerPopup(win2, function*() { + yield triggerPopup(win2, function* () { yield checkWindow("popup", winId2, "win2"); }); diff --git a/browser/components/extensions/test/browser/browser_ext_getViews.js b/browser/components/extensions/test/browser/browser_ext_getViews.js index 0143d3694cbd..f071a4558ebc 100644 --- a/browser/components/extensions/test/browser/browser_ext_getViews.js +++ b/browser/components/extensions/test/browser/browser_ext_getViews.js @@ -140,12 +140,12 @@ add_task(function* () { // short timeout seems to consistently fix it. yield new Promise(resolve => win1.setTimeout(resolve, 10)); - yield triggerPopup(win1, function*() { + yield triggerPopup(win1, function* () { yield checkViews("background", 2, 1); yield checkViews("popup", 2, 1); }); - yield triggerPopup(win2, function*() { + yield triggerPopup(win2, function* () { yield checkViews("background", 2, 1); yield checkViews("popup", 2, 1); }); @@ -165,7 +165,7 @@ add_task(function* () { info("opening win1 popup"); - yield triggerPopup(win1, function*() { + yield triggerPopup(win1, function* () { yield checkViews("background", 1, 1); yield checkViews("tab", 1, 1); yield checkViews("popup", 1, 1); @@ -173,7 +173,7 @@ add_task(function* () { info("opening win2 popup"); - yield triggerPopup(win2, function*() { + yield triggerPopup(win2, function* () { yield checkViews("background", 1, 1); yield checkViews("tab", 1, 1); yield checkViews("popup", 1, 1); diff --git a/browser/components/extensions/test/browser/browser_ext_runtime_openOptionsPage.js b/browser/components/extensions/test/browser/browser_ext_runtime_openOptionsPage.js index 459ca108de9f..5c8c865a88e4 100644 --- a/browser/components/extensions/test/browser/browser_ext_runtime_openOptionsPage.js +++ b/browser/components/extensions/test/browser/browser_ext_runtime_openOptionsPage.js @@ -226,3 +226,34 @@ add_task(function* test_tab_options() { yield BrowserTestUtils.removeTab(tab); }); + +add_task(function* test_options_no_manifest() { + let extension = yield loadExtension({ + manifest: {}, + + background: function() { + browser.test.log("Try to open options page when not specified in the manifest."); + + browser.runtime.openOptionsPage().then( + () => { + browser.test.fail("Opening options page without one specified in the manifest generated an error"); + browser.test.notifyFail("options-no-manifest"); + }, + error => { + let expected = "No `options_ui` declared"; + browser.test.assertTrue( + error.message.includes(expected), + `Got expected error (got: '${error.message}', expected: '${expected}'`); + } + ).then(() => { + browser.test.notifyPass("options-no-manifest"); + }).catch(error => { + browser.test.log(`Error: ${error} :: ${error.stack}`); + browser.test.notifyFail("options-no-manifest"); + }); + }, + }); + + yield extension.awaitFinish("options-no-manifest"); + yield extension.unload(); +}); diff --git a/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js b/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js index 630420202d0d..3bd586a17f02 100644 --- a/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js +++ b/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js @@ -13,6 +13,17 @@ add_task(function* testWindowCreate() { }); }; + let promiseTabUpdated = (expected) => { + return new Promise(resolve => { + browser.tabs.onUpdated.addListener(function listener(tabId, changeInfo, tab) { + if (changeInfo.url === expected) { + browser.tabs.onUpdated.removeListener(listener); + resolve(); + } + }); + }); + }; + let windowId; browser.windows.getCurrent().then(window => { windowId = window.id; @@ -85,6 +96,35 @@ add_task(function* testWindowCreate() { browser.test.assertTrue(/`incognito` property must match the incognito state of tab/.test(error.message), "Create call failed as expected"); }); + }).then(() => { + browser.test.log("Try to create a window with an invalid tabId"); + + return browser.windows.create({tabId: 0}).then( + window => { + browser.test.fail("Create call should have failed"); + }, + error => { + browser.test.assertTrue(/Invalid tab ID: 0/.test(error.message), + "Create call failed as expected"); + } + ); + }).then(() => { + browser.test.log("Try to create a window with two URLs"); + + return browser.windows.create({url: ["http://example.com/", "http://example.org/"]}); + }).then(window => { + return Promise.all([ + promiseTabUpdated("http://example.com/"), + promiseTabUpdated("http://example.org/"), + Promise.resolve(window), + ]); + }).then(([, , window]) => { + return browser.windows.get(window.id, {populate: true}); + }).then(window => { + browser.test.assertEq(2, window.tabs.length, "2 tabs were opened in new window"); + browser.test.assertEq("http://example.com/", window.tabs[0].url, "Correct URL was loaded in tab 1"); + browser.test.assertEq("http://example.org/", window.tabs[1].url, "Correct URL was loaded in tab 2"); + return browser.windows.remove(window.id); }).then(() => { browser.test.notifyPass("window-create"); }).catch(e => { diff --git a/browser/components/extensions/test/browser/browser_ext_windows_events.js b/browser/components/extensions/test/browser/browser_ext_windows_events.js new file mode 100644 index 000000000000..5a19b207c2d5 --- /dev/null +++ b/browser/components/extensions/test/browser/browser_ext_windows_events.js @@ -0,0 +1,39 @@ +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set sts=2 sw=2 et tw=80: */ +"use strict"; + +add_task(function* testWindowsEvents() { + function background() { + browser.windows.onCreated.addListener(function listener(window) { + browser.windows.onCreated.removeListener(listener); + browser.test.assertTrue(Number.isInteger(window.id), + "Window object's id is an integer"); + browser.test.assertEq("normal", window.type, + "Window object returned with the correct type"); + browser.test.sendMessage("window-created", window.id); + }); + + browser.windows.onRemoved.addListener(function listener(windowId) { + browser.windows.onRemoved.removeListener(listener); + browser.test.assertTrue(Number.isInteger(windowId), + "windowId is an integer"); + browser.test.sendMessage(`window-removed-${windowId}`); + browser.test.notifyPass("windows.events"); + }); + + browser.test.sendMessage("ready"); + } + + let extension = ExtensionTestUtils.loadExtension({ + background: `(${background})()`, + }); + + yield extension.startup(); + yield extension.awaitMessage("ready"); + let win1 = yield BrowserTestUtils.openNewBrowserWindow(); + let windowId = yield extension.awaitMessage("window-created"); + yield BrowserTestUtils.closeWindow(win1); + yield extension.awaitMessage(`window-removed-${windowId}`); + yield extension.awaitFinish("windows.events"); + yield extension.unload(); +}); diff --git a/browser/components/extensions/test/browser/file_popup_api_injection_a.html b/browser/components/extensions/test/browser/file_popup_api_injection_a.html index dd1632da875b..750ff1db3782 100644 --- a/browser/components/extensions/test/browser/file_popup_api_injection_a.html +++ b/browser/components/extensions/test/browser/file_popup_api_injection_a.html @@ -3,6 +3,7 @@ diff --git a/browser/components/extensions/test/browser/file_popup_api_injection_b.html b/browser/components/extensions/test/browser/file_popup_api_injection_b.html index 24d749220e03..b8c287e55c85 100644 --- a/browser/components/extensions/test/browser/file_popup_api_injection_b.html +++ b/browser/components/extensions/test/browser/file_popup_api_injection_b.html @@ -3,6 +3,7 @@ diff --git a/browser/components/extensions/test/browser/head.js b/browser/components/extensions/test/browser/head.js index 28d048c7f608..6944d0e2dea6 100644 --- a/browser/components/extensions/test/browser/head.js +++ b/browser/components/extensions/test/browser/head.js @@ -78,10 +78,8 @@ function getBrowserActionPopup(extension, win = window) { if (group.areaType == CustomizableUI.TYPE_TOOLBAR) { return win.document.getElementById("customizationui-widget-panel"); - } else { - return win.PanelUI.panel; } - return null; + return win.PanelUI.panel; } var clickBrowserAction = Task.async(function* (extension, win = window) { diff --git a/browser/components/migration/ESEDBReader.jsm b/browser/components/migration/ESEDBReader.jsm index b94e2754ee6b..e952b0cd41a5 100644 --- a/browser/components/migration/ESEDBReader.jsm +++ b/browser/components/migration/ESEDBReader.jsm @@ -478,6 +478,7 @@ ESEDB.prototype = { systemTime.wSecond, systemTime.wMilliseconds)); } + return undefined; }, _getColumnInfo(tableName, columns) { diff --git a/browser/components/migration/MSMigrationUtils.jsm b/browser/components/migration/MSMigrationUtils.jsm index 0ba933bd6c2a..5b52ce86bacf 100644 --- a/browser/components/migration/MSMigrationUtils.jsm +++ b/browser/components/migration/MSMigrationUtils.jsm @@ -872,6 +872,7 @@ WindowsVaultFormPasswords.prototype = { if (aOnlyCheckExists) { return false; } + return undefined; } }; diff --git a/browser/components/migration/content/migration.js b/browser/components/migration/content/migration.js index f2fc8dc4421e..0de70247fdae 100644 --- a/browser/components/migration/content/migration.js +++ b/browser/components/migration/content/migration.js @@ -161,6 +161,7 @@ var MigrationWizard = { else this._selectedProfile = null; } + return undefined; }, // 2 - [Profile Selection] diff --git a/browser/components/search/content/search.xml b/browser/components/search/content/search.xml index 84c6134db4de..33900c1dfa1f 100644 --- a/browser/components/search/content/search.xml +++ b/browser/components/search/content/search.xml @@ -1436,7 +1436,22 @@ BrowserSearch.searchBar.openSuggestionsPanel(); }, onError: function(errorCode) { - Components.utils.reportError("Error adding search engine: " + errorCode); + if (errorCode != Ci.nsISearchInstallCallback.ERROR_DUPLICATE_ENGINE) { + // Download error is shown by the search service + return; + } + const kSearchBundleURI = "chrome://global/locale/search/search.properties"; + let searchBundle = Services.strings.createBundle(kSearchBundleURI); + let brandBundle = document.getElementById("bundle_brand"); + let brandName = brandBundle.getString("brandShortName"); + let title = searchBundle.GetStringFromName("error_invalid_engine_title"); + let text = searchBundle.formatStringFromName("error_duplicate_engine_msg", + [brandName, target.getAttribute("uri")], 2); + Services.prompt.QueryInterface(Ci.nsIPromptFactory); + let prompt = Services.prompt.getPrompt(gBrowser.contentWindow, Ci.nsIPrompt); + prompt.QueryInterface(Ci.nsIWritablePropertyBag2); + prompt.setPropertyAsBool("allowTabModal", true); + prompt.alert(title, text); } } Services.search.addEngine(target.getAttribute("uri"), null, diff --git a/browser/components/uitour/test/head.js b/browser/components/uitour/test/head.js index c1332f9a1189..ac3275fa3681 100644 --- a/browser/components/uitour/test/head.js +++ b/browser/components/uitour/test/head.js @@ -27,6 +27,7 @@ function waitForConditionPromise(condition, timeoutMsg, tryCount=NUMBER_OF_TRIES } tries++; setTimeout(checkCondition, SINGLE_TRY_TIMEOUT); + return undefined; } setTimeout(checkCondition, SINGLE_TRY_TIMEOUT); return defer.promise; diff --git a/browser/experiments/Experiments.jsm b/browser/experiments/Experiments.jsm index 30075ae3fdf1..76c6bd7dfef1 100644 --- a/browser/experiments/Experiments.jsm +++ b/browser/experiments/Experiments.jsm @@ -1822,6 +1822,7 @@ Experiments.ExperimentEntry.prototype = { this._log.error("_installAddon() - onInstallStarted, wrong addon type"); return false; } + return undefined; }, onInstallEnded: install => { diff --git a/browser/extensions/pdfjs/README.mozilla b/browser/extensions/pdfjs/README.mozilla index b61e130b451e..eb2a3316f28d 100644 --- a/browser/extensions/pdfjs/README.mozilla +++ b/browser/extensions/pdfjs/README.mozilla @@ -1,3 +1,3 @@ This is the pdf.js project output, https://github.com/mozilla/pdf.js -Current extension version is: 1.4.185 +Current extension version is: 1.4.213 diff --git a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm index f1635da23369..17ad4c6bb377 100644 --- a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm +++ b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm @@ -1023,14 +1023,18 @@ PdfStreamConverter.prototype = { // Keep the URL the same so the browser sees it as the same. channel.originalURI = aRequest.URI; channel.loadGroup = aRequest.loadGroup; + channel.loadInfo.originAttributes = aRequest.loadInfo.originAttributes; // We can use resource principal when data is fetched by the chrome + // make sure we reuse the origin attributes from the request channel to keep + // isolation consistent. // e.g. useful for NoScript var ssm = Cc['@mozilla.org/scriptsecuritymanager;1'] .getService(Ci.nsIScriptSecurityManager); var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE, null, null); + var attrs = aRequest.loadInfo.originAttributes; var resourcePrincipal; - resourcePrincipal = ssm.createCodebasePrincipal(uri, {}); + resourcePrincipal = ssm.createCodebasePrincipal(uri, attrs); aRequest.owner = resourcePrincipal; channel.asyncOpen(proxy, aContext); }, diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js index 75b5b14b79e4..6e86de8bed09 100644 --- a/browser/extensions/pdfjs/content/build/pdf.js +++ b/browser/extensions/pdfjs/content/build/pdf.js @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {})); // Use strict in our context only - users might not want it 'use strict'; -var pdfjsVersion = '1.4.185'; -var pdfjsBuild = 'a250c15'; +var pdfjsVersion = '1.4.213'; +var pdfjsBuild = '1c253e6'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? @@ -613,6 +613,17 @@ function isLittleEndian() { return (buffer16[0] === 1); } +// Checks if it's possible to eval JS expressions. +function isEvalSupported() { + try { + /* jshint evil: true */ + new Function(''); + return true; + } catch (e) { + return false; + } +} + var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; @@ -867,7 +878,7 @@ var Util = (function UtilClosure() { /** * PDF page viewport created based on scale, rotation and offset. * @class - * @alias PDFJS.PageViewport + * @alias PageViewport */ var PageViewport = (function PageViewportClosure() { /** @@ -943,13 +954,13 @@ var PageViewport = (function PageViewportClosure() { this.height = height; this.fontScale = scale; } - PageViewport.prototype = /** @lends PDFJS.PageViewport.prototype */ { + PageViewport.prototype = /** @lends PageViewport.prototype */ { /** * Clones viewport with additional properties. * @param args {Object} (optional) If specified, may contain the 'scale' or * 'rotation' properties to override the corresponding properties in * the cloned viewport. - * @returns {PDFJS.PageViewport} Cloned viewport. + * @returns {PageViewport} Cloned viewport. */ clone: function PageViewPort_clone(args) { args = args || {}; @@ -1079,7 +1090,7 @@ function isArrayBuffer(v) { /** * Creates a promise capability object. - * @alias PDFJS.createPromiseCapability + * @alias createPromiseCapability * * @return {PromiseCapability} A capability object contains: * - a Promise, resolve and reject methods. @@ -1443,6 +1454,7 @@ exports.isString = isString; exports.isSameOrigin = isSameOrigin; exports.isValidUrl = isValidUrl; exports.isLittleEndian = isLittleEndian; +exports.isEvalSupported = isEvalSupported; exports.loadJpegStream = loadJpegStream; exports.log2 = log2; exports.readInt8 = readInt8; @@ -1462,88 +1474,12 @@ exports.warn = warn; (function (root, factory) { { - factory((root.pdfjsDisplayGlobal = {}), root.pdfjsSharedUtil); + factory((root.pdfjsDisplayDOMUtils = {}), root.pdfjsSharedUtil); } }(this, function (exports, sharedUtil) { - var globalScope = sharedUtil.globalScope; - - var isWorker = (typeof window === 'undefined'); - - // The global PDFJS object exposes the API - // In production, it will be declared outside a global wrapper - // In development, it will be declared here - if (!globalScope.PDFJS) { - globalScope.PDFJS = {}; - } - var PDFJS = globalScope.PDFJS; - - if (typeof pdfjsVersion !== 'undefined') { - PDFJS.version = pdfjsVersion; - } - if (typeof pdfjsBuild !== 'undefined') { - PDFJS.build = pdfjsBuild; - } - - PDFJS.pdfBug = false; - - if (PDFJS.verbosity !== undefined) { - sharedUtil.setVerbosityLevel(PDFJS.verbosity); - } - delete PDFJS.verbosity; - Object.defineProperty(PDFJS, 'verbosity', { - get: function () { return sharedUtil.getVerbosityLevel(); }, - set: function (level) { sharedUtil.setVerbosityLevel(level); }, - enumerable: true, - configurable: true - }); - - PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS; - PDFJS.OPS = sharedUtil.OPS; - PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES; - PDFJS.isValidUrl = sharedUtil.isValidUrl; - PDFJS.shadow = sharedUtil.shadow; - PDFJS.createBlob = sharedUtil.createBlob; - PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) { - return sharedUtil.createObjectURL(data, contentType, - PDFJS.disableCreateObjectURL); - }; - Object.defineProperty(PDFJS, 'isLittleEndian', { - configurable: true, - get: function PDFJS_isLittleEndian() { - var value = sharedUtil.isLittleEndian(); - return sharedUtil.shadow(PDFJS, 'isLittleEndian', value); - } - }); - PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters; - PDFJS.PasswordResponses = sharedUtil.PasswordResponses; - PDFJS.PasswordException = sharedUtil.PasswordException; - PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException; - PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException; - PDFJS.MissingPDFException = sharedUtil.MissingPDFException; - PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException; - PDFJS.Util = sharedUtil.Util; - PDFJS.PageViewport = sharedUtil.PageViewport; - PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability; - - exports.globalScope = globalScope; - exports.isWorker = isWorker; - exports.PDFJS = globalScope.PDFJS; -})); - - -(function (root, factory) { - { - factory((root.pdfjsDisplayDOMUtils = {}), root.pdfjsSharedUtil, - root.pdfjsDisplayGlobal); - } -}(this, function (exports, sharedUtil, displayGlobal) { - -var deprecated = sharedUtil.deprecated; var removeNullCharacters = sharedUtil.removeNullCharacters; -var shadow = sharedUtil.shadow; var warn = sharedUtil.warn; -var PDFJS = displayGlobal.PDFJS; /** * Optimised CSS custom property getter/setter. @@ -1599,9 +1535,7 @@ var CustomStyle = (function CustomStyleClosure() { return CustomStyle; })(); -PDFJS.CustomStyle = CustomStyle; - - PDFJS.hasCanvasTypedArrays = true; + function hasCanvasTypedArrays() { return true; } var LinkTarget = { NONE: 0, // Default value. @@ -1611,8 +1545,6 @@ var LinkTarget = { TOP: 4, }; -PDFJS.LinkTarget = LinkTarget; - var LinkTargetStringMap = [ '', '_self', @@ -1621,42 +1553,37 @@ var LinkTargetStringMap = [ '_top' ]; -function isExternalLinkTargetSet() { - switch (PDFJS.externalLinkTarget) { - case LinkTarget.NONE: - return false; - case LinkTarget.SELF: - case LinkTarget.BLANK: - case LinkTarget.PARENT: - case LinkTarget.TOP: - return true; - } - warn('PDFJS.externalLinkTarget is invalid: ' + PDFJS.externalLinkTarget); - // Reset the external link target, to suppress further warnings. - PDFJS.externalLinkTarget = LinkTarget.NONE; - return false; -} -PDFJS.isExternalLinkTargetSet = isExternalLinkTargetSet; +/** + * @typedef ExternalLinkParameters + * @typedef {Object} ExternalLinkParameters + * @property {string} url + * @property {LinkTarget} target + * @property {string} rel + */ /** * Adds various attributes (href, title, target, rel) to hyperlinks. * @param {HTMLLinkElement} link - The link element. - * @param {Object} params - An object with the properties: - * @param {string} params.url - An absolute URL. + * @param {ExternalLinkParameters} params - An object with the properties. */ function addLinkAttributes(link, params) { var url = params && params.url; link.href = link.title = (url ? removeNullCharacters(url) : ''); if (url) { - if (isExternalLinkTargetSet()) { - link.target = LinkTargetStringMap[PDFJS.externalLinkTarget]; + var target = params.target; + if (typeof target === 'undefined') { + target = getDefaultSetting('externalLinkTarget'); } + link.target = LinkTargetStringMap[target]; // Strip referrer from the URL. - link.rel = PDFJS.externalLinkRel; + var rel = params.rel; + if (typeof rel === 'undefined') { + rel = getDefaultSetting('externalLinkRel'); + } + link.rel = rel; } } -PDFJS.addLinkAttributes = addLinkAttributes; // Gets the file name from a given URL. function getFilenameFromUrl(url) { @@ -1667,22 +1594,96 @@ function getFilenameFromUrl(url) { query > 0 ? query : url.length); return url.substring(url.lastIndexOf('/', end) + 1, end); } -PDFJS.getFilenameFromUrl = getFilenameFromUrl; + +function getDefaultSetting(id) { + // The list of the settings and their default is maintained for backward + // compatibility and shall not be extended or modified. See also global.js. + var globalSettings = sharedUtil.globalScope.PDFJS; + switch (id) { + case 'pdfBug': + return globalSettings ? globalSettings.pdfBug : false; + case 'disableAutoFetch': + return globalSettings ? globalSettings.disableAutoFetch : false; + case 'disableStream': + return globalSettings ? globalSettings.disableStream : false; + case 'disableRange': + return globalSettings ? globalSettings.disableRange : false; + case 'disableFontFace': + return globalSettings ? globalSettings.disableFontFace : false; + case 'disableCreateObjectURL': + return globalSettings ? globalSettings.disableCreateObjectURL : false; + case 'disableWebGL': + return globalSettings ? globalSettings.disableWebGL : true; + case 'cMapUrl': + return globalSettings ? globalSettings.cMapUrl : null; + case 'cMapPacked': + return globalSettings ? globalSettings.cMapPacked : false; + case 'postMessageTransfers': + return globalSettings ? globalSettings.postMessageTransfers : true; + case 'workerSrc': + return globalSettings ? globalSettings.workerSrc : null; + case 'disableWorker': + return globalSettings ? globalSettings.disableWorker : false; + case 'maxImageSize': + return globalSettings ? globalSettings.maxImageSize : -1; + case 'imageResourcesPath': + return globalSettings ? globalSettings.imageResourcesPath : ''; + case 'isEvalSupported': + return globalSettings ? globalSettings.isEvalSupported : true; + case 'externalLinkTarget': + if (!globalSettings) { + return LinkTarget.NONE; + } + switch (globalSettings.externalLinkTarget) { + case LinkTarget.NONE: + case LinkTarget.SELF: + case LinkTarget.BLANK: + case LinkTarget.PARENT: + case LinkTarget.TOP: + return globalSettings.externalLinkTarget; + } + warn('PDFJS.externalLinkTarget is invalid: ' + + globalSettings.externalLinkTarget); + // Reset the external link target, to suppress further warnings. + globalSettings.externalLinkTarget = LinkTarget.NONE; + return LinkTarget.NONE; + case 'externalLinkRel': + return globalSettings ? globalSettings.externalLinkRel : 'noreferrer'; + case 'enableStats': + return !!(globalSettings && globalSettings.enableStats); + default: + throw new Error('Unknown default setting: ' + id); + } +} + +function isExternalLinkTargetSet() { + var externalLinkTarget = getDefaultSetting('externalLinkTarget'); + switch (externalLinkTarget) { + case LinkTarget.NONE: + return false; + case LinkTarget.SELF: + case LinkTarget.BLANK: + case LinkTarget.PARENT: + case LinkTarget.TOP: + return true; + } +} exports.CustomStyle = CustomStyle; exports.addLinkAttributes = addLinkAttributes; exports.isExternalLinkTargetSet = isExternalLinkTargetSet; exports.getFilenameFromUrl = getFilenameFromUrl; exports.LinkTarget = LinkTarget; +exports.hasCanvasTypedArrays = hasCanvasTypedArrays; +exports.getDefaultSetting = getDefaultSetting; })); (function (root, factory) { { - factory((root.pdfjsDisplayFontLoader = {}), root.pdfjsSharedUtil, - root.pdfjsDisplayGlobal); + factory((root.pdfjsDisplayFontLoader = {}), root.pdfjsSharedUtil); } -}(this, function (exports, sharedUtil, displayGlobal) { +}(this, function (exports, sharedUtil) { var assert = sharedUtil.assert; var bytesToString = sharedUtil.bytesToString; @@ -1690,10 +1691,6 @@ var string32 = sharedUtil.string32; var shadow = sharedUtil.shadow; var warn = sharedUtil.warn; -var PDFJS = displayGlobal.PDFJS; -var globalScope = displayGlobal.globalScope; -var isWorker = displayGlobal.isWorker; - function FontLoader(docId) { this.docId = docId; this.styleElement = null; @@ -1720,8 +1717,6 @@ FontLoader.prototype = { } }, bind: function fontLoaderBind(fonts, callback) { - assert(!isWorker, 'bind() shall be called from main thread'); - for (var i = 0, ii = fonts.length; i < ii; i++) { var font = fonts[i]; if (font.attached) { @@ -1739,29 +1734,21 @@ FontLoader.prototype = { } }; +var IsEvalSupportedCached = { + get value() { + return shadow(this, 'value', sharedUtil.isEvalSupported()); + } +}; + var FontFaceObject = (function FontFaceObjectClosure() { - function FontFaceObject(translatedData) { + function FontFaceObject(translatedData, options) { this.compiledGlyphs = Object.create(null); // importing translated data for (var i in translatedData) { this[i] = translatedData[i]; } + this.options = options; } - Object.defineProperty(FontFaceObject, 'isEvalSupported', { - get: function () { - var evalSupport = false; - if (PDFJS.isEvalSupported) { - try { - /* jshint evil: true */ - new Function(''); - evalSupport = true; - } catch (e) {} - } - return shadow(this, 'isEvalSupported', evalSupport); - }, - enumerable: true, - configurable: true - }); FontFaceObject.prototype = { createFontFaceRule: function FontFaceObject_createFontFaceRule() { @@ -1769,7 +1756,7 @@ var FontFaceObject = (function FontFaceObjectClosure() { return null; } - if (PDFJS.disableFontFace) { + if (this.options.disableFontFace) { this.disableFontFace = true; return null; } @@ -1778,13 +1765,11 @@ var FontFaceObject = (function FontFaceObjectClosure() { var fontName = this.loadedName; // Add the font-face rule to the document - var url = ('url(data:' + this.mimetype + ';base64,' + - window.btoa(data) + ');'); + var url = ('url(data:' + this.mimetype + ';base64,' + btoa(data) + ');'); var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}'; - if (PDFJS.pdfBug && 'FontInspector' in globalScope && - globalScope['FontInspector'].enabled) { - globalScope['FontInspector'].fontAdded(this, url); + if (this.options.fontRegistry) { + this.options.fontRegistry.registerFont(this, url); } return rule; @@ -1797,7 +1782,7 @@ var FontFaceObject = (function FontFaceObjectClosure() { var current, i, len; // If we can, compile cmds into JS for MAXIMUM SPEED - if (FontFaceObject.isEvalSupported) { + if (this.options.isEvalSupported && IsEvalSupportedCached.value) { var args, js = ''; for (i = 0, len = cmds.length; i < len; i++) { current = cmds[i]; @@ -1841,15 +1826,12 @@ exports.FontLoader = FontLoader; (function (root, factory) { { - factory((root.pdfjsDisplayMetadata = {}), root.pdfjsSharedUtil, - root.pdfjsDisplayGlobal); + factory((root.pdfjsDisplayMetadata = {}), root.pdfjsSharedUtil); } -}(this, function (exports, sharedUtil, displayGlobal) { +}(this, function (exports, sharedUtil) { var error = sharedUtil.error; -var PDFJS = displayGlobal.PDFJS; -var Metadata = PDFJS.Metadata = (function MetadataClosure() { function fixMetadata(meta) { return meta.replace(/>\\376\\377([^<]+)/g, function(all, codes) { var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, @@ -1926,441 +1908,15 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() { } }; - return Metadata; -})(); - exports.Metadata = Metadata; })); (function (root, factory) { { - factory((root.pdfjsDisplayWebGL = {}), root.pdfjsSharedUtil, - root.pdfjsDisplayGlobal); + factory((root.pdfjsDisplaySVG = {}), root.pdfjsSharedUtil); } -}(this, function (exports, sharedUtil, displayGlobal) { - -var shadow = sharedUtil.shadow; -var PDFJS = displayGlobal.PDFJS; - -var WebGLUtils = (function WebGLUtilsClosure() { - function loadShader(gl, code, shaderType) { - var shader = gl.createShader(shaderType); - gl.shaderSource(shader, code); - gl.compileShader(shader); - var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); - if (!compiled) { - var errorMsg = gl.getShaderInfoLog(shader); - throw new Error('Error during shader compilation: ' + errorMsg); - } - return shader; - } - function createVertexShader(gl, code) { - return loadShader(gl, code, gl.VERTEX_SHADER); - } - function createFragmentShader(gl, code) { - return loadShader(gl, code, gl.FRAGMENT_SHADER); - } - function createProgram(gl, shaders) { - var program = gl.createProgram(); - for (var i = 0, ii = shaders.length; i < ii; ++i) { - gl.attachShader(program, shaders[i]); - } - gl.linkProgram(program); - var linked = gl.getProgramParameter(program, gl.LINK_STATUS); - if (!linked) { - var errorMsg = gl.getProgramInfoLog(program); - throw new Error('Error during program linking: ' + errorMsg); - } - return program; - } - function createTexture(gl, image, textureId) { - gl.activeTexture(textureId); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - - // Set the parameters so we can render any size image. - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - - // Upload the image into the texture. - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); - return texture; - } - - var currentGL, currentCanvas; - function generateGL() { - if (currentGL) { - return; - } - currentCanvas = document.createElement('canvas'); - currentGL = currentCanvas.getContext('webgl', - { premultipliedalpha: false }); - } - - var smaskVertexShaderCode = '\ - attribute vec2 a_position; \ - attribute vec2 a_texCoord; \ - \ - uniform vec2 u_resolution; \ - \ - varying vec2 v_texCoord; \ - \ - void main() { \ - vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \ - gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ - \ - v_texCoord = a_texCoord; \ - } '; - - var smaskFragmentShaderCode = '\ - precision mediump float; \ - \ - uniform vec4 u_backdrop; \ - uniform int u_subtype; \ - uniform sampler2D u_image; \ - uniform sampler2D u_mask; \ - \ - varying vec2 v_texCoord; \ - \ - void main() { \ - vec4 imageColor = texture2D(u_image, v_texCoord); \ - vec4 maskColor = texture2D(u_mask, v_texCoord); \ - if (u_backdrop.a > 0.0) { \ - maskColor.rgb = maskColor.rgb * maskColor.a + \ - u_backdrop.rgb * (1.0 - maskColor.a); \ - } \ - float lum; \ - if (u_subtype == 0) { \ - lum = maskColor.a; \ - } else { \ - lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \ - maskColor.b * 0.11; \ - } \ - imageColor.a *= lum; \ - imageColor.rgb *= imageColor.a; \ - gl_FragColor = imageColor; \ - } '; - - var smaskCache = null; - - function initSmaskGL() { - var canvas, gl; - - generateGL(); - canvas = currentCanvas; - currentCanvas = null; - gl = currentGL; - currentGL = null; - - // setup a GLSL program - var vertexShader = createVertexShader(gl, smaskVertexShaderCode); - var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode); - var program = createProgram(gl, [vertexShader, fragmentShader]); - gl.useProgram(program); - - var cache = {}; - cache.gl = gl; - cache.canvas = canvas; - cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); - cache.positionLocation = gl.getAttribLocation(program, 'a_position'); - cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop'); - cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype'); - - var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord'); - var texLayerLocation = gl.getUniformLocation(program, 'u_image'); - var texMaskLocation = gl.getUniformLocation(program, 'u_mask'); - - // provide texture coordinates for the rectangle. - var texCoordBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ - 0.0, 0.0, - 1.0, 0.0, - 0.0, 1.0, - 0.0, 1.0, - 1.0, 0.0, - 1.0, 1.0]), gl.STATIC_DRAW); - gl.enableVertexAttribArray(texCoordLocation); - gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0); - - gl.uniform1i(texLayerLocation, 0); - gl.uniform1i(texMaskLocation, 1); - - smaskCache = cache; - } - - function composeSMask(layer, mask, properties) { - var width = layer.width, height = layer.height; - - if (!smaskCache) { - initSmaskGL(); - } - var cache = smaskCache,canvas = cache.canvas, gl = cache.gl; - canvas.width = width; - canvas.height = height; - gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); - gl.uniform2f(cache.resolutionLocation, width, height); - - if (properties.backdrop) { - gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], - properties.backdrop[1], properties.backdrop[2], 1); - } else { - gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0); - } - gl.uniform1i(cache.subtypeLocation, - properties.subtype === 'Luminosity' ? 1 : 0); - - // Create a textures - var texture = createTexture(gl, layer, gl.TEXTURE0); - var maskTexture = createTexture(gl, mask, gl.TEXTURE1); - - - // Create a buffer and put a single clipspace rectangle in - // it (2 triangles) - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ - 0, 0, - width, 0, - 0, height, - 0, height, - width, 0, - width, height]), gl.STATIC_DRAW); - gl.enableVertexAttribArray(cache.positionLocation); - gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); - - // draw - gl.clearColor(0, 0, 0, 0); - gl.enable(gl.BLEND); - gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); - gl.clear(gl.COLOR_BUFFER_BIT); - - gl.drawArrays(gl.TRIANGLES, 0, 6); - - gl.flush(); - - gl.deleteTexture(texture); - gl.deleteTexture(maskTexture); - gl.deleteBuffer(buffer); - - return canvas; - } - - var figuresVertexShaderCode = '\ - attribute vec2 a_position; \ - attribute vec3 a_color; \ - \ - uniform vec2 u_resolution; \ - uniform vec2 u_scale; \ - uniform vec2 u_offset; \ - \ - varying vec4 v_color; \ - \ - void main() { \ - vec2 position = (a_position + u_offset) * u_scale; \ - vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \ - gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ - \ - v_color = vec4(a_color / 255.0, 1.0); \ - } '; - - var figuresFragmentShaderCode = '\ - precision mediump float; \ - \ - varying vec4 v_color; \ - \ - void main() { \ - gl_FragColor = v_color; \ - } '; - - var figuresCache = null; - - function initFiguresGL() { - var canvas, gl; - - generateGL(); - canvas = currentCanvas; - currentCanvas = null; - gl = currentGL; - currentGL = null; - - // setup a GLSL program - var vertexShader = createVertexShader(gl, figuresVertexShaderCode); - var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode); - var program = createProgram(gl, [vertexShader, fragmentShader]); - gl.useProgram(program); - - var cache = {}; - cache.gl = gl; - cache.canvas = canvas; - cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); - cache.scaleLocation = gl.getUniformLocation(program, 'u_scale'); - cache.offsetLocation = gl.getUniformLocation(program, 'u_offset'); - cache.positionLocation = gl.getAttribLocation(program, 'a_position'); - cache.colorLocation = gl.getAttribLocation(program, 'a_color'); - - figuresCache = cache; - } - - function drawFigures(width, height, backgroundColor, figures, context) { - if (!figuresCache) { - initFiguresGL(); - } - var cache = figuresCache, canvas = cache.canvas, gl = cache.gl; - - canvas.width = width; - canvas.height = height; - gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); - gl.uniform2f(cache.resolutionLocation, width, height); - - // count triangle points - var count = 0; - var i, ii, rows; - for (i = 0, ii = figures.length; i < ii; i++) { - switch (figures[i].type) { - case 'lattice': - rows = (figures[i].coords.length / figures[i].verticesPerRow) | 0; - count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6; - break; - case 'triangles': - count += figures[i].coords.length; - break; - } - } - // transfer data - var coords = new Float32Array(count * 2); - var colors = new Uint8Array(count * 3); - var coordsMap = context.coords, colorsMap = context.colors; - var pIndex = 0, cIndex = 0; - for (i = 0, ii = figures.length; i < ii; i++) { - var figure = figures[i], ps = figure.coords, cs = figure.colors; - switch (figure.type) { - case 'lattice': - var cols = figure.verticesPerRow; - rows = (ps.length / cols) | 0; - for (var row = 1; row < rows; row++) { - var offset = row * cols + 1; - for (var col = 1; col < cols; col++, offset++) { - coords[pIndex] = coordsMap[ps[offset - cols - 1]]; - coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1]; - coords[pIndex + 2] = coordsMap[ps[offset - cols]]; - coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1]; - coords[pIndex + 4] = coordsMap[ps[offset - 1]]; - coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1]; - colors[cIndex] = colorsMap[cs[offset - cols - 1]]; - colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1]; - colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2]; - colors[cIndex + 3] = colorsMap[cs[offset - cols]]; - colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1]; - colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2]; - colors[cIndex + 6] = colorsMap[cs[offset - 1]]; - colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1]; - colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2]; - - coords[pIndex + 6] = coords[pIndex + 2]; - coords[pIndex + 7] = coords[pIndex + 3]; - coords[pIndex + 8] = coords[pIndex + 4]; - coords[pIndex + 9] = coords[pIndex + 5]; - coords[pIndex + 10] = coordsMap[ps[offset]]; - coords[pIndex + 11] = coordsMap[ps[offset] + 1]; - colors[cIndex + 9] = colors[cIndex + 3]; - colors[cIndex + 10] = colors[cIndex + 4]; - colors[cIndex + 11] = colors[cIndex + 5]; - colors[cIndex + 12] = colors[cIndex + 6]; - colors[cIndex + 13] = colors[cIndex + 7]; - colors[cIndex + 14] = colors[cIndex + 8]; - colors[cIndex + 15] = colorsMap[cs[offset]]; - colors[cIndex + 16] = colorsMap[cs[offset] + 1]; - colors[cIndex + 17] = colorsMap[cs[offset] + 2]; - pIndex += 12; - cIndex += 18; - } - } - break; - case 'triangles': - for (var j = 0, jj = ps.length; j < jj; j++) { - coords[pIndex] = coordsMap[ps[j]]; - coords[pIndex + 1] = coordsMap[ps[j] + 1]; - colors[cIndex] = colorsMap[cs[j]]; - colors[cIndex + 1] = colorsMap[cs[j] + 1]; - colors[cIndex + 2] = colorsMap[cs[j] + 2]; - pIndex += 2; - cIndex += 3; - } - break; - } - } - - // draw - if (backgroundColor) { - gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, - backgroundColor[2] / 255, 1.0); - } else { - gl.clearColor(0, 0, 0, 0); - } - gl.clear(gl.COLOR_BUFFER_BIT); - - var coordsBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer); - gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW); - gl.enableVertexAttribArray(cache.positionLocation); - gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); - - var colorsBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer); - gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW); - gl.enableVertexAttribArray(cache.colorLocation); - gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, - 0, 0); - - gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY); - gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY); - - gl.drawArrays(gl.TRIANGLES, 0, count); - - gl.flush(); - - gl.deleteBuffer(coordsBuffer); - gl.deleteBuffer(colorsBuffer); - - return canvas; - } - - function cleanup() { - if (smaskCache && smaskCache.canvas) { - smaskCache.canvas.width = 0; - smaskCache.canvas.height = 0; - } - if (figuresCache && figuresCache.canvas) { - figuresCache.canvas.width = 0; - figuresCache.canvas.height = 0; - } - smaskCache = null; - figuresCache = null; - } - - return { - get isEnabled() { - if (PDFJS.disableWebGL) { - return false; - } - var enabled = false; - try { - generateGL(); - enabled = !!currentGL; - } catch (e) { } - return shadow(this, 'isEnabled', enabled); - }, - composeSMask: composeSMask, - drawFigures: drawFigures, - clear: cleanup - }; -})(); - -exports.WebGLUtils = WebGLUtils; +}(this, function (exports, sharedUtil) { })); @@ -2378,6 +1934,7 @@ var addLinkAttributes = displayDOMUtils.addLinkAttributes; var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl; var warn = sharedUtil.warn; var CustomStyle = displayDOMUtils.CustomStyle; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; /** * @typedef {Object} AnnotationElementParameters @@ -2450,6 +2007,7 @@ var AnnotationElement = (function AnnotationElementClosure() { this.viewport = parameters.viewport; this.linkService = parameters.linkService; this.downloadManager = parameters.downloadManager; + this.imageResourcesPath = parameters.imageResourcesPath; if (isRenderable) { this.container = this._createContainer(); @@ -2706,7 +2264,7 @@ var TextAnnotationElement = (function TextAnnotationElementClosure() { var image = document.createElement('img'); image.style.height = this.container.style.height; image.style.width = this.container.style.width; - image.src = PDFJS.imageResourcesPath + 'annotation-' + + image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg'; image.alt = '[{{type}} Annotation]'; image.dataset.l10nId = 'text_annotation_type'; @@ -3181,6 +2739,7 @@ var FileAttachmentAnnotationElement = ( * @property {Array} annotations * @property {PDFPage} page * @property {IPDFLinkService} linkService + * @property {string} imageResourcesPath */ /** @@ -3211,7 +2770,9 @@ var AnnotationLayer = (function AnnotationLayerClosure() { page: parameters.page, viewport: parameters.viewport, linkService: parameters.linkService, - downloadManager: parameters.downloadManager + downloadManager: parameters.downloadManager, + imageResourcesPath: parameters.imageResourcesPath || + getDefaultSetting('imageResourcesPath') }; var element = annotationElementFactory.create(properties); if (element.isRenderable) { @@ -3242,12 +2803,674 @@ var AnnotationLayer = (function AnnotationLayerClosure() { }; })(); -PDFJS.AnnotationLayer = AnnotationLayer; - exports.AnnotationLayer = AnnotationLayer; })); +(function (root, factory) { + { + factory((root.pdfjsDisplayTextLayer = {}), root.pdfjsSharedUtil, + root.pdfjsDisplayDOMUtils); + } +}(this, function (exports, sharedUtil, displayDOMUtils) { + +var Util = sharedUtil.Util; +var createPromiseCapability = sharedUtil.createPromiseCapability; +var CustomStyle = displayDOMUtils.CustomStyle; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; +var PageViewport = sharedUtil.PageViewport; + +/** + * Text layer render parameters. + * + * @typedef {Object} TextLayerRenderParameters + * @property {TextContent} textContent - Text content to render (the object is + * returned by the page's getTextContent() method). + * @property {HTMLElement} container - HTML element that will contain text runs. + * @property {PageViewport} viewport - The target viewport to properly + * layout the text runs. + * @property {Array} textDivs - (optional) HTML elements that are correspond + * the text items of the textContent input. This is output and shall be + * initially be set to empty array. + * @property {number} timeout - (optional) Delay in milliseconds before + * rendering of the text runs occurs. + */ +var renderTextLayer = (function renderTextLayerClosure() { + var MAX_TEXT_DIVS_TO_RENDER = 100000; + + var NonWhitespaceRegexp = /\S/; + + function isAllWhitespace(str) { + return !NonWhitespaceRegexp.test(str); + } + + function appendText(textDivs, viewport, geom, styles) { + var style = styles[geom.fontName]; + var textDiv = document.createElement('div'); + textDivs.push(textDiv); + if (isAllWhitespace(geom.str)) { + textDiv.dataset.isWhitespace = true; + return; + } + var tx = Util.transform(viewport.transform, geom.transform); + var angle = Math.atan2(tx[1], tx[0]); + if (style.vertical) { + angle += Math.PI / 2; + } + var fontHeight = Math.sqrt((tx[2] * tx[2]) + (tx[3] * tx[3])); + var fontAscent = fontHeight; + if (style.ascent) { + fontAscent = style.ascent * fontAscent; + } else if (style.descent) { + fontAscent = (1 + style.descent) * fontAscent; + } + + var left; + var top; + if (angle === 0) { + left = tx[4]; + top = tx[5] - fontAscent; + } else { + left = tx[4] + (fontAscent * Math.sin(angle)); + top = tx[5] - (fontAscent * Math.cos(angle)); + } + textDiv.style.left = left + 'px'; + textDiv.style.top = top + 'px'; + textDiv.style.fontSize = fontHeight + 'px'; + textDiv.style.fontFamily = style.fontFamily; + + textDiv.textContent = geom.str; + // |fontName| is only used by the Font Inspector. This test will succeed + // when e.g. the Font Inspector is off but the Stepper is on, but it's + // not worth the effort to do a more accurate test. + if (getDefaultSetting('pdfBug')) { + textDiv.dataset.fontName = geom.fontName; + } + // Storing into dataset will convert number into string. + if (angle !== 0) { + textDiv.dataset.angle = angle * (180 / Math.PI); + } + // We don't bother scaling single-char text divs, because it has very + // little effect on text highlighting. This makes scrolling on docs with + // lots of such divs a lot faster. + if (geom.str.length > 1) { + if (style.vertical) { + textDiv.dataset.canvasWidth = geom.height * viewport.scale; + } else { + textDiv.dataset.canvasWidth = geom.width * viewport.scale; + } + } + } + + function render(task) { + if (task._canceled) { + return; + } + var textLayerFrag = task._container; + var textDivs = task._textDivs; + var capability = task._capability; + var textDivsLength = textDivs.length; + + // No point in rendering many divs as it would make the browser + // unusable even after the divs are rendered. + if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) { + capability.resolve(); + return; + } + + var canvas = document.createElement('canvas'); + canvas.mozOpaque = true; + var ctx = canvas.getContext('2d', {alpha: false}); + + var lastFontSize; + var lastFontFamily; + for (var i = 0; i < textDivsLength; i++) { + var textDiv = textDivs[i]; + if (textDiv.dataset.isWhitespace !== undefined) { + continue; + } + + var fontSize = textDiv.style.fontSize; + var fontFamily = textDiv.style.fontFamily; + + // Only build font string and set to context if different from last. + if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) { + ctx.font = fontSize + ' ' + fontFamily; + lastFontSize = fontSize; + lastFontFamily = fontFamily; + } + + var width = ctx.measureText(textDiv.textContent).width; + if (width > 0) { + textLayerFrag.appendChild(textDiv); + var transform; + if (textDiv.dataset.canvasWidth !== undefined) { + // Dataset values come of type string. + var textScale = textDiv.dataset.canvasWidth / width; + transform = 'scaleX(' + textScale + ')'; + } else { + transform = ''; + } + var rotation = textDiv.dataset.angle; + if (rotation) { + transform = 'rotate(' + rotation + 'deg) ' + transform; + } + if (transform) { + CustomStyle.setProp('transform' , textDiv, transform); + } + } + } + capability.resolve(); + } + + /** + * Text layer rendering task. + * + * @param {TextContent} textContent + * @param {HTMLElement} container + * @param {PageViewport} viewport + * @param {Array} textDivs + * @private + */ + function TextLayerRenderTask(textContent, container, viewport, textDivs) { + this._textContent = textContent; + this._container = container; + this._viewport = viewport; + textDivs = textDivs || []; + this._textDivs = textDivs; + this._canceled = false; + this._capability = createPromiseCapability(); + this._renderTimer = null; + } + TextLayerRenderTask.prototype = { + get promise() { + return this._capability.promise; + }, + + cancel: function TextLayer_cancel() { + this._canceled = true; + if (this._renderTimer !== null) { + clearTimeout(this._renderTimer); + this._renderTimer = null; + } + this._capability.reject('canceled'); + }, + + _render: function TextLayer_render(timeout) { + var textItems = this._textContent.items; + var styles = this._textContent.styles; + var textDivs = this._textDivs; + var viewport = this._viewport; + for (var i = 0, len = textItems.length; i < len; i++) { + appendText(textDivs, viewport, textItems[i], styles); + } + + if (!timeout) { // Render right away + render(this); + } else { // Schedule + var self = this; + this._renderTimer = setTimeout(function() { + render(self); + self._renderTimer = null; + }, timeout); + } + } + }; + + + /** + * Starts rendering of the text layer. + * + * @param {TextLayerRenderParameters} renderParameters + * @returns {TextLayerRenderTask} + */ + function renderTextLayer(renderParameters) { + var task = new TextLayerRenderTask(renderParameters.textContent, + renderParameters.container, + renderParameters.viewport, + renderParameters.textDivs); + task._render(renderParameters.timeout); + return task; + } + + return renderTextLayer; +})(); + +exports.renderTextLayer = renderTextLayer; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayWebGL = {}), root.pdfjsSharedUtil, + root.pdfjsDisplayDOMUtils); + } +}(this, function (exports, sharedUtil, displayDOMUtils) { + +var shadow = sharedUtil.shadow; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; + +var WebGLUtils = (function WebGLUtilsClosure() { + function loadShader(gl, code, shaderType) { + var shader = gl.createShader(shaderType); + gl.shaderSource(shader, code); + gl.compileShader(shader); + var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); + if (!compiled) { + var errorMsg = gl.getShaderInfoLog(shader); + throw new Error('Error during shader compilation: ' + errorMsg); + } + return shader; + } + function createVertexShader(gl, code) { + return loadShader(gl, code, gl.VERTEX_SHADER); + } + function createFragmentShader(gl, code) { + return loadShader(gl, code, gl.FRAGMENT_SHADER); + } + function createProgram(gl, shaders) { + var program = gl.createProgram(); + for (var i = 0, ii = shaders.length; i < ii; ++i) { + gl.attachShader(program, shaders[i]); + } + gl.linkProgram(program); + var linked = gl.getProgramParameter(program, gl.LINK_STATUS); + if (!linked) { + var errorMsg = gl.getProgramInfoLog(program); + throw new Error('Error during program linking: ' + errorMsg); + } + return program; + } + function createTexture(gl, image, textureId) { + gl.activeTexture(textureId); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + + // Set the parameters so we can render any size image. + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + // Upload the image into the texture. + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); + return texture; + } + + var currentGL, currentCanvas; + function generateGL() { + if (currentGL) { + return; + } + currentCanvas = document.createElement('canvas'); + currentGL = currentCanvas.getContext('webgl', + { premultipliedalpha: false }); + } + + var smaskVertexShaderCode = '\ + attribute vec2 a_position; \ + attribute vec2 a_texCoord; \ + \ + uniform vec2 u_resolution; \ + \ + varying vec2 v_texCoord; \ + \ + void main() { \ + vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \ + gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ + \ + v_texCoord = a_texCoord; \ + } '; + + var smaskFragmentShaderCode = '\ + precision mediump float; \ + \ + uniform vec4 u_backdrop; \ + uniform int u_subtype; \ + uniform sampler2D u_image; \ + uniform sampler2D u_mask; \ + \ + varying vec2 v_texCoord; \ + \ + void main() { \ + vec4 imageColor = texture2D(u_image, v_texCoord); \ + vec4 maskColor = texture2D(u_mask, v_texCoord); \ + if (u_backdrop.a > 0.0) { \ + maskColor.rgb = maskColor.rgb * maskColor.a + \ + u_backdrop.rgb * (1.0 - maskColor.a); \ + } \ + float lum; \ + if (u_subtype == 0) { \ + lum = maskColor.a; \ + } else { \ + lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \ + maskColor.b * 0.11; \ + } \ + imageColor.a *= lum; \ + imageColor.rgb *= imageColor.a; \ + gl_FragColor = imageColor; \ + } '; + + var smaskCache = null; + + function initSmaskGL() { + var canvas, gl; + + generateGL(); + canvas = currentCanvas; + currentCanvas = null; + gl = currentGL; + currentGL = null; + + // setup a GLSL program + var vertexShader = createVertexShader(gl, smaskVertexShaderCode); + var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode); + var program = createProgram(gl, [vertexShader, fragmentShader]); + gl.useProgram(program); + + var cache = {}; + cache.gl = gl; + cache.canvas = canvas; + cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); + cache.positionLocation = gl.getAttribLocation(program, 'a_position'); + cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop'); + cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype'); + + var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord'); + var texLayerLocation = gl.getUniformLocation(program, 'u_image'); + var texMaskLocation = gl.getUniformLocation(program, 'u_mask'); + + // provide texture coordinates for the rectangle. + var texCoordBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ + 0.0, 0.0, + 1.0, 0.0, + 0.0, 1.0, + 0.0, 1.0, + 1.0, 0.0, + 1.0, 1.0]), gl.STATIC_DRAW); + gl.enableVertexAttribArray(texCoordLocation); + gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0); + + gl.uniform1i(texLayerLocation, 0); + gl.uniform1i(texMaskLocation, 1); + + smaskCache = cache; + } + + function composeSMask(layer, mask, properties) { + var width = layer.width, height = layer.height; + + if (!smaskCache) { + initSmaskGL(); + } + var cache = smaskCache,canvas = cache.canvas, gl = cache.gl; + canvas.width = width; + canvas.height = height; + gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); + gl.uniform2f(cache.resolutionLocation, width, height); + + if (properties.backdrop) { + gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], + properties.backdrop[1], properties.backdrop[2], 1); + } else { + gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0); + } + gl.uniform1i(cache.subtypeLocation, + properties.subtype === 'Luminosity' ? 1 : 0); + + // Create a textures + var texture = createTexture(gl, layer, gl.TEXTURE0); + var maskTexture = createTexture(gl, mask, gl.TEXTURE1); + + + // Create a buffer and put a single clipspace rectangle in + // it (2 triangles) + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ + 0, 0, + width, 0, + 0, height, + 0, height, + width, 0, + width, height]), gl.STATIC_DRAW); + gl.enableVertexAttribArray(cache.positionLocation); + gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); + + // draw + gl.clearColor(0, 0, 0, 0); + gl.enable(gl.BLEND); + gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + gl.clear(gl.COLOR_BUFFER_BIT); + + gl.drawArrays(gl.TRIANGLES, 0, 6); + + gl.flush(); + + gl.deleteTexture(texture); + gl.deleteTexture(maskTexture); + gl.deleteBuffer(buffer); + + return canvas; + } + + var figuresVertexShaderCode = '\ + attribute vec2 a_position; \ + attribute vec3 a_color; \ + \ + uniform vec2 u_resolution; \ + uniform vec2 u_scale; \ + uniform vec2 u_offset; \ + \ + varying vec4 v_color; \ + \ + void main() { \ + vec2 position = (a_position + u_offset) * u_scale; \ + vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \ + gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ + \ + v_color = vec4(a_color / 255.0, 1.0); \ + } '; + + var figuresFragmentShaderCode = '\ + precision mediump float; \ + \ + varying vec4 v_color; \ + \ + void main() { \ + gl_FragColor = v_color; \ + } '; + + var figuresCache = null; + + function initFiguresGL() { + var canvas, gl; + + generateGL(); + canvas = currentCanvas; + currentCanvas = null; + gl = currentGL; + currentGL = null; + + // setup a GLSL program + var vertexShader = createVertexShader(gl, figuresVertexShaderCode); + var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode); + var program = createProgram(gl, [vertexShader, fragmentShader]); + gl.useProgram(program); + + var cache = {}; + cache.gl = gl; + cache.canvas = canvas; + cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); + cache.scaleLocation = gl.getUniformLocation(program, 'u_scale'); + cache.offsetLocation = gl.getUniformLocation(program, 'u_offset'); + cache.positionLocation = gl.getAttribLocation(program, 'a_position'); + cache.colorLocation = gl.getAttribLocation(program, 'a_color'); + + figuresCache = cache; + } + + function drawFigures(width, height, backgroundColor, figures, context) { + if (!figuresCache) { + initFiguresGL(); + } + var cache = figuresCache, canvas = cache.canvas, gl = cache.gl; + + canvas.width = width; + canvas.height = height; + gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); + gl.uniform2f(cache.resolutionLocation, width, height); + + // count triangle points + var count = 0; + var i, ii, rows; + for (i = 0, ii = figures.length; i < ii; i++) { + switch (figures[i].type) { + case 'lattice': + rows = (figures[i].coords.length / figures[i].verticesPerRow) | 0; + count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6; + break; + case 'triangles': + count += figures[i].coords.length; + break; + } + } + // transfer data + var coords = new Float32Array(count * 2); + var colors = new Uint8Array(count * 3); + var coordsMap = context.coords, colorsMap = context.colors; + var pIndex = 0, cIndex = 0; + for (i = 0, ii = figures.length; i < ii; i++) { + var figure = figures[i], ps = figure.coords, cs = figure.colors; + switch (figure.type) { + case 'lattice': + var cols = figure.verticesPerRow; + rows = (ps.length / cols) | 0; + for (var row = 1; row < rows; row++) { + var offset = row * cols + 1; + for (var col = 1; col < cols; col++, offset++) { + coords[pIndex] = coordsMap[ps[offset - cols - 1]]; + coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1]; + coords[pIndex + 2] = coordsMap[ps[offset - cols]]; + coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1]; + coords[pIndex + 4] = coordsMap[ps[offset - 1]]; + coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1]; + colors[cIndex] = colorsMap[cs[offset - cols - 1]]; + colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1]; + colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2]; + colors[cIndex + 3] = colorsMap[cs[offset - cols]]; + colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1]; + colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2]; + colors[cIndex + 6] = colorsMap[cs[offset - 1]]; + colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1]; + colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2]; + + coords[pIndex + 6] = coords[pIndex + 2]; + coords[pIndex + 7] = coords[pIndex + 3]; + coords[pIndex + 8] = coords[pIndex + 4]; + coords[pIndex + 9] = coords[pIndex + 5]; + coords[pIndex + 10] = coordsMap[ps[offset]]; + coords[pIndex + 11] = coordsMap[ps[offset] + 1]; + colors[cIndex + 9] = colors[cIndex + 3]; + colors[cIndex + 10] = colors[cIndex + 4]; + colors[cIndex + 11] = colors[cIndex + 5]; + colors[cIndex + 12] = colors[cIndex + 6]; + colors[cIndex + 13] = colors[cIndex + 7]; + colors[cIndex + 14] = colors[cIndex + 8]; + colors[cIndex + 15] = colorsMap[cs[offset]]; + colors[cIndex + 16] = colorsMap[cs[offset] + 1]; + colors[cIndex + 17] = colorsMap[cs[offset] + 2]; + pIndex += 12; + cIndex += 18; + } + } + break; + case 'triangles': + for (var j = 0, jj = ps.length; j < jj; j++) { + coords[pIndex] = coordsMap[ps[j]]; + coords[pIndex + 1] = coordsMap[ps[j] + 1]; + colors[cIndex] = colorsMap[cs[j]]; + colors[cIndex + 1] = colorsMap[cs[j] + 1]; + colors[cIndex + 2] = colorsMap[cs[j] + 2]; + pIndex += 2; + cIndex += 3; + } + break; + } + } + + // draw + if (backgroundColor) { + gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, + backgroundColor[2] / 255, 1.0); + } else { + gl.clearColor(0, 0, 0, 0); + } + gl.clear(gl.COLOR_BUFFER_BIT); + + var coordsBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer); + gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW); + gl.enableVertexAttribArray(cache.positionLocation); + gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); + + var colorsBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer); + gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW); + gl.enableVertexAttribArray(cache.colorLocation); + gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, + 0, 0); + + gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY); + gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY); + + gl.drawArrays(gl.TRIANGLES, 0, count); + + gl.flush(); + + gl.deleteBuffer(coordsBuffer); + gl.deleteBuffer(colorsBuffer); + + return canvas; + } + + function cleanup() { + if (smaskCache && smaskCache.canvas) { + smaskCache.canvas.width = 0; + smaskCache.canvas.height = 0; + } + if (figuresCache && figuresCache.canvas) { + figuresCache.canvas.width = 0; + figuresCache.canvas.height = 0; + } + smaskCache = null; + figuresCache = null; + } + + return { + get isEnabled() { + if (getDefaultSetting('disableWebGL')) { + return false; + } + var enabled = false; + try { + generateGL(); + enabled = !!currentGL; + } catch (e) { } + return shadow(this, 'isEnabled', enabled); + }, + composeSMask: composeSMask, + drawFigures: drawFigures, + clear: cleanup + }; +})(); + +exports.WebGLUtils = WebGLUtils; +})); + + (function (root, factory) { { factory((root.pdfjsDisplayPatternHelper = {}), root.pdfjsSharedUtil, @@ -3671,240 +3894,6 @@ exports.TilingPattern = TilingPattern; })); -(function (root, factory) { - { - factory((root.pdfjsDisplayTextLayer = {}), root.pdfjsSharedUtil, - root.pdfjsDisplayDOMUtils, root.pdfjsDisplayGlobal); - } -}(this, function (exports, sharedUtil, displayDOMUtils, displayGlobal) { - -var Util = sharedUtil.Util; -var createPromiseCapability = sharedUtil.createPromiseCapability; -var CustomStyle = displayDOMUtils.CustomStyle; -var PDFJS = displayGlobal.PDFJS; - -/** - * Text layer render parameters. - * - * @typedef {Object} TextLayerRenderParameters - * @property {TextContent} textContent - Text content to render (the object is - * returned by the page's getTextContent() method). - * @property {HTMLElement} container - HTML element that will contain text runs. - * @property {PDFJS.PageViewport} viewport - The target viewport to properly - * layout the text runs. - * @property {Array} textDivs - (optional) HTML elements that are correspond - * the text items of the textContent input. This is output and shall be - * initially be set to empty array. - * @property {number} timeout - (optional) Delay in milliseconds before - * rendering of the text runs occurs. - */ -var renderTextLayer = (function renderTextLayerClosure() { - var MAX_TEXT_DIVS_TO_RENDER = 100000; - - var NonWhitespaceRegexp = /\S/; - - function isAllWhitespace(str) { - return !NonWhitespaceRegexp.test(str); - } - - function appendText(textDivs, viewport, geom, styles) { - var style = styles[geom.fontName]; - var textDiv = document.createElement('div'); - textDivs.push(textDiv); - if (isAllWhitespace(geom.str)) { - textDiv.dataset.isWhitespace = true; - return; - } - var tx = Util.transform(viewport.transform, geom.transform); - var angle = Math.atan2(tx[1], tx[0]); - if (style.vertical) { - angle += Math.PI / 2; - } - var fontHeight = Math.sqrt((tx[2] * tx[2]) + (tx[3] * tx[3])); - var fontAscent = fontHeight; - if (style.ascent) { - fontAscent = style.ascent * fontAscent; - } else if (style.descent) { - fontAscent = (1 + style.descent) * fontAscent; - } - - var left; - var top; - if (angle === 0) { - left = tx[4]; - top = tx[5] - fontAscent; - } else { - left = tx[4] + (fontAscent * Math.sin(angle)); - top = tx[5] - (fontAscent * Math.cos(angle)); - } - textDiv.style.left = left + 'px'; - textDiv.style.top = top + 'px'; - textDiv.style.fontSize = fontHeight + 'px'; - textDiv.style.fontFamily = style.fontFamily; - - textDiv.textContent = geom.str; - // |fontName| is only used by the Font Inspector. This test will succeed - // when e.g. the Font Inspector is off but the Stepper is on, but it's - // not worth the effort to do a more accurate test. - if (PDFJS.pdfBug) { - textDiv.dataset.fontName = geom.fontName; - } - // Storing into dataset will convert number into string. - if (angle !== 0) { - textDiv.dataset.angle = angle * (180 / Math.PI); - } - // We don't bother scaling single-char text divs, because it has very - // little effect on text highlighting. This makes scrolling on docs with - // lots of such divs a lot faster. - if (geom.str.length > 1) { - if (style.vertical) { - textDiv.dataset.canvasWidth = geom.height * viewport.scale; - } else { - textDiv.dataset.canvasWidth = geom.width * viewport.scale; - } - } - } - - function render(task) { - if (task._canceled) { - return; - } - var textLayerFrag = task._container; - var textDivs = task._textDivs; - var capability = task._capability; - var textDivsLength = textDivs.length; - - // No point in rendering many divs as it would make the browser - // unusable even after the divs are rendered. - if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) { - capability.resolve(); - return; - } - - var canvas = document.createElement('canvas'); - canvas.mozOpaque = true; - var ctx = canvas.getContext('2d', {alpha: false}); - - var lastFontSize; - var lastFontFamily; - for (var i = 0; i < textDivsLength; i++) { - var textDiv = textDivs[i]; - if (textDiv.dataset.isWhitespace !== undefined) { - continue; - } - - var fontSize = textDiv.style.fontSize; - var fontFamily = textDiv.style.fontFamily; - - // Only build font string and set to context if different from last. - if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) { - ctx.font = fontSize + ' ' + fontFamily; - lastFontSize = fontSize; - lastFontFamily = fontFamily; - } - - var width = ctx.measureText(textDiv.textContent).width; - if (width > 0) { - textLayerFrag.appendChild(textDiv); - var transform; - if (textDiv.dataset.canvasWidth !== undefined) { - // Dataset values come of type string. - var textScale = textDiv.dataset.canvasWidth / width; - transform = 'scaleX(' + textScale + ')'; - } else { - transform = ''; - } - var rotation = textDiv.dataset.angle; - if (rotation) { - transform = 'rotate(' + rotation + 'deg) ' + transform; - } - if (transform) { - CustomStyle.setProp('transform' , textDiv, transform); - } - } - } - capability.resolve(); - } - - /** - * Text layer rendering task. - * - * @param {TextContent} textContent - * @param {HTMLElement} container - * @param {PDFJS.PageViewport} viewport - * @param {Array} textDivs - * @private - */ - function TextLayerRenderTask(textContent, container, viewport, textDivs) { - this._textContent = textContent; - this._container = container; - this._viewport = viewport; - textDivs = textDivs || []; - this._textDivs = textDivs; - this._canceled = false; - this._capability = createPromiseCapability(); - this._renderTimer = null; - } - TextLayerRenderTask.prototype = { - get promise() { - return this._capability.promise; - }, - - cancel: function TextLayer_cancel() { - this._canceled = true; - if (this._renderTimer !== null) { - clearTimeout(this._renderTimer); - this._renderTimer = null; - } - this._capability.reject('canceled'); - }, - - _render: function TextLayer_render(timeout) { - var textItems = this._textContent.items; - var styles = this._textContent.styles; - var textDivs = this._textDivs; - var viewport = this._viewport; - for (var i = 0, len = textItems.length; i < len; i++) { - appendText(textDivs, viewport, textItems[i], styles); - } - - if (!timeout) { // Render right away - render(this); - } else { // Schedule - var self = this; - this._renderTimer = setTimeout(function() { - render(self); - self._renderTimer = null; - }, timeout); - } - } - }; - - - /** - * Starts rendering of the text layer. - * - * @param {TextLayerRenderParameters} renderParameters - * @returns {TextLayerRenderTask} - */ - function renderTextLayer(renderParameters) { - var task = new TextLayerRenderTask(renderParameters.textContent, - renderParameters.container, - renderParameters.viewport, - renderParameters.textDivs); - task._render(renderParameters.timeout); - return task; - } - - return renderTextLayer; -})(); - -PDFJS.renderTextLayer = renderTextLayer; - -exports.renderTextLayer = renderTextLayer; -})); - - (function (root, factory) { { factory((root.pdfjsDisplayCanvas = {}), root.pdfjsSharedUtil, @@ -3925,12 +3914,14 @@ var assert = sharedUtil.assert; var info = sharedUtil.info; var isNum = sharedUtil.isNum; var isArray = sharedUtil.isArray; +var isLittleEndian = sharedUtil.isLittleEndian; var error = sharedUtil.error; var shadow = sharedUtil.shadow; var warn = sharedUtil.warn; var TilingPattern = displayPatternHelper.TilingPattern; var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR; var WebGLUtils = displayWebGL.WebGLUtils; +var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays; // contexts store most of the state we need natively. // However, PDF needs a bit more state, which we store here. @@ -3949,6 +3940,18 @@ var MAX_SIZE_TO_COMPILE = 1000; var FULL_CHUNK_HEIGHT = 16; +var HasCanvasTypedArraysCached = { + get value() { + return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays()); + } +}; + +var IsLittleEndianCached = { + get value() { + return shadow(IsLittleEndianCached, 'value', isLittleEndian()); + } +}; + function createScratchCanvas(width, height) { var canvas = document.createElement('canvas'); canvas.width = width; @@ -4387,13 +4390,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { if (imgData.kind === ImageKind.GRAYSCALE_1BPP) { // Grayscale, 1 bit per pixel (i.e. black-and-white). var srcLength = src.byteLength; - var dest32 = PDFJS.hasCanvasTypedArrays ? new Uint32Array(dest.buffer) : - new Uint32ArrayView(dest); + var dest32 = HasCanvasTypedArraysCached.value ? + new Uint32Array(dest.buffer) : new Uint32ArrayView(dest); var dest32DataLength = dest32.length; var fullSrcDiff = (width + 7) >> 3; var white = 0xFFFFFFFF; - var black = (PDFJS.isLittleEndian || !PDFJS.hasCanvasTypedArrays) ? - 0xFF000000 : 0x000000FF; + var black = (IsLittleEndianCached.value || + !HasCanvasTypedArraysCached.value) ? 0xFF000000 : 0x000000FF; for (i = 0; i < totalChunks; i++) { thisChunkHeight = (i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight; @@ -6127,15 +6130,15 @@ exports.createScratchCanvas = createScratchCanvas; { factory((root.pdfjsDisplayAPI = {}), root.pdfjsSharedUtil, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, - root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils, - root.pdfjsDisplayGlobal); + root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils); } }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, - displayMetadata, displayDOMUtils, displayGlobal, amdRequire) { + displayMetadata, displayDOMUtils, amdRequire) { var InvalidPDFException = sharedUtil.InvalidPDFException; var MessageHandler = sharedUtil.MessageHandler; var MissingPDFException = sharedUtil.MissingPDFException; +var PageViewport = sharedUtil.PageViewport; var PasswordResponses = sharedUtil.PasswordResponses; var PasswordException = sharedUtil.PasswordException; var StatTimer = sharedUtil.StatTimer; @@ -6152,196 +6155,23 @@ var isArrayBuffer = sharedUtil.isArrayBuffer; var isSameOrigin = sharedUtil.isSameOrigin; var loadJpegStream = sharedUtil.loadJpegStream; var stringToBytes = sharedUtil.stringToBytes; +var globalScope = sharedUtil.globalScope; var warn = sharedUtil.warn; var FontFaceObject = displayFontLoader.FontFaceObject; var FontLoader = displayFontLoader.FontLoader; var CanvasGraphics = displayCanvas.CanvasGraphics; var createScratchCanvas = displayCanvas.createScratchCanvas; var Metadata = displayMetadata.Metadata; -var PDFJS = displayGlobal.PDFJS; -var globalScope = displayGlobal.globalScope; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536 +var isWorkerDisabled = false; +var workerSrc; +var isPostMessageTransfersDisabled = false; + var fakeWorkerFilesLoader = null; -/** - * The maximum allowed image size in total pixels e.g. width * height. Images - * above this value will not be drawn. Use -1 for no limit. - * @var {number} - */ -PDFJS.maxImageSize = (PDFJS.maxImageSize === undefined ? - -1 : PDFJS.maxImageSize); - -/** - * The url of where the predefined Adobe CMaps are located. Include trailing - * slash. - * @var {string} - */ -PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl); - -/** - * Specifies if CMaps are binary packed. - * @var {boolean} - */ -PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked; - -/** - * By default fonts are converted to OpenType fonts and loaded via font face - * rules. If disabled, the font will be rendered using a built in font renderer - * that constructs the glyphs with primitive path commands. - * @var {boolean} - */ -PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ? - false : PDFJS.disableFontFace); - -/** - * Path for image resources, mainly for annotation icons. Include trailing - * slash. - * @var {string} - */ -PDFJS.imageResourcesPath = (PDFJS.imageResourcesPath === undefined ? - '' : PDFJS.imageResourcesPath); - -/** - * Disable the web worker and run all code on the main thread. This will happen - * automatically if the browser doesn't support workers or sending typed arrays - * to workers. - * @var {boolean} - */ -PDFJS.disableWorker = (PDFJS.disableWorker === undefined ? - false : PDFJS.disableWorker); - -/** - * Path and filename of the worker file. Required when the worker is enabled in - * development mode. If unspecified in the production build, the worker will be - * loaded based on the location of the pdf.js file. It is recommended that - * the workerSrc is set in a custom application to prevent issues caused by - * third-party frameworks and libraries. - * @var {string} - */ -PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc); - -/** - * Disable range request loading of PDF files. When enabled and if the server - * supports partial content requests then the PDF will be fetched in chunks. - * Enabled (false) by default. - * @var {boolean} - */ -PDFJS.disableRange = (PDFJS.disableRange === undefined ? - false : PDFJS.disableRange); - -/** - * Disable streaming of PDF file data. By default PDF.js attempts to load PDF - * in chunks. This default behavior can be disabled. - * @var {boolean} - */ -PDFJS.disableStream = (PDFJS.disableStream === undefined ? - false : PDFJS.disableStream); - -/** - * Disable pre-fetching of PDF file data. When range requests are enabled PDF.js - * will automatically keep fetching more data even if it isn't needed to display - * the current page. This default behavior can be disabled. - * - * NOTE: It is also necessary to disable streaming, see above, - * in order for disabling of pre-fetching to work correctly. - * @var {boolean} - */ -PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ? - false : PDFJS.disableAutoFetch); - -/** - * Enables special hooks for debugging PDF.js. - * @var {boolean} - */ -PDFJS.pdfBug = (PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug); - -/** - * Enables transfer usage in postMessage for ArrayBuffers. - * @var {boolean} - */ -PDFJS.postMessageTransfers = (PDFJS.postMessageTransfers === undefined ? - true : PDFJS.postMessageTransfers); - -/** - * Disables URL.createObjectURL usage. - * @var {boolean} - */ -PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ? - false : PDFJS.disableCreateObjectURL); - -/** - * Disables WebGL usage. - * @var {boolean} - */ -PDFJS.disableWebGL = (PDFJS.disableWebGL === undefined ? - true : PDFJS.disableWebGL); - -/** - * Disables fullscreen support, and by extension Presentation Mode, - * in browsers which support the fullscreen API. - * @var {boolean} - */ -PDFJS.disableFullscreen = (PDFJS.disableFullscreen === undefined ? - false : PDFJS.disableFullscreen); - -/** - * Enables CSS only zooming. - * @var {boolean} - */ -PDFJS.useOnlyCssZoom = (PDFJS.useOnlyCssZoom === undefined ? - false : PDFJS.useOnlyCssZoom); - -/** - * The maximum supported canvas size in total pixels e.g. width * height. - * The default value is 4096 * 4096. Use -1 for no limit. - * @var {number} - */ -PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ? - 16777216 : PDFJS.maxCanvasPixels); - -/** - * (Deprecated) Opens external links in a new window if enabled. - * The default behavior opens external links in the PDF.js window. - * - * NOTE: This property has been deprecated, please use - * `PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK` instead. - * @var {boolean} - */ -PDFJS.openExternalLinksInNewWindow = ( - PDFJS.openExternalLinksInNewWindow === undefined ? - false : PDFJS.openExternalLinksInNewWindow); - -/** - * Specifies the |target| attribute for external links. - * The constants from PDFJS.LinkTarget should be used: - * - NONE [default] - * - SELF - * - BLANK - * - PARENT - * - TOP - * @var {number} - */ -PDFJS.externalLinkTarget = (PDFJS.externalLinkTarget === undefined ? - PDFJS.LinkTarget.NONE : PDFJS.externalLinkTarget); - -/** - * Specifies the |rel| attribute for external links. Defaults to stripping - * the referrer. - * @var {string} - */ -PDFJS.externalLinkRel = (PDFJS.externalLinkRel === undefined ? - 'noreferrer' : PDFJS.externalLinkRel); - -/** - * Determines if we can eval strings as JS. Primarily used to improve - * performance for font rendering. - * @var {boolean} - */ -PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ? - true : PDFJS.isEvalSupported); - /** * Document initialization / loading parameters object. * @@ -6401,10 +6231,8 @@ PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ? * * @return {PDFDocumentLoadingTask} */ -PDFJS.getDocument = function getDocument(src, - pdfDataRangeTransport, - passwordCallback, - progressCallback) { +function getDocument(src, pdfDataRangeTransport, + passwordCallback, progressCallback) { var task = new PDFDocumentLoadingTask(); // Support of the obsolete arguments (for compatibility with API v1.0) @@ -6505,7 +6333,7 @@ PDFJS.getDocument = function getDocument(src, }).catch(task._capability.reject); return task; -}; +} /** * Starts fetching of specified PDF document/data. @@ -6522,8 +6350,8 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { return Promise.reject(new Error('Worker was destroyed')); } - source.disableAutoFetch = PDFJS.disableAutoFetch; - source.disableStream = PDFJS.disableStream; + source.disableAutoFetch = getDefaultSetting('disableAutoFetch'); + source.disableStream = getDefaultSetting('disableStream'); source.chunkedViewerLoading = !!pdfDataRangeTransport; if (pdfDataRangeTransport) { source.length = pdfDataRangeTransport.length; @@ -6532,13 +6360,14 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { return worker.messageHandler.sendWithPromise('GetDocRequest', { docId: docId, source: source, - disableRange: PDFJS.disableRange, - maxImageSize: PDFJS.maxImageSize, - cMapUrl: PDFJS.cMapUrl, - cMapPacked: PDFJS.cMapPacked, - disableFontFace: PDFJS.disableFontFace, - disableCreateObjectURL: PDFJS.disableCreateObjectURL, - postMessageTransfers: PDFJS.postMessageTransfers, + disableRange: getDefaultSetting('disableRange'), + maxImageSize: getDefaultSetting('maxImageSize'), + cMapUrl: getDefaultSetting('cMapUrl'), + cMapPacked: getDefaultSetting('cMapPacked'), + disableFontFace: getDefaultSetting('disableFontFace'), + disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'), + postMessageTransfers: getDefaultSetting('postMessageTransfers') && + !isPostMessageTransfersDisabled, }).then(function (workerId) { if (worker.destroyed) { throw new Error('Worker was destroyed'); @@ -6589,7 +6418,7 @@ var PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() { /** * Callback to when unsupported feature is used. The callback receives - * an {PDFJS.UNSUPPORTED_FEATURES} argument. + * an {UNSUPPORTED_FEATURES} argument. */ this.onUnsupportedFeature = null; } @@ -6641,7 +6470,7 @@ var PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() { /** * Abstract class to support range requests file loading. * @class - * @alias PDFJS.PDFDataRangeTransport + * @alias PDFDataRangeTransport * @param {number} length * @param {Uint8Array} initialData */ @@ -6713,8 +6542,6 @@ var PDFDataRangeTransport = (function pdfDataRangeTransportClosure() { return PDFDataRangeTransport; })(); -PDFJS.PDFDataRangeTransport = PDFDataRangeTransport; - /** * Proxy to a PDFDocument in the worker thread. Also, contains commonly used * properties that can be read synchronously. @@ -6917,7 +6744,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { * * @typedef {Object} RenderParameters * @property {Object} canvasContext - A 2D context of a DOM Canvas object. - * @property {PDFJS.PageViewport} viewport - Rendering viewport obtained by + * @property {PageViewport} viewport - Rendering viewport obtained by * calling of PDFPage.getViewport method. * @property {string} intent - Rendering intent, can be 'display' or 'print' * (default value is 'display'). @@ -6951,7 +6778,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { this.pageInfo = pageInfo; this.transport = transport; this.stats = new StatTimer(); - this.stats.enabled = !!globalScope.PDFJS.enableStats; + this.stats.enabled = getDefaultSetting('enableStats'); this.commonObjs = transport.commonObjs; this.objs = new PDFObjects(); this.cleanupAfterRender = false; @@ -6990,14 +6817,14 @@ var PDFPageProxy = (function PDFPageProxyClosure() { * @param {number} scale The desired scale of the viewport. * @param {number} rotate Degrees to rotate the viewport. If omitted this * defaults to the page rotation. - * @return {PDFJS.PageViewport} Contains 'width' and 'height' properties + * @return {PageViewport} Contains 'width' and 'height' properties * along with transforms required for rendering. */ getViewport: function PDFPageProxy_getViewport(scale, rotate) { if (arguments.length < 2) { rotate = this.rotate; } - return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0); + return new PageViewport(this.view, scale, rotate, 0, 0); }, /** * @param {GetAnnotationsParameters} params - Annotation parameters. @@ -7285,8 +7112,11 @@ var PDFWorker = (function PDFWorkerClosure() { var nextFakeWorkerId = 0; function getWorkerSrc() { - if (PDFJS.workerSrc) { - return PDFJS.workerSrc; + if (typeof workerSrc !== 'undefined') { + return workerSrc; + } + if (getDefaultSetting('workerSrc')) { + return getDefaultSetting('workerSrc'); } error('No PDFJS.workerSrc specified'); } @@ -7349,7 +7179,8 @@ var PDFWorker = (function PDFWorkerClosure() { // all requirements to run parts of pdf.js in a web worker. // Right now, the requirement is, that an Uint8Array is still an // Uint8Array as it arrives on the worker. (Chrome added this with v.15.) - if (!globalScope.PDFJS.disableWorker && typeof Worker !== 'undefined') { + if (!isWorkerDisabled && !getDefaultSetting('disableWorker') && + typeof Worker !== 'undefined') { var workerSrc = getWorkerSrc(); try { @@ -7357,11 +7188,32 @@ var PDFWorker = (function PDFWorkerClosure() { // https://bugzilla.mozilla.org/show_bug.cgi?id=683280 var worker = new Worker(workerSrc); var messageHandler = new MessageHandler('main', 'worker', worker); - messageHandler.on('test', function PDFWorker_test(data) { + var terminateEarly = function() { + worker.removeEventListener('error', onWorkerError); + messageHandler.destroy(); + worker.terminate(); if (this.destroyed) { this._readyCapability.reject(new Error('Worker was destroyed')); - messageHandler.destroy(); - worker.terminate(); + } else { + // Fall back to fake worker if the termination is caused by an + // error (e.g. NetworkError / SecurityError). + this._setupFakeWorker(); + } + }.bind(this); + + var onWorkerError = function(event) { + if (!this._webWorker) { + // Worker failed to initialize due to an error. Clean up and fall + // back to the fake worker. + terminateEarly(); + } + }.bind(this); + worker.addEventListener('error', onWorkerError); + + messageHandler.on('test', function PDFWorker_test(data) { + worker.removeEventListener('error', onWorkerError); + if (this.destroyed) { + terminateEarly(); return; // worker was destroyed } var supportTypedArray = data && data.supportTypedArray; @@ -7370,10 +7222,10 @@ var PDFWorker = (function PDFWorkerClosure() { this._port = worker; this._webWorker = worker; if (!data.supportTransfers) { - PDFJS.postMessageTransfers = false; + isPostMessageTransfersDisabled = true; } this._readyCapability.resolve(); - // Send global PDFJS setting, e.g. verbosity level. + // Send global setting, e.g. verbosity level. messageHandler.send('configure', { verbosity: getVerbosityLevel() }); @@ -7392,10 +7244,9 @@ var PDFWorker = (function PDFWorkerClosure() { }); messageHandler.on('ready', function (data) { + worker.removeEventListener('error', onWorkerError); if (this.destroyed) { - this._readyCapability.reject(new Error('Worker was destroyed')); - messageHandler.destroy(); - worker.terminate(); + terminateEarly(); return; // worker was destroyed } try { @@ -7407,8 +7258,10 @@ var PDFWorker = (function PDFWorkerClosure() { }.bind(this)); var sendTest = function () { - var testObj = new Uint8Array( - [PDFJS.postMessageTransfers ? 255 : 0]); + var postMessageTransfers = + getDefaultSetting('postMessageTransfers') && + !isPostMessageTransfersDisabled; + var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]); // Some versions of Opera throw a DATA_CLONE_ERR on serializing the // typed array. Also, checking if we can use transfers. try { @@ -7436,9 +7289,9 @@ var PDFWorker = (function PDFWorkerClosure() { }, _setupFakeWorker: function PDFWorker_setupFakeWorker() { - if (!globalScope.PDFJS.disableWorker) { + if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) { warn('Setting up fake worker.'); - globalScope.PDFJS.disableWorker = true; + isWorkerDisabled = true; } setupFakeWorkerGlobal().then(function (WorkerMessageHandler) { @@ -7501,7 +7354,6 @@ var PDFWorker = (function PDFWorkerClosure() { return PDFWorker; })(); -PDFJS.PDFWorker = PDFWorker; /** * For internal use only. @@ -7701,7 +7553,20 @@ var WorkerTransport = (function WorkerTransportClosure() { this.commonObjs.resolve(id, error); break; } else { - font = new FontFaceObject(exportedData); + var fontRegistry = null; + if (getDefaultSetting('pdfBug') && globalScope.FontInspector && + globalScope['FontInspector'].enabled) { + fontRegistry = { + registerFont: function (font, url) { + globalScope['FontInspector'].fontAdded(font, url); + } + }; + } + font = new FontFaceObject(exportedData, { + isEvalSuported: getDefaultSetting('isEvalSupported'), + disableFontFace: getDefaultSetting('disableFontFace'), + fontRegistry: fontRegistry + }); } this.fontLoader.bind( @@ -7801,7 +7666,7 @@ var WorkerTransport = (function WorkerTransportClosure() { if (loadingTask.onUnsupportedFeature) { loadingTask.onUnsupportedFeature(featureId); } - PDFJS.UnsupportedManager.notify(featureId); + _UnsupportedManager.notify(featureId); }, this); messageHandler.on('JpegDecode', function(data) { @@ -8140,7 +8005,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() { if (this.cancelled) { return; } - if (PDFJS.pdfBug && 'StepperManager' in globalScope && + if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) { this.stepper = globalScope.StepperManager.create(this.pageNumber - 1); this.stepper.init(this.operatorList); @@ -8196,7 +8061,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() { }, _scheduleNext: function InternalRenderTask__scheduleNext() { - if (this.useRequestAnimationFrame) { + if (this.useRequestAnimationFrame && typeof window !== 'undefined') { window.requestAnimationFrame(this._nextBound); } else { Promise.resolve(undefined).then(this._nextBound); @@ -8229,7 +8094,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() { * (Deprecated) Global observer of unsupported feature usages. Use * onUnsupportedFeature callback of the {PDFDocumentLoadingTask} instance. */ -PDFJS.UnsupportedManager = (function UnsupportedManagerClosure() { +var _UnsupportedManager = (function UnsupportedManagerClosure() { var listeners = []; return { listen: function (cb) { @@ -8245,19 +8110,282 @@ PDFJS.UnsupportedManager = (function UnsupportedManagerClosure() { }; })(); -exports.getDocument = PDFJS.getDocument; +if (typeof pdfjsVersion !== 'undefined') { + exports.version = pdfjsVersion; +} +if (typeof pdfjsBuild !== 'undefined') { + exports.build = pdfjsBuild; +} + +exports.getDocument = getDocument; exports.PDFDataRangeTransport = PDFDataRangeTransport; +exports.PDFWorker = PDFWorker; exports.PDFDocumentProxy = PDFDocumentProxy; exports.PDFPageProxy = PDFPageProxy; +exports._UnsupportedManager = _UnsupportedManager; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayGlobal = {}), root.pdfjsSharedUtil, + root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI, + root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer, + root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG); + } +}(this, function (exports, sharedUtil, displayDOMUtils, displayAPI, + displayAnnotationLayer, displayTextLayer, displayMetadata, + displaySVG) { + + var globalScope = sharedUtil.globalScope; + var deprecated = sharedUtil.deprecated; + var warn = sharedUtil.warn; + var LinkTarget = displayDOMUtils.LinkTarget; + + var isWorker = (typeof window === 'undefined'); + + // The global PDFJS object is now deprecated and will not be supported in + // the future. The members below are maintained for backward compatibility + // and shall not be extended or modified. If the global.js is included as + // a module, we will create a global PDFJS object instance or use existing. + if (!globalScope.PDFJS) { + globalScope.PDFJS = {}; + } + var PDFJS = globalScope.PDFJS; + + if (typeof pdfjsVersion !== 'undefined') { + PDFJS.version = pdfjsVersion; + } + if (typeof pdfjsBuild !== 'undefined') { + PDFJS.build = pdfjsBuild; + } + + PDFJS.pdfBug = false; + + if (PDFJS.verbosity !== undefined) { + sharedUtil.setVerbosityLevel(PDFJS.verbosity); + } + delete PDFJS.verbosity; + Object.defineProperty(PDFJS, 'verbosity', { + get: function () { return sharedUtil.getVerbosityLevel(); }, + set: function (level) { sharedUtil.setVerbosityLevel(level); }, + enumerable: true, + configurable: true + }); + + PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS; + PDFJS.OPS = sharedUtil.OPS; + PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES; + PDFJS.isValidUrl = sharedUtil.isValidUrl; + PDFJS.shadow = sharedUtil.shadow; + PDFJS.createBlob = sharedUtil.createBlob; + PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) { + return sharedUtil.createObjectURL(data, contentType, + PDFJS.disableCreateObjectURL); + }; + Object.defineProperty(PDFJS, 'isLittleEndian', { + configurable: true, + get: function PDFJS_isLittleEndian() { + var value = sharedUtil.isLittleEndian(); + return sharedUtil.shadow(PDFJS, 'isLittleEndian', value); + } + }); + PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters; + PDFJS.PasswordResponses = sharedUtil.PasswordResponses; + PDFJS.PasswordException = sharedUtil.PasswordException; + PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException; + PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException; + PDFJS.MissingPDFException = sharedUtil.MissingPDFException; + PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException; + PDFJS.Util = sharedUtil.Util; + PDFJS.PageViewport = sharedUtil.PageViewport; + PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability; + + /** + * The maximum allowed image size in total pixels e.g. width * height. Images + * above this value will not be drawn. Use -1 for no limit. + * @var {number} + */ + PDFJS.maxImageSize = (PDFJS.maxImageSize === undefined ? + -1 : PDFJS.maxImageSize); + + /** + * The url of where the predefined Adobe CMaps are located. Include trailing + * slash. + * @var {string} + */ + PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl); + + /** + * Specifies if CMaps are binary packed. + * @var {boolean} + */ + PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked; + + /** + * By default fonts are converted to OpenType fonts and loaded via font face + * rules. If disabled, the font will be rendered using a built in font + * renderer that constructs the glyphs with primitive path commands. + * @var {boolean} + */ + PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ? + false : PDFJS.disableFontFace); + + /** + * Path for image resources, mainly for annotation icons. Include trailing + * slash. + * @var {string} + */ + PDFJS.imageResourcesPath = (PDFJS.imageResourcesPath === undefined ? + '' : PDFJS.imageResourcesPath); + + /** + * Disable the web worker and run all code on the main thread. This will + * happen automatically if the browser doesn't support workers or sending + * typed arrays to workers. + * @var {boolean} + */ + PDFJS.disableWorker = (PDFJS.disableWorker === undefined ? + false : PDFJS.disableWorker); + + /** + * Path and filename of the worker file. Required when the worker is enabled + * in development mode. If unspecified in the production build, the worker + * will be loaded based on the location of the pdf.js file. It is recommended + * that the workerSrc is set in a custom application to prevent issues caused + * by third-party frameworks and libraries. + * @var {string} + */ + PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc); + + /** + * Disable range request loading of PDF files. When enabled and if the server + * supports partial content requests then the PDF will be fetched in chunks. + * Enabled (false) by default. + * @var {boolean} + */ + PDFJS.disableRange = (PDFJS.disableRange === undefined ? + false : PDFJS.disableRange); + + /** + * Disable streaming of PDF file data. By default PDF.js attempts to load PDF + * in chunks. This default behavior can be disabled. + * @var {boolean} + */ + PDFJS.disableStream = (PDFJS.disableStream === undefined ? + false : PDFJS.disableStream); + + /** + * Disable pre-fetching of PDF file data. When range requests are enabled + * PDF.js will automatically keep fetching more data even if it isn't needed + * to display the current page. This default behavior can be disabled. + * + * NOTE: It is also necessary to disable streaming, see above, + * in order for disabling of pre-fetching to work correctly. + * @var {boolean} + */ + PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ? + false : PDFJS.disableAutoFetch); + + /** + * Enables special hooks for debugging PDF.js. + * @var {boolean} + */ + PDFJS.pdfBug = (PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug); + + /** + * Enables transfer usage in postMessage for ArrayBuffers. + * @var {boolean} + */ + PDFJS.postMessageTransfers = (PDFJS.postMessageTransfers === undefined ? + true : PDFJS.postMessageTransfers); + + /** + * Disables URL.createObjectURL usage. + * @var {boolean} + */ + PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ? + false : PDFJS.disableCreateObjectURL); + + /** + * Disables WebGL usage. + * @var {boolean} + */ + PDFJS.disableWebGL = (PDFJS.disableWebGL === undefined ? + true : PDFJS.disableWebGL); + + /** + * Specifies the |target| attribute for external links. + * The constants from PDFJS.LinkTarget should be used: + * - NONE [default] + * - SELF + * - BLANK + * - PARENT + * - TOP + * @var {number} + */ + PDFJS.externalLinkTarget = (PDFJS.externalLinkTarget === undefined ? + LinkTarget.NONE : PDFJS.externalLinkTarget); + + /** + * Specifies the |rel| attribute for external links. Defaults to stripping + * the referrer. + * @var {string} + */ + PDFJS.externalLinkRel = (PDFJS.externalLinkRel === undefined ? + 'noreferrer' : PDFJS.externalLinkRel); + + /** + * Determines if we can eval strings as JS. Primarily used to improve + * performance for font rendering. + * @var {boolean} + */ + PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ? + true : PDFJS.isEvalSupported); + + + PDFJS.getDocument = displayAPI.getDocument; + PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport; + PDFJS.PDFWorker = displayAPI.PDFWorker; + + Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', { + configurable: true, + get: function PDFJS_hasCanvasTypedArrays() { + var value = displayDOMUtils.hasCanvasTypedArrays(); + return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value); + } + }); + PDFJS.CustomStyle = displayDOMUtils.CustomStyle; + PDFJS.LinkTarget = LinkTarget; + PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes; + PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl; + PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet; + + PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer; + + PDFJS.renderTextLayer = displayTextLayer.renderTextLayer; + + PDFJS.Metadata = displayMetadata.Metadata; + + PDFJS.SVGGraphics = displaySVG.SVGGraphics; + + PDFJS.UnsupportedManager = displayAPI._UnsupportedManager; + + exports.globalScope = globalScope; + exports.isWorker = isWorker; + exports.PDFJS = globalScope.PDFJS; })); }).call(pdfjsLibs); exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS; + exports.build = pdfjsLibs.pdfjsDisplayAPI.build; + exports.version = pdfjsLibs.pdfjsDisplayAPI.version; exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument; exports.PDFDataRangeTransport = pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport; + exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker; exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer; exports.AnnotationLayer = pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer; @@ -8265,8 +8393,19 @@ exports.PDFPageProxy = PDFPageProxy; exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses; exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException; exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException; + exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics; exports.UnexpectedResponseException = pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException; + exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS; + exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES; + exports.isValidUrl = pdfjsLibs.pdfjsSharedUtil.isValidUrl; + exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL; + exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters; + exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow; + exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob; + exports.getFilenameFromUrl = + pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl; + exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes; })); diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js index dc4695c66c95..3fcd86fc478d 100644 --- a/browser/extensions/pdfjs/content/build/pdf.worker.js +++ b/browser/extensions/pdfjs/content/build/pdf.worker.js @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {})); // Use strict in our context only - users might not want it 'use strict'; -var pdfjsVersion = '1.4.185'; -var pdfjsBuild = 'a250c15'; +var pdfjsVersion = '1.4.213'; +var pdfjsBuild = '1c253e6'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? @@ -2634,6 +2634,17 @@ function isLittleEndian() { return (buffer16[0] === 1); } +// Checks if it's possible to eval JS expressions. +function isEvalSupported() { + try { + /* jshint evil: true */ + new Function(''); + return true; + } catch (e) { + return false; + } +} + var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; @@ -2888,7 +2899,7 @@ var Util = (function UtilClosure() { /** * PDF page viewport created based on scale, rotation and offset. * @class - * @alias PDFJS.PageViewport + * @alias PageViewport */ var PageViewport = (function PageViewportClosure() { /** @@ -2964,13 +2975,13 @@ var PageViewport = (function PageViewportClosure() { this.height = height; this.fontScale = scale; } - PageViewport.prototype = /** @lends PDFJS.PageViewport.prototype */ { + PageViewport.prototype = /** @lends PageViewport.prototype */ { /** * Clones viewport with additional properties. * @param args {Object} (optional) If specified, may contain the 'scale' or * 'rotation' properties to override the corresponding properties in * the cloned viewport. - * @returns {PDFJS.PageViewport} Cloned viewport. + * @returns {PageViewport} Cloned viewport. */ clone: function PageViewPort_clone(args) { args = args || {}; @@ -3100,7 +3111,7 @@ function isArrayBuffer(v) { /** * Creates a promise capability object. - * @alias PDFJS.createPromiseCapability + * @alias createPromiseCapability * * @return {PromiseCapability} A capability object contains: * - a Promise, resolve and reject methods. @@ -3464,6 +3475,7 @@ exports.isString = isString; exports.isSameOrigin = isSameOrigin; exports.isValidUrl = isValidUrl; exports.isLittleEndian = isLittleEndian; +exports.isEvalSupported = isEvalSupported; exports.loadJpegStream = loadJpegStream; exports.log2 = log2; exports.readInt8 = readInt8; @@ -3481,6 +3493,1631 @@ exports.warn = warn; })); +(function (root, factory) { + { + factory((root.pdfjsCoreCFFParser = {}), root.pdfjsSharedUtil, + root.pdfjsCoreCharsets, root.pdfjsCoreEncodings); + } +}(this, function (exports, sharedUtil, coreCharsets, coreEncodings) { + +var error = sharedUtil.error; +var info = sharedUtil.info; +var bytesToString = sharedUtil.bytesToString; +var warn = sharedUtil.warn; +var isArray = sharedUtil.isArray; +var Util = sharedUtil.Util; +var stringToBytes = sharedUtil.stringToBytes; +var assert = sharedUtil.assert; +var ISOAdobeCharset = coreCharsets.ISOAdobeCharset; +var ExpertCharset = coreCharsets.ExpertCharset; +var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset; +var StandardEncoding = coreEncodings.StandardEncoding; +var ExpertEncoding = coreEncodings.ExpertEncoding; + +// Maximum subroutine call depth of type 2 chartrings. Matches OTS. +var MAX_SUBR_NESTING = 10; + +/** + * The CFF class takes a Type1 file and wrap it into a + * 'Compact Font Format' which itself embed Type2 charstrings. + */ +var CFFStandardStrings = [ + '.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent', + 'ampersand', 'quoteright', 'parenleft', 'parenright', 'asterisk', 'plus', + 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four', + 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less', + 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright', 'asciicircum', + 'underscore', 'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', + 'z', 'braceleft', 'bar', 'braceright', 'asciitilde', 'exclamdown', 'cent', + 'sterling', 'fraction', 'yen', 'florin', 'section', 'currency', + 'quotesingle', 'quotedblleft', 'guillemotleft', 'guilsinglleft', + 'guilsinglright', 'fi', 'fl', 'endash', 'dagger', 'daggerdbl', + 'periodcentered', 'paragraph', 'bullet', 'quotesinglbase', 'quotedblbase', + 'quotedblright', 'guillemotright', 'ellipsis', 'perthousand', 'questiondown', + 'grave', 'acute', 'circumflex', 'tilde', 'macron', 'breve', 'dotaccent', + 'dieresis', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron', 'emdash', + 'AE', 'ordfeminine', 'Lslash', 'Oslash', 'OE', 'ordmasculine', 'ae', + 'dotlessi', 'lslash', 'oslash', 'oe', 'germandbls', 'onesuperior', + 'logicalnot', 'mu', 'trademark', 'Eth', 'onehalf', 'plusminus', 'Thorn', + 'onequarter', 'divide', 'brokenbar', 'degree', 'thorn', 'threequarters', + 'twosuperior', 'registered', 'minus', 'eth', 'multiply', 'threesuperior', + 'copyright', 'Aacute', 'Acircumflex', 'Adieresis', 'Agrave', 'Aring', + 'Atilde', 'Ccedilla', 'Eacute', 'Ecircumflex', 'Edieresis', 'Egrave', + 'Iacute', 'Icircumflex', 'Idieresis', 'Igrave', 'Ntilde', 'Oacute', + 'Ocircumflex', 'Odieresis', 'Ograve', 'Otilde', 'Scaron', 'Uacute', + 'Ucircumflex', 'Udieresis', 'Ugrave', 'Yacute', 'Ydieresis', 'Zcaron', + 'aacute', 'acircumflex', 'adieresis', 'agrave', 'aring', 'atilde', + 'ccedilla', 'eacute', 'ecircumflex', 'edieresis', 'egrave', 'iacute', + 'icircumflex', 'idieresis', 'igrave', 'ntilde', 'oacute', 'ocircumflex', + 'odieresis', 'ograve', 'otilde', 'scaron', 'uacute', 'ucircumflex', + 'udieresis', 'ugrave', 'yacute', 'ydieresis', 'zcaron', 'exclamsmall', + 'Hungarumlautsmall', 'dollaroldstyle', 'dollarsuperior', 'ampersandsmall', + 'Acutesmall', 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader', + 'onedotenleader', 'zerooldstyle', 'oneoldstyle', 'twooldstyle', + 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle', + 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'commasuperior', + 'threequartersemdash', 'periodsuperior', 'questionsmall', 'asuperior', + 'bsuperior', 'centsuperior', 'dsuperior', 'esuperior', 'isuperior', + 'lsuperior', 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior', + 'tsuperior', 'ff', 'ffi', 'ffl', 'parenleftinferior', 'parenrightinferior', + 'Circumflexsmall', 'hyphensuperior', 'Gravesmall', 'Asmall', 'Bsmall', + 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall', + 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall', + 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall', + 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', 'onefitted', 'rupiah', + 'Tildesmall', 'exclamdownsmall', 'centoldstyle', 'Lslashsmall', + 'Scaronsmall', 'Zcaronsmall', 'Dieresissmall', 'Brevesmall', 'Caronsmall', + 'Dotaccentsmall', 'Macronsmall', 'figuredash', 'hypheninferior', + 'Ogoneksmall', 'Ringsmall', 'Cedillasmall', 'questiondownsmall', 'oneeighth', + 'threeeighths', 'fiveeighths', 'seveneighths', 'onethird', 'twothirds', + 'zerosuperior', 'foursuperior', 'fivesuperior', 'sixsuperior', + 'sevensuperior', 'eightsuperior', 'ninesuperior', 'zeroinferior', + 'oneinferior', 'twoinferior', 'threeinferior', 'fourinferior', + 'fiveinferior', 'sixinferior', 'seveninferior', 'eightinferior', + 'nineinferior', 'centinferior', 'dollarinferior', 'periodinferior', + 'commainferior', 'Agravesmall', 'Aacutesmall', 'Acircumflexsmall', + 'Atildesmall', 'Adieresissmall', 'Aringsmall', 'AEsmall', 'Ccedillasmall', + 'Egravesmall', 'Eacutesmall', 'Ecircumflexsmall', 'Edieresissmall', + 'Igravesmall', 'Iacutesmall', 'Icircumflexsmall', 'Idieresissmall', + 'Ethsmall', 'Ntildesmall', 'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall', + 'Otildesmall', 'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall', + 'Uacutesmall', 'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall', + 'Thornsmall', 'Ydieresissmall', '001.000', '001.001', '001.002', '001.003', + 'Black', 'Bold', 'Book', 'Light', 'Medium', 'Regular', 'Roman', 'Semibold' +]; + + +var CFFParser = (function CFFParserClosure() { + var CharstringValidationData = [ + null, + { id: 'hstem', min: 2, stackClearing: true, stem: true }, + null, + { id: 'vstem', min: 2, stackClearing: true, stem: true }, + { id: 'vmoveto', min: 1, stackClearing: true }, + { id: 'rlineto', min: 2, resetStack: true }, + { id: 'hlineto', min: 1, resetStack: true }, + { id: 'vlineto', min: 1, resetStack: true }, + { id: 'rrcurveto', min: 6, resetStack: true }, + null, + { id: 'callsubr', min: 1, undefStack: true }, + { id: 'return', min: 0, undefStack: true }, + null, // 12 + null, + { id: 'endchar', min: 0, stackClearing: true }, + null, + null, + null, + { id: 'hstemhm', min: 2, stackClearing: true, stem: true }, + { id: 'hintmask', min: 0, stackClearing: true }, + { id: 'cntrmask', min: 0, stackClearing: true }, + { id: 'rmoveto', min: 2, stackClearing: true }, + { id: 'hmoveto', min: 1, stackClearing: true }, + { id: 'vstemhm', min: 2, stackClearing: true, stem: true }, + { id: 'rcurveline', min: 8, resetStack: true }, + { id: 'rlinecurve', min: 8, resetStack: true }, + { id: 'vvcurveto', min: 4, resetStack: true }, + { id: 'hhcurveto', min: 4, resetStack: true }, + null, // shortint + { id: 'callgsubr', min: 1, undefStack: true }, + { id: 'vhcurveto', min: 4, resetStack: true }, + { id: 'hvcurveto', min: 4, resetStack: true } + ]; + var CharstringValidationData12 = [ + null, + null, + null, + { id: 'and', min: 2, stackDelta: -1 }, + { id: 'or', min: 2, stackDelta: -1 }, + { id: 'not', min: 1, stackDelta: 0 }, + null, + null, + null, + { id: 'abs', min: 1, stackDelta: 0 }, + { id: 'add', min: 2, stackDelta: -1, + stackFn: function stack_div(stack, index) { + stack[index - 2] = stack[index - 2] + stack[index - 1]; + } + }, + { id: 'sub', min: 2, stackDelta: -1, + stackFn: function stack_div(stack, index) { + stack[index - 2] = stack[index - 2] - stack[index - 1]; + } + }, + { id: 'div', min: 2, stackDelta: -1, + stackFn: function stack_div(stack, index) { + stack[index - 2] = stack[index - 2] / stack[index - 1]; + } + }, + null, + { id: 'neg', min: 1, stackDelta: 0, + stackFn: function stack_div(stack, index) { + stack[index - 1] = -stack[index - 1]; + } + }, + { id: 'eq', min: 2, stackDelta: -1 }, + null, + null, + { id: 'drop', min: 1, stackDelta: -1 }, + null, + { id: 'put', min: 2, stackDelta: -2 }, + { id: 'get', min: 1, stackDelta: 0 }, + { id: 'ifelse', min: 4, stackDelta: -3 }, + { id: 'random', min: 0, stackDelta: 1 }, + { id: 'mul', min: 2, stackDelta: -1, + stackFn: function stack_div(stack, index) { + stack[index - 2] = stack[index - 2] * stack[index - 1]; + } + }, + null, + { id: 'sqrt', min: 1, stackDelta: 0 }, + { id: 'dup', min: 1, stackDelta: 1 }, + { id: 'exch', min: 2, stackDelta: 0 }, + { id: 'index', min: 2, stackDelta: 0 }, + { id: 'roll', min: 3, stackDelta: -2 }, + null, + null, + null, + { id: 'hflex', min: 7, resetStack: true }, + { id: 'flex', min: 13, resetStack: true }, + { id: 'hflex1', min: 9, resetStack: true }, + { id: 'flex1', min: 11, resetStack: true } + ]; + + function CFFParser(file, properties, seacAnalysisEnabled) { + this.bytes = file.getBytes(); + this.properties = properties; + this.seacAnalysisEnabled = !!seacAnalysisEnabled; + } + CFFParser.prototype = { + parse: function CFFParser_parse() { + var properties = this.properties; + var cff = new CFF(); + this.cff = cff; + + // The first five sections must be in order, all the others are reached + // via offsets contained in one of the below. + var header = this.parseHeader(); + var nameIndex = this.parseIndex(header.endPos); + var topDictIndex = this.parseIndex(nameIndex.endPos); + var stringIndex = this.parseIndex(topDictIndex.endPos); + var globalSubrIndex = this.parseIndex(stringIndex.endPos); + + var topDictParsed = this.parseDict(topDictIndex.obj.get(0)); + var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings); + + cff.header = header.obj; + cff.names = this.parseNameIndex(nameIndex.obj); + cff.strings = this.parseStringIndex(stringIndex.obj); + cff.topDict = topDict; + cff.globalSubrIndex = globalSubrIndex.obj; + + this.parsePrivateDict(cff.topDict); + + cff.isCIDFont = topDict.hasName('ROS'); + + var charStringOffset = topDict.getByName('CharStrings'); + var charStringIndex = this.parseIndex(charStringOffset).obj; + + var fontMatrix = topDict.getByName('FontMatrix'); + if (fontMatrix) { + properties.fontMatrix = fontMatrix; + } + + var fontBBox = topDict.getByName('FontBBox'); + if (fontBBox) { + // adjusting ascent/descent + properties.ascent = fontBBox[3]; + properties.descent = fontBBox[1]; + properties.ascentScaled = true; + } + + var charset, encoding; + if (cff.isCIDFont) { + var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj; + for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) { + var dictRaw = fdArrayIndex.get(i); + var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), + cff.strings); + this.parsePrivateDict(fontDict); + cff.fdArray.push(fontDict); + } + // cid fonts don't have an encoding + encoding = null; + charset = this.parseCharsets(topDict.getByName('charset'), + charStringIndex.count, cff.strings, true); + cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), + charStringIndex.count); + } else { + charset = this.parseCharsets(topDict.getByName('charset'), + charStringIndex.count, cff.strings, false); + encoding = this.parseEncoding(topDict.getByName('Encoding'), + properties, + cff.strings, charset.charset); + } + + cff.charset = charset; + cff.encoding = encoding; + + var charStringsAndSeacs = this.parseCharStrings( + charStringIndex, + topDict.privateDict.subrsIndex, + globalSubrIndex.obj, + cff.fdSelect, + cff.fdArray); + cff.charStrings = charStringsAndSeacs.charStrings; + cff.seacs = charStringsAndSeacs.seacs; + cff.widths = charStringsAndSeacs.widths; + + return cff; + }, + parseHeader: function CFFParser_parseHeader() { + var bytes = this.bytes; + var bytesLength = bytes.length; + var offset = 0; + + // Prevent an infinite loop, by checking that the offset is within the + // bounds of the bytes array. Necessary in empty, or invalid, font files. + while (offset < bytesLength && bytes[offset] !== 1) { + ++offset; + } + if (offset >= bytesLength) { + error('Invalid CFF header'); + } else if (offset !== 0) { + info('cff data is shifted'); + bytes = bytes.subarray(offset); + this.bytes = bytes; + } + var major = bytes[0]; + var minor = bytes[1]; + var hdrSize = bytes[2]; + var offSize = bytes[3]; + var header = new CFFHeader(major, minor, hdrSize, offSize); + return { obj: header, endPos: hdrSize }; + }, + parseDict: function CFFParser_parseDict(dict) { + var pos = 0; + + function parseOperand() { + var value = dict[pos++]; + if (value === 30) { + return parseFloatOperand(pos); + } else if (value === 28) { + value = dict[pos++]; + value = ((value << 24) | (dict[pos++] << 16)) >> 16; + return value; + } else if (value === 29) { + value = dict[pos++]; + value = (value << 8) | dict[pos++]; + value = (value << 8) | dict[pos++]; + value = (value << 8) | dict[pos++]; + return value; + } else if (value >= 32 && value <= 246) { + return value - 139; + } else if (value >= 247 && value <= 250) { + return ((value - 247) * 256) + dict[pos++] + 108; + } else if (value >= 251 && value <= 254) { + return -((value - 251) * 256) - dict[pos++] - 108; + } else { + error('255 is not a valid DICT command'); + } + return -1; + } + + function parseFloatOperand() { + var str = ''; + var eof = 15; + var lookup = ['0', '1', '2', '3', '4', '5', '6', '7', '8', + '9', '.', 'E', 'E-', null, '-']; + var length = dict.length; + while (pos < length) { + var b = dict[pos++]; + var b1 = b >> 4; + var b2 = b & 15; + + if (b1 === eof) { + break; + } + str += lookup[b1]; + + if (b2 === eof) { + break; + } + str += lookup[b2]; + } + return parseFloat(str); + } + + var operands = []; + var entries = []; + + pos = 0; + var end = dict.length; + while (pos < end) { + var b = dict[pos]; + if (b <= 21) { + if (b === 12) { + b = (b << 8) | dict[++pos]; + } + entries.push([b, operands]); + operands = []; + ++pos; + } else { + operands.push(parseOperand()); + } + } + return entries; + }, + parseIndex: function CFFParser_parseIndex(pos) { + var cffIndex = new CFFIndex(); + var bytes = this.bytes; + var count = (bytes[pos++] << 8) | bytes[pos++]; + var offsets = []; + var end = pos; + var i, ii; + + if (count !== 0) { + var offsetSize = bytes[pos++]; + // add 1 for offset to determine size of last object + var startPos = pos + ((count + 1) * offsetSize) - 1; + + for (i = 0, ii = count + 1; i < ii; ++i) { + var offset = 0; + for (var j = 0; j < offsetSize; ++j) { + offset <<= 8; + offset += bytes[pos++]; + } + offsets.push(startPos + offset); + } + end = offsets[count]; + } + for (i = 0, ii = offsets.length - 1; i < ii; ++i) { + var offsetStart = offsets[i]; + var offsetEnd = offsets[i + 1]; + cffIndex.add(bytes.subarray(offsetStart, offsetEnd)); + } + return {obj: cffIndex, endPos: end}; + }, + parseNameIndex: function CFFParser_parseNameIndex(index) { + var names = []; + for (var i = 0, ii = index.count; i < ii; ++i) { + var name = index.get(i); + // OTS doesn't allow names to be over 127 characters. + var length = Math.min(name.length, 127); + var data = []; + // OTS also only permits certain characters in the name. + for (var j = 0; j < length; ++j) { + var c = name[j]; + if (j === 0 && c === 0) { + data[j] = c; + continue; + } + if ((c < 33 || c > 126) || c === 91 /* [ */ || c === 93 /* ] */ || + c === 40 /* ( */ || c === 41 /* ) */ || c === 123 /* { */ || + c === 125 /* } */ || c === 60 /* < */ || c === 62 /* > */ || + c === 47 /* / */ || c === 37 /* % */ || c === 35 /* # */) { + data[j] = 95; + continue; + } + data[j] = c; + } + names.push(bytesToString(data)); + } + return names; + }, + parseStringIndex: function CFFParser_parseStringIndex(index) { + var strings = new CFFStrings(); + for (var i = 0, ii = index.count; i < ii; ++i) { + var data = index.get(i); + strings.add(bytesToString(data)); + } + return strings; + }, + createDict: function CFFParser_createDict(Type, dict, strings) { + var cffDict = new Type(strings); + for (var i = 0, ii = dict.length; i < ii; ++i) { + var pair = dict[i]; + var key = pair[0]; + var value = pair[1]; + cffDict.setByKey(key, value); + } + return cffDict; + }, + parseCharString: function CFFParser_parseCharString(state, data, + localSubrIndex, + globalSubrIndex) { + if (state.callDepth > MAX_SUBR_NESTING) { + return false; + } + var stackSize = state.stackSize; + var stack = state.stack; + + var length = data.length; + + for (var j = 0; j < length;) { + var value = data[j++]; + var validationCommand = null; + if (value === 12) { + var q = data[j++]; + if (q === 0) { + // The CFF specification state that the 'dotsection' command + // (12, 0) is deprecated and treated as a no-op, but all Type2 + // charstrings processors should support them. Unfortunately + // the font sanitizer don't. As a workaround the sequence (12, 0) + // is replaced by a useless (0, hmoveto). + data[j - 2] = 139; + data[j - 1] = 22; + stackSize = 0; + } else { + validationCommand = CharstringValidationData12[q]; + } + } else if (value === 28) { // number (16 bit) + stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16)) >> 16; + j += 2; + stackSize++; + } else if (value === 14) { + if (stackSize >= 4) { + stackSize -= 4; + if (this.seacAnalysisEnabled) { + state.seac = stack.slice(stackSize, stackSize + 4); + return false; + } + } + validationCommand = CharstringValidationData[value]; + } else if (value >= 32 && value <= 246) { // number + stack[stackSize] = value - 139; + stackSize++; + } else if (value >= 247 && value <= 254) { // number (+1 bytes) + stack[stackSize] = (value < 251 ? + ((value - 247) << 8) + data[j] + 108 : + -((value - 251) << 8) - data[j] - 108); + j++; + stackSize++; + } else if (value === 255) { // number (32 bit) + stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16) | + (data[j + 2] << 8) | data[j + 3]) / 65536; + j += 4; + stackSize++; + } else if (value === 19 || value === 20) { + state.hints += stackSize >> 1; + // skipping right amount of hints flag data + j += (state.hints + 7) >> 3; + stackSize %= 2; + validationCommand = CharstringValidationData[value]; + } else if (value === 10 || value === 29) { + var subrsIndex; + if (value === 10) { + subrsIndex = localSubrIndex; + } else { + subrsIndex = globalSubrIndex; + } + if (!subrsIndex) { + validationCommand = CharstringValidationData[value]; + warn('Missing subrsIndex for ' + validationCommand.id); + return false; + } + var bias = 32768; + if (subrsIndex.count < 1240) { + bias = 107; + } else if (subrsIndex.count < 33900) { + bias = 1131; + } + var subrNumber = stack[--stackSize] + bias; + if (subrNumber < 0 || subrNumber >= subrsIndex.count) { + validationCommand = CharstringValidationData[value]; + warn('Out of bounds subrIndex for ' + validationCommand.id); + return false; + } + state.stackSize = stackSize; + state.callDepth++; + var valid = this.parseCharString(state, subrsIndex.get(subrNumber), + localSubrIndex, globalSubrIndex); + if (!valid) { + return false; + } + state.callDepth--; + stackSize = state.stackSize; + continue; + } else if (value === 11) { + state.stackSize = stackSize; + return true; + } else { + validationCommand = CharstringValidationData[value]; + } + if (validationCommand) { + if (validationCommand.stem) { + state.hints += stackSize >> 1; + } + if ('min' in validationCommand) { + if (!state.undefStack && stackSize < validationCommand.min) { + warn('Not enough parameters for ' + validationCommand.id + + '; actual: ' + stackSize + + ', expected: ' + validationCommand.min); + return false; + } + } + if (state.firstStackClearing && validationCommand.stackClearing) { + state.firstStackClearing = false; + // the optional character width can be found before the first + // stack-clearing command arguments + stackSize -= validationCommand.min; + if (stackSize >= 2 && validationCommand.stem) { + // there are even amount of arguments for stem commands + stackSize %= 2; + } else if (stackSize > 1) { + warn('Found too many parameters for stack-clearing command'); + } + if (stackSize > 0 && stack[stackSize - 1] >= 0) { + state.width = stack[stackSize - 1]; + } + } + if ('stackDelta' in validationCommand) { + if ('stackFn' in validationCommand) { + validationCommand.stackFn(stack, stackSize); + } + stackSize += validationCommand.stackDelta; + } else if (validationCommand.stackClearing) { + stackSize = 0; + } else if (validationCommand.resetStack) { + stackSize = 0; + state.undefStack = false; + } else if (validationCommand.undefStack) { + stackSize = 0; + state.undefStack = true; + state.firstStackClearing = false; + } + } + } + state.stackSize = stackSize; + return true; + }, + parseCharStrings: function CFFParser_parseCharStrings(charStrings, + localSubrIndex, + globalSubrIndex, + fdSelect, + fdArray) { + var seacs = []; + var widths = []; + var count = charStrings.count; + for (var i = 0; i < count; i++) { + var charstring = charStrings.get(i); + var state = { + callDepth: 0, + stackSize: 0, + stack: [], + undefStack: true, + hints: 0, + firstStackClearing: true, + seac: null, + width: null + }; + var valid = true; + var localSubrToUse = null; + if (fdSelect && fdArray.length) { + var fdIndex = fdSelect.getFDIndex(i); + if (fdIndex === -1) { + warn('Glyph index is not in fd select.'); + valid = false; + } + if (fdIndex >= fdArray.length) { + warn('Invalid fd index for glyph index.'); + valid = false; + } + if (valid) { + localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex; + } + } else if (localSubrIndex) { + localSubrToUse = localSubrIndex; + } + if (valid) { + valid = this.parseCharString(state, charstring, localSubrToUse, + globalSubrIndex); + } + if (state.width !== null) { + widths[i] = state.width; + } + if (state.seac !== null) { + seacs[i] = state.seac; + } + if (!valid) { + // resetting invalid charstring to single 'endchar' + charStrings.set(i, new Uint8Array([14])); + } + } + return { charStrings: charStrings, seacs: seacs, widths: widths }; + }, + emptyPrivateDictionary: + function CFFParser_emptyPrivateDictionary(parentDict) { + var privateDict = this.createDict(CFFPrivateDict, [], + parentDict.strings); + parentDict.setByKey(18, [0, 0]); + parentDict.privateDict = privateDict; + }, + parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) { + // no private dict, do nothing + if (!parentDict.hasName('Private')) { + this.emptyPrivateDictionary(parentDict); + return; + } + var privateOffset = parentDict.getByName('Private'); + // make sure the params are formatted correctly + if (!isArray(privateOffset) || privateOffset.length !== 2) { + parentDict.removeByName('Private'); + return; + } + var size = privateOffset[0]; + var offset = privateOffset[1]; + // remove empty dicts or ones that refer to invalid location + if (size === 0 || offset >= this.bytes.length) { + this.emptyPrivateDictionary(parentDict); + return; + } + + var privateDictEnd = offset + size; + var dictData = this.bytes.subarray(offset, privateDictEnd); + var dict = this.parseDict(dictData); + var privateDict = this.createDict(CFFPrivateDict, dict, + parentDict.strings); + parentDict.privateDict = privateDict; + + // Parse the Subrs index also since it's relative to the private dict. + if (!privateDict.getByName('Subrs')) { + return; + } + var subrsOffset = privateDict.getByName('Subrs'); + var relativeOffset = offset + subrsOffset; + // Validate the offset. + if (subrsOffset === 0 || relativeOffset >= this.bytes.length) { + this.emptyPrivateDictionary(parentDict); + return; + } + var subrsIndex = this.parseIndex(relativeOffset); + privateDict.subrsIndex = subrsIndex.obj; + }, + parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) { + if (pos === 0) { + return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, + ISOAdobeCharset); + } else if (pos === 1) { + return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, + ExpertCharset); + } else if (pos === 2) { + return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, + ExpertSubsetCharset); + } + + var bytes = this.bytes; + var start = pos; + var format = bytes[pos++]; + var charset = ['.notdef']; + var id, count, i; + + // subtract 1 for the .notdef glyph + length -= 1; + + switch (format) { + case 0: + for (i = 0; i < length; i++) { + id = (bytes[pos++] << 8) | bytes[pos++]; + charset.push(cid ? id : strings.get(id)); + } + break; + case 1: + while (charset.length <= length) { + id = (bytes[pos++] << 8) | bytes[pos++]; + count = bytes[pos++]; + for (i = 0; i <= count; i++) { + charset.push(cid ? id++ : strings.get(id++)); + } + } + break; + case 2: + while (charset.length <= length) { + id = (bytes[pos++] << 8) | bytes[pos++]; + count = (bytes[pos++] << 8) | bytes[pos++]; + for (i = 0; i <= count; i++) { + charset.push(cid ? id++ : strings.get(id++)); + } + } + break; + default: + error('Unknown charset format'); + } + // Raw won't be needed if we actually compile the charset. + var end = pos; + var raw = bytes.subarray(start, end); + + return new CFFCharset(false, format, charset, raw); + }, + parseEncoding: function CFFParser_parseEncoding(pos, + properties, + strings, + charset) { + var encoding = Object.create(null); + var bytes = this.bytes; + var predefined = false; + var hasSupplement = false; + var format, i, ii; + var raw = null; + + function readSupplement() { + var supplementsCount = bytes[pos++]; + for (i = 0; i < supplementsCount; i++) { + var code = bytes[pos++]; + var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff); + encoding[code] = charset.indexOf(strings.get(sid)); + } + } + + if (pos === 0 || pos === 1) { + predefined = true; + format = pos; + var baseEncoding = pos ? ExpertEncoding : StandardEncoding; + for (i = 0, ii = charset.length; i < ii; i++) { + var index = baseEncoding.indexOf(charset[i]); + if (index !== -1) { + encoding[index] = i; + } + } + } else { + var dataStart = pos; + format = bytes[pos++]; + switch (format & 0x7f) { + case 0: + var glyphsCount = bytes[pos++]; + for (i = 1; i <= glyphsCount; i++) { + encoding[bytes[pos++]] = i; + } + break; + + case 1: + var rangesCount = bytes[pos++]; + var gid = 1; + for (i = 0; i < rangesCount; i++) { + var start = bytes[pos++]; + var left = bytes[pos++]; + for (var j = start; j <= start + left; j++) { + encoding[j] = gid++; + } + } + break; + + default: + error('Unknow encoding format: ' + format + ' in CFF'); + break; + } + var dataEnd = pos; + if (format & 0x80) { + // The font sanitizer does not support CFF encoding with a + // supplement, since the encoding is not really used to map + // between gid to glyph, let's overwrite what is declared in + // the top dictionary to let the sanitizer think the font use + // StandardEncoding, that's a lie but that's ok. + bytes[dataStart] &= 0x7f; + readSupplement(); + hasSupplement = true; + } + raw = bytes.subarray(dataStart, dataEnd); + } + format = format & 0x7f; + return new CFFEncoding(predefined, format, encoding, raw); + }, + parseFDSelect: function CFFParser_parseFDSelect(pos, length) { + var start = pos; + var bytes = this.bytes; + var format = bytes[pos++]; + var fdSelect = []; + var i; + + switch (format) { + case 0: + for (i = 0; i < length; ++i) { + var id = bytes[pos++]; + fdSelect.push(id); + } + break; + case 3: + var rangesCount = (bytes[pos++] << 8) | bytes[pos++]; + for (i = 0; i < rangesCount; ++i) { + var first = (bytes[pos++] << 8) | bytes[pos++]; + var fdIndex = bytes[pos++]; + var next = (bytes[pos] << 8) | bytes[pos + 1]; + for (var j = first; j < next; ++j) { + fdSelect.push(fdIndex); + } + } + // Advance past the sentinel(next). + pos += 2; + break; + default: + error('Unknown fdselect format ' + format); + break; + } + var end = pos; + return new CFFFDSelect(fdSelect, bytes.subarray(start, end)); + } + }; + return CFFParser; +})(); + +// Compact Font Format +var CFF = (function CFFClosure() { + function CFF() { + this.header = null; + this.names = []; + this.topDict = null; + this.strings = new CFFStrings(); + this.globalSubrIndex = null; + + // The following could really be per font, but since we only have one font + // store them here. + this.encoding = null; + this.charset = null; + this.charStrings = null; + this.fdArray = []; + this.fdSelect = null; + + this.isCIDFont = false; + } + return CFF; +})(); + +var CFFHeader = (function CFFHeaderClosure() { + function CFFHeader(major, minor, hdrSize, offSize) { + this.major = major; + this.minor = minor; + this.hdrSize = hdrSize; + this.offSize = offSize; + } + return CFFHeader; +})(); + +var CFFStrings = (function CFFStringsClosure() { + function CFFStrings() { + this.strings = []; + } + CFFStrings.prototype = { + get: function CFFStrings_get(index) { + if (index >= 0 && index <= 390) { + return CFFStandardStrings[index]; + } + if (index - 391 <= this.strings.length) { + return this.strings[index - 391]; + } + return CFFStandardStrings[0]; + }, + add: function CFFStrings_add(value) { + this.strings.push(value); + }, + get count() { + return this.strings.length; + } + }; + return CFFStrings; +})(); + +var CFFIndex = (function CFFIndexClosure() { + function CFFIndex() { + this.objects = []; + this.length = 0; + } + CFFIndex.prototype = { + add: function CFFIndex_add(data) { + this.length += data.length; + this.objects.push(data); + }, + set: function CFFIndex_set(index, data) { + this.length += data.length - this.objects[index].length; + this.objects[index] = data; + }, + get: function CFFIndex_get(index) { + return this.objects[index]; + }, + get count() { + return this.objects.length; + } + }; + return CFFIndex; +})(); + +var CFFDict = (function CFFDictClosure() { + function CFFDict(tables, strings) { + this.keyToNameMap = tables.keyToNameMap; + this.nameToKeyMap = tables.nameToKeyMap; + this.defaults = tables.defaults; + this.types = tables.types; + this.opcodes = tables.opcodes; + this.order = tables.order; + this.strings = strings; + this.values = Object.create(null); + } + CFFDict.prototype = { + // value should always be an array + setByKey: function CFFDict_setByKey(key, value) { + if (!(key in this.keyToNameMap)) { + return false; + } + // ignore empty values + if (value.length === 0) { + return true; + } + var type = this.types[key]; + // remove the array wrapping these types of values + if (type === 'num' || type === 'sid' || type === 'offset') { + value = value[0]; + } + this.values[key] = value; + return true; + }, + setByName: function CFFDict_setByName(name, value) { + if (!(name in this.nameToKeyMap)) { + error('Invalid dictionary name "' + name + '"'); + } + this.values[this.nameToKeyMap[name]] = value; + }, + hasName: function CFFDict_hasName(name) { + return this.nameToKeyMap[name] in this.values; + }, + getByName: function CFFDict_getByName(name) { + if (!(name in this.nameToKeyMap)) { + error('Invalid dictionary name "' + name + '"'); + } + var key = this.nameToKeyMap[name]; + if (!(key in this.values)) { + return this.defaults[key]; + } + return this.values[key]; + }, + removeByName: function CFFDict_removeByName(name) { + delete this.values[this.nameToKeyMap[name]]; + } + }; + CFFDict.createTables = function CFFDict_createTables(layout) { + var tables = { + keyToNameMap: {}, + nameToKeyMap: {}, + defaults: {}, + types: {}, + opcodes: {}, + order: [] + }; + for (var i = 0, ii = layout.length; i < ii; ++i) { + var entry = layout[i]; + var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0]; + tables.keyToNameMap[key] = entry[1]; + tables.nameToKeyMap[entry[1]] = key; + tables.types[key] = entry[2]; + tables.defaults[key] = entry[3]; + tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]]; + tables.order.push(key); + } + return tables; + }; + return CFFDict; +})(); + +var CFFTopDict = (function CFFTopDictClosure() { + var layout = [ + [[12, 30], 'ROS', ['sid', 'sid', 'num'], null], + [[12, 20], 'SyntheticBase', 'num', null], + [0, 'version', 'sid', null], + [1, 'Notice', 'sid', null], + [[12, 0], 'Copyright', 'sid', null], + [2, 'FullName', 'sid', null], + [3, 'FamilyName', 'sid', null], + [4, 'Weight', 'sid', null], + [[12, 1], 'isFixedPitch', 'num', 0], + [[12, 2], 'ItalicAngle', 'num', 0], + [[12, 3], 'UnderlinePosition', 'num', -100], + [[12, 4], 'UnderlineThickness', 'num', 50], + [[12, 5], 'PaintType', 'num', 0], + [[12, 6], 'CharstringType', 'num', 2], + [[12, 7], 'FontMatrix', ['num', 'num', 'num', 'num', 'num', 'num'], + [0.001, 0, 0, 0.001, 0, 0]], + [13, 'UniqueID', 'num', null], + [5, 'FontBBox', ['num', 'num', 'num', 'num'], [0, 0, 0, 0]], + [[12, 8], 'StrokeWidth', 'num', 0], + [14, 'XUID', 'array', null], + [15, 'charset', 'offset', 0], + [16, 'Encoding', 'offset', 0], + [17, 'CharStrings', 'offset', 0], + [18, 'Private', ['offset', 'offset'], null], + [[12, 21], 'PostScript', 'sid', null], + [[12, 22], 'BaseFontName', 'sid', null], + [[12, 23], 'BaseFontBlend', 'delta', null], + [[12, 31], 'CIDFontVersion', 'num', 0], + [[12, 32], 'CIDFontRevision', 'num', 0], + [[12, 33], 'CIDFontType', 'num', 0], + [[12, 34], 'CIDCount', 'num', 8720], + [[12, 35], 'UIDBase', 'num', null], + // XXX: CID Fonts on DirectWrite 6.1 only seem to work if FDSelect comes + // before FDArray. + [[12, 37], 'FDSelect', 'offset', null], + [[12, 36], 'FDArray', 'offset', null], + [[12, 38], 'FontName', 'sid', null] + ]; + var tables = null; + function CFFTopDict(strings) { + if (tables === null) { + tables = CFFDict.createTables(layout); + } + CFFDict.call(this, tables, strings); + this.privateDict = null; + } + CFFTopDict.prototype = Object.create(CFFDict.prototype); + return CFFTopDict; +})(); + +var CFFPrivateDict = (function CFFPrivateDictClosure() { + var layout = [ + [6, 'BlueValues', 'delta', null], + [7, 'OtherBlues', 'delta', null], + [8, 'FamilyBlues', 'delta', null], + [9, 'FamilyOtherBlues', 'delta', null], + [[12, 9], 'BlueScale', 'num', 0.039625], + [[12, 10], 'BlueShift', 'num', 7], + [[12, 11], 'BlueFuzz', 'num', 1], + [10, 'StdHW', 'num', null], + [11, 'StdVW', 'num', null], + [[12, 12], 'StemSnapH', 'delta', null], + [[12, 13], 'StemSnapV', 'delta', null], + [[12, 14], 'ForceBold', 'num', 0], + [[12, 17], 'LanguageGroup', 'num', 0], + [[12, 18], 'ExpansionFactor', 'num', 0.06], + [[12, 19], 'initialRandomSeed', 'num', 0], + [20, 'defaultWidthX', 'num', 0], + [21, 'nominalWidthX', 'num', 0], + [19, 'Subrs', 'offset', null] + ]; + var tables = null; + function CFFPrivateDict(strings) { + if (tables === null) { + tables = CFFDict.createTables(layout); + } + CFFDict.call(this, tables, strings); + this.subrsIndex = null; + } + CFFPrivateDict.prototype = Object.create(CFFDict.prototype); + return CFFPrivateDict; +})(); + +var CFFCharsetPredefinedTypes = { + ISO_ADOBE: 0, + EXPERT: 1, + EXPERT_SUBSET: 2 +}; +var CFFCharset = (function CFFCharsetClosure() { + function CFFCharset(predefined, format, charset, raw) { + this.predefined = predefined; + this.format = format; + this.charset = charset; + this.raw = raw; + } + return CFFCharset; +})(); + +var CFFEncoding = (function CFFEncodingClosure() { + function CFFEncoding(predefined, format, encoding, raw) { + this.predefined = predefined; + this.format = format; + this.encoding = encoding; + this.raw = raw; + } + return CFFEncoding; +})(); + +var CFFFDSelect = (function CFFFDSelectClosure() { + function CFFFDSelect(fdSelect, raw) { + this.fdSelect = fdSelect; + this.raw = raw; + } + CFFFDSelect.prototype = { + getFDIndex: function CFFFDSelect_get(glyphIndex) { + if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) { + return -1; + } + return this.fdSelect[glyphIndex]; + } + }; + return CFFFDSelect; +})(); + +// Helper class to keep track of where an offset is within the data and helps +// filling in that offset once it's known. +var CFFOffsetTracker = (function CFFOffsetTrackerClosure() { + function CFFOffsetTracker() { + this.offsets = Object.create(null); + } + CFFOffsetTracker.prototype = { + isTracking: function CFFOffsetTracker_isTracking(key) { + return key in this.offsets; + }, + track: function CFFOffsetTracker_track(key, location) { + if (key in this.offsets) { + error('Already tracking location of ' + key); + } + this.offsets[key] = location; + }, + offset: function CFFOffsetTracker_offset(value) { + for (var key in this.offsets) { + this.offsets[key] += value; + } + }, + setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, + values, + output) { + if (!(key in this.offsets)) { + error('Not tracking location of ' + key); + } + var data = output.data; + var dataOffset = this.offsets[key]; + var size = 5; + for (var i = 0, ii = values.length; i < ii; ++i) { + var offset0 = i * size + dataOffset; + var offset1 = offset0 + 1; + var offset2 = offset0 + 2; + var offset3 = offset0 + 3; + var offset4 = offset0 + 4; + // It's easy to screw up offsets so perform this sanity check. + if (data[offset0] !== 0x1d || data[offset1] !== 0 || + data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) { + error('writing to an offset that is not empty'); + } + var value = values[i]; + data[offset0] = 0x1d; + data[offset1] = (value >> 24) & 0xFF; + data[offset2] = (value >> 16) & 0xFF; + data[offset3] = (value >> 8) & 0xFF; + data[offset4] = value & 0xFF; + } + } + }; + return CFFOffsetTracker; +})(); + +// Takes a CFF and converts it to the binary representation. +var CFFCompiler = (function CFFCompilerClosure() { + function CFFCompiler(cff) { + this.cff = cff; + } + CFFCompiler.prototype = { + compile: function CFFCompiler_compile() { + var cff = this.cff; + var output = { + data: [], + length: 0, + add: function CFFCompiler_add(data) { + this.data = this.data.concat(data); + this.length = this.data.length; + } + }; + + // Compile the five entries that must be in order. + var header = this.compileHeader(cff.header); + output.add(header); + + var nameIndex = this.compileNameIndex(cff.names); + output.add(nameIndex); + + if (cff.isCIDFont) { + // The spec is unclear on how font matrices should relate to each other + // when there is one in the main top dict and the sub top dicts. + // Windows handles this differently than linux and osx so we have to + // normalize to work on all. + // Rules based off of some mailing list discussions: + // - If main font has a matrix and subfont doesn't, use the main matrix. + // - If no main font matrix and there is a subfont matrix, use the + // subfont matrix. + // - If both have matrices, concat together. + // - If neither have matrices, use default. + // To make this work on all platforms we move the top matrix into each + // sub top dict and concat if necessary. + if (cff.topDict.hasName('FontMatrix')) { + var base = cff.topDict.getByName('FontMatrix'); + cff.topDict.removeByName('FontMatrix'); + for (var i = 0, ii = cff.fdArray.length; i < ii; i++) { + var subDict = cff.fdArray[i]; + var matrix = base.slice(0); + if (subDict.hasName('FontMatrix')) { + matrix = Util.transform(matrix, subDict.getByName('FontMatrix')); + } + subDict.setByName('FontMatrix', matrix); + } + } + } + + var compiled = this.compileTopDicts([cff.topDict], + output.length, + cff.isCIDFont); + output.add(compiled.output); + var topDictTracker = compiled.trackers[0]; + + var stringIndex = this.compileStringIndex(cff.strings.strings); + output.add(stringIndex); + + var globalSubrIndex = this.compileIndex(cff.globalSubrIndex); + output.add(globalSubrIndex); + + // Now start on the other entries that have no specfic order. + if (cff.encoding && cff.topDict.hasName('Encoding')) { + if (cff.encoding.predefined) { + topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], + output); + } else { + var encoding = this.compileEncoding(cff.encoding); + topDictTracker.setEntryLocation('Encoding', [output.length], output); + output.add(encoding); + } + } + + if (cff.charset && cff.topDict.hasName('charset')) { + if (cff.charset.predefined) { + topDictTracker.setEntryLocation('charset', [cff.charset.format], + output); + } else { + var charset = this.compileCharset(cff.charset); + topDictTracker.setEntryLocation('charset', [output.length], output); + output.add(charset); + } + } + + var charStrings = this.compileCharStrings(cff.charStrings); + topDictTracker.setEntryLocation('CharStrings', [output.length], output); + output.add(charStrings); + + if (cff.isCIDFont) { + // For some reason FDSelect must be in front of FDArray on windows. OSX + // and linux don't seem to care. + topDictTracker.setEntryLocation('FDSelect', [output.length], output); + var fdSelect = this.compileFDSelect(cff.fdSelect.raw); + output.add(fdSelect); + // It is unclear if the sub font dictionary can have CID related + // dictionary keys, but the sanitizer doesn't like them so remove them. + compiled = this.compileTopDicts(cff.fdArray, output.length, true); + topDictTracker.setEntryLocation('FDArray', [output.length], output); + output.add(compiled.output); + var fontDictTrackers = compiled.trackers; + + this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output); + } + + this.compilePrivateDicts([cff.topDict], [topDictTracker], output); + + // If the font data ends with INDEX whose object data is zero-length, + // the sanitizer will bail out. Add a dummy byte to avoid that. + output.add([0]); + + return output.data; + }, + encodeNumber: function CFFCompiler_encodeNumber(value) { + if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) { // isInt + return this.encodeInteger(value); + } else { + return this.encodeFloat(value); + } + }, + encodeFloat: function CFFCompiler_encodeFloat(num) { + var value = num.toString(); + + // rounding inaccurate doubles + var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value); + if (m) { + var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length)); + value = (Math.round(num * epsilon) / epsilon).toString(); + } + + var nibbles = ''; + var i, ii; + for (i = 0, ii = value.length; i < ii; ++i) { + var a = value[i]; + if (a === 'e') { + nibbles += value[++i] === '-' ? 'c' : 'b'; + } else if (a === '.') { + nibbles += 'a'; + } else if (a === '-') { + nibbles += 'e'; + } else { + nibbles += a; + } + } + nibbles += (nibbles.length & 1) ? 'f' : 'ff'; + var out = [30]; + for (i = 0, ii = nibbles.length; i < ii; i += 2) { + out.push(parseInt(nibbles.substr(i, 2), 16)); + } + return out; + }, + encodeInteger: function CFFCompiler_encodeInteger(value) { + var code; + if (value >= -107 && value <= 107) { + code = [value + 139]; + } else if (value >= 108 && value <= 1131) { + value = [value - 108]; + code = [(value >> 8) + 247, value & 0xFF]; + } else if (value >= -1131 && value <= -108) { + value = -value - 108; + code = [(value >> 8) + 251, value & 0xFF]; + } else if (value >= -32768 && value <= 32767) { + code = [0x1c, (value >> 8) & 0xFF, value & 0xFF]; + } else { + code = [0x1d, + (value >> 24) & 0xFF, + (value >> 16) & 0xFF, + (value >> 8) & 0xFF, + value & 0xFF]; + } + return code; + }, + compileHeader: function CFFCompiler_compileHeader(header) { + return [ + header.major, + header.minor, + header.hdrSize, + header.offSize + ]; + }, + compileNameIndex: function CFFCompiler_compileNameIndex(names) { + var nameIndex = new CFFIndex(); + for (var i = 0, ii = names.length; i < ii; ++i) { + nameIndex.add(stringToBytes(names[i])); + } + return this.compileIndex(nameIndex); + }, + compileTopDicts: function CFFCompiler_compileTopDicts(dicts, + length, + removeCidKeys) { + var fontDictTrackers = []; + var fdArrayIndex = new CFFIndex(); + for (var i = 0, ii = dicts.length; i < ii; ++i) { + var fontDict = dicts[i]; + if (removeCidKeys) { + fontDict.removeByName('CIDFontVersion'); + fontDict.removeByName('CIDFontRevision'); + fontDict.removeByName('CIDFontType'); + fontDict.removeByName('CIDCount'); + fontDict.removeByName('UIDBase'); + } + var fontDictTracker = new CFFOffsetTracker(); + var fontDictData = this.compileDict(fontDict, fontDictTracker); + fontDictTrackers.push(fontDictTracker); + fdArrayIndex.add(fontDictData); + fontDictTracker.offset(length); + } + fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers); + return { + trackers: fontDictTrackers, + output: fdArrayIndex + }; + }, + compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, + trackers, + output) { + for (var i = 0, ii = dicts.length; i < ii; ++i) { + var fontDict = dicts[i]; + assert(fontDict.privateDict && fontDict.hasName('Private'), + 'There must be an private dictionary.'); + var privateDict = fontDict.privateDict; + var privateDictTracker = new CFFOffsetTracker(); + var privateDictData = this.compileDict(privateDict, privateDictTracker); + + var outputLength = output.length; + privateDictTracker.offset(outputLength); + if (!privateDictData.length) { + // The private dictionary was empty, set the output length to zero to + // ensure the offset length isn't out of bounds in the eyes of the + // sanitizer. + outputLength = 0; + } + + trackers[i].setEntryLocation('Private', + [privateDictData.length, outputLength], + output); + output.add(privateDictData); + + if (privateDict.subrsIndex && privateDict.hasName('Subrs')) { + var subrs = this.compileIndex(privateDict.subrsIndex); + privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], + output); + output.add(subrs); + } + } + }, + compileDict: function CFFCompiler_compileDict(dict, offsetTracker) { + var out = []; + // The dictionary keys must be in a certain order. + var order = dict.order; + for (var i = 0; i < order.length; ++i) { + var key = order[i]; + if (!(key in dict.values)) { + continue; + } + var values = dict.values[key]; + var types = dict.types[key]; + if (!isArray(types)) { + types = [types]; + } + if (!isArray(values)) { + values = [values]; + } + + // Remove any empty dict values. + if (values.length === 0) { + continue; + } + + for (var j = 0, jj = types.length; j < jj; ++j) { + var type = types[j]; + var value = values[j]; + switch (type) { + case 'num': + case 'sid': + out = out.concat(this.encodeNumber(value)); + break; + case 'offset': + // For offsets we just insert a 32bit integer so we don't have to + // deal with figuring out the length of the offset when it gets + // replaced later on by the compiler. + var name = dict.keyToNameMap[key]; + // Some offsets have the offset and the length, so just record the + // position of the first one. + if (!offsetTracker.isTracking(name)) { + offsetTracker.track(name, out.length); + } + out = out.concat([0x1d, 0, 0, 0, 0]); + break; + case 'array': + case 'delta': + out = out.concat(this.encodeNumber(value)); + for (var k = 1, kk = values.length; k < kk; ++k) { + out = out.concat(this.encodeNumber(values[k])); + } + break; + default: + error('Unknown data type of ' + type); + break; + } + } + out = out.concat(dict.opcodes[key]); + } + return out; + }, + compileStringIndex: function CFFCompiler_compileStringIndex(strings) { + var stringIndex = new CFFIndex(); + for (var i = 0, ii = strings.length; i < ii; ++i) { + stringIndex.add(stringToBytes(strings[i])); + } + return this.compileIndex(stringIndex); + }, + compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() { + var globalSubrIndex = this.cff.globalSubrIndex; + this.out.writeByteArray(this.compileIndex(globalSubrIndex)); + }, + compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) { + return this.compileIndex(charStrings); + }, + compileCharset: function CFFCompiler_compileCharset(charset) { + return this.compileTypedArray(charset.raw); + }, + compileEncoding: function CFFCompiler_compileEncoding(encoding) { + return this.compileTypedArray(encoding.raw); + }, + compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) { + return this.compileTypedArray(fdSelect); + }, + compileTypedArray: function CFFCompiler_compileTypedArray(data) { + var out = []; + for (var i = 0, ii = data.length; i < ii; ++i) { + out[i] = data[i]; + } + return out; + }, + compileIndex: function CFFCompiler_compileIndex(index, trackers) { + trackers = trackers || []; + var objects = index.objects; + // First 2 bytes contains the number of objects contained into this index + var count = objects.length; + + // If there is no object, just create an index. This technically + // should just be [0, 0] but OTS has an issue with that. + if (count === 0) { + return [0, 0, 0]; + } + + var data = [(count >> 8) & 0xFF, count & 0xff]; + + var lastOffset = 1, i; + for (i = 0; i < count; ++i) { + lastOffset += objects[i].length; + } + + var offsetSize; + if (lastOffset < 0x100) { + offsetSize = 1; + } else if (lastOffset < 0x10000) { + offsetSize = 2; + } else if (lastOffset < 0x1000000) { + offsetSize = 3; + } else { + offsetSize = 4; + } + + // Next byte contains the offset size use to reference object in the file + data.push(offsetSize); + + // Add another offset after this one because we need a new offset + var relativeOffset = 1; + for (i = 0; i < count + 1; i++) { + if (offsetSize === 1) { + data.push(relativeOffset & 0xFF); + } else if (offsetSize === 2) { + data.push((relativeOffset >> 8) & 0xFF, + relativeOffset & 0xFF); + } else if (offsetSize === 3) { + data.push((relativeOffset >> 16) & 0xFF, + (relativeOffset >> 8) & 0xFF, + relativeOffset & 0xFF); + } else { + data.push((relativeOffset >>> 24) & 0xFF, + (relativeOffset >> 16) & 0xFF, + (relativeOffset >> 8) & 0xFF, + relativeOffset & 0xFF); + } + + if (objects[i]) { + relativeOffset += objects[i].length; + } + } + + for (i = 0; i < count; i++) { + // Notify the tracker where the object will be offset in the data. + if (trackers[i]) { + trackers[i].offset(data.length); + } + for (var j = 0, jj = objects[i].length; j < jj; j++) { + data.push(objects[i][j]); + } + } + return data; + } + }; + return CFFCompiler; +})(); + +exports.CFFStandardStrings = CFFStandardStrings; +exports.CFFParser = CFFParser; +exports.CFF = CFF; +exports.CFFHeader = CFFHeader; +exports.CFFStrings = CFFStrings; +exports.CFFIndex = CFFIndex; +exports.CFFCharset = CFFCharset; +exports.CFFTopDict = CFFTopDict; +exports.CFFPrivateDict = CFFPrivateDict; +exports.CFFCompiler = CFFCompiler; +})); + + (function (root, factory) { { factory((root.pdfjsCoreChunkedStream = {}), root.pdfjsSharedUtil); @@ -21694,10 +23331,11 @@ exports.calculateSHA512 = calculateSHA512; (function (root, factory) { { factory((root.pdfjsCoreFontRenderer = {}), root.pdfjsSharedUtil, - root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings); + root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, + root.pdfjsCoreCFFParser); } }(this, function (exports, sharedUtil, coreStream, coreGlyphList, - coreEncodings) { + coreEncodings, coreCFFParser) { var Util = sharedUtil.Util; var bytesToString = sharedUtil.bytesToString; @@ -21705,9 +23343,7 @@ var error = sharedUtil.error; var Stream = coreStream.Stream; var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode; var StandardEncoding = coreEncodings.StandardEncoding; - -var coreFonts; // see _setCoreFonts below -var CFFParser; // = coreFonts.CFFParser; +var CFFParser = coreCFFParser.CFFParser; var FontRendererFactory = (function FontRendererFactoryClosure() { function getLong(data, offset) { @@ -21769,10 +23405,10 @@ var FontRendererFactory = (function FontRendererFactoryClosure() { error('not supported cmap: ' + format); } - function parseCff(data, start, end) { + function parseCff(data, start, end, seacAnalysisEnabled) { var properties = {}; var parser = new CFFParser(new Stream(data, start, end - start), - properties); + properties, seacAnalysisEnabled); var cff = parser.parse(); return { glyphs: cff.charStrings.objects, @@ -22366,7 +24002,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() { return { - create: function FontRendererFactory_create(font) { + create: function FontRendererFactory_create(font, seacAnalysisEnabled) { var data = new Uint8Array(font.data); var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm; var numTables = getUshort(data, 4); @@ -22389,7 +24025,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() { indexToLocFormat = getUshort(data, offset + 50); break; case 'CFF ': - cff = parseCff(data, offset, offset + length); + cff = parseCff(data, offset, offset + length, seacAnalysisEnabled); break; } } @@ -22406,14 +24042,6 @@ var FontRendererFactory = (function FontRendererFactoryClosure() { }; })(); - -// TODO refactor to remove cyclic dependency on fonts.js -function _setCoreFonts(coreFonts_) { - coreFonts = coreFonts_; - CFFParser = coreFonts_.CFFParser; -} -exports._setCoreFonts = _setCoreFonts; - exports.FontRendererFactory = FontRendererFactory; })); @@ -24523,17 +26151,938 @@ exports.IdentityCMap = IdentityCMap; })); +(function (root, factory) { + { + factory((root.pdfjsCorePsParser = {}), root.pdfjsSharedUtil, + root.pdfjsCoreParser); + } +}(this, function (exports, sharedUtil, coreParser) { + +var error = sharedUtil.error; +var EOF = coreParser.EOF; +var Lexer = coreParser.Lexer; + +var PostScriptParser = (function PostScriptParserClosure() { + function PostScriptParser(lexer) { + this.lexer = lexer; + this.operators = []; + this.token = null; + this.prev = null; + } + PostScriptParser.prototype = { + nextToken: function PostScriptParser_nextToken() { + this.prev = this.token; + this.token = this.lexer.getToken(); + }, + accept: function PostScriptParser_accept(type) { + if (this.token.type === type) { + this.nextToken(); + return true; + } + return false; + }, + expect: function PostScriptParser_expect(type) { + if (this.accept(type)) { + return true; + } + error('Unexpected symbol: found ' + this.token.type + ' expected ' + + type + '.'); + }, + parse: function PostScriptParser_parse() { + this.nextToken(); + this.expect(PostScriptTokenTypes.LBRACE); + this.parseBlock(); + this.expect(PostScriptTokenTypes.RBRACE); + return this.operators; + }, + parseBlock: function PostScriptParser_parseBlock() { + while (true) { + if (this.accept(PostScriptTokenTypes.NUMBER)) { + this.operators.push(this.prev.value); + } else if (this.accept(PostScriptTokenTypes.OPERATOR)) { + this.operators.push(this.prev.value); + } else if (this.accept(PostScriptTokenTypes.LBRACE)) { + this.parseCondition(); + } else { + return; + } + } + }, + parseCondition: function PostScriptParser_parseCondition() { + // Add two place holders that will be updated later + var conditionLocation = this.operators.length; + this.operators.push(null, null); + + this.parseBlock(); + this.expect(PostScriptTokenTypes.RBRACE); + if (this.accept(PostScriptTokenTypes.IF)) { + // The true block is right after the 'if' so it just falls through on + // true else it jumps and skips the true block. + this.operators[conditionLocation] = this.operators.length; + this.operators[conditionLocation + 1] = 'jz'; + } else if (this.accept(PostScriptTokenTypes.LBRACE)) { + var jumpLocation = this.operators.length; + this.operators.push(null, null); + var endOfTrue = this.operators.length; + this.parseBlock(); + this.expect(PostScriptTokenTypes.RBRACE); + this.expect(PostScriptTokenTypes.IFELSE); + // The jump is added at the end of the true block to skip the false + // block. + this.operators[jumpLocation] = this.operators.length; + this.operators[jumpLocation + 1] = 'j'; + + this.operators[conditionLocation] = endOfTrue; + this.operators[conditionLocation + 1] = 'jz'; + } else { + error('PS Function: error parsing conditional.'); + } + } + }; + return PostScriptParser; +})(); + +var PostScriptTokenTypes = { + LBRACE: 0, + RBRACE: 1, + NUMBER: 2, + OPERATOR: 3, + IF: 4, + IFELSE: 5 +}; + +var PostScriptToken = (function PostScriptTokenClosure() { + function PostScriptToken(type, value) { + this.type = type; + this.value = value; + } + + var opCache = Object.create(null); + + PostScriptToken.getOperator = function PostScriptToken_getOperator(op) { + var opValue = opCache[op]; + if (opValue) { + return opValue; + } + return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op); + }; + + PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, + '{'); + PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, + '}'); + PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF'); + PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, + 'IFELSE'); + return PostScriptToken; +})(); + +var PostScriptLexer = (function PostScriptLexerClosure() { + function PostScriptLexer(stream) { + this.stream = stream; + this.nextChar(); + + this.strBuf = []; + } + PostScriptLexer.prototype = { + nextChar: function PostScriptLexer_nextChar() { + return (this.currentChar = this.stream.getByte()); + }, + getToken: function PostScriptLexer_getToken() { + var comment = false; + var ch = this.currentChar; + + // skip comments + while (true) { + if (ch < 0) { + return EOF; + } + + if (comment) { + if (ch === 0x0A || ch === 0x0D) { + comment = false; + } + } else if (ch === 0x25) { // '%' + comment = true; + } else if (!Lexer.isSpace(ch)) { + break; + } + ch = this.nextChar(); + } + switch (ch | 0) { + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: // '0'-'4' + case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: // '5'-'9' + case 0x2B: case 0x2D: case 0x2E: // '+', '-', '.' + return new PostScriptToken(PostScriptTokenTypes.NUMBER, + this.getNumber()); + case 0x7B: // '{' + this.nextChar(); + return PostScriptToken.LBRACE; + case 0x7D: // '}' + this.nextChar(); + return PostScriptToken.RBRACE; + } + // operator + var strBuf = this.strBuf; + strBuf.length = 0; + strBuf[0] = String.fromCharCode(ch); + + while ((ch = this.nextChar()) >= 0 && // and 'A'-'Z', 'a'-'z' + ((ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A))) { + strBuf.push(String.fromCharCode(ch)); + } + var str = strBuf.join(''); + switch (str.toLowerCase()) { + case 'if': + return PostScriptToken.IF; + case 'ifelse': + return PostScriptToken.IFELSE; + default: + return PostScriptToken.getOperator(str); + } + }, + getNumber: function PostScriptLexer_getNumber() { + var ch = this.currentChar; + var strBuf = this.strBuf; + strBuf.length = 0; + strBuf[0] = String.fromCharCode(ch); + + while ((ch = this.nextChar()) >= 0) { + if ((ch >= 0x30 && ch <= 0x39) || // '0'-'9' + ch === 0x2D || ch === 0x2E) { // '-', '.' + strBuf.push(String.fromCharCode(ch)); + } else { + break; + } + } + var value = parseFloat(strBuf.join('')); + if (isNaN(value)) { + error('Invalid floating point number: ' + value); + } + return value; + } + }; + return PostScriptLexer; +})(); + +exports.PostScriptLexer = PostScriptLexer; +exports.PostScriptParser = PostScriptParser; +})); + + +(function (root, factory) { + { + factory((root.pdfjsCoreType1Parser = {}), root.pdfjsSharedUtil, + root.pdfjsCoreStream, root.pdfjsCoreParser, root.pdfjsCoreEncodings); + } +}(this, function (exports, sharedUtil, coreStream, coreParser, coreEncodings) { + +var warn = sharedUtil.warn; +var Stream = coreStream.Stream; +var Lexer = coreParser.Lexer; +var getEncoding = coreEncodings.getEncoding; + +// Hinting is currently disabled due to unknown problems on windows +// in tracemonkey and various other pdfs with type1 fonts. +var HINTING_ENABLED = false; + +/* + * CharStrings are encoded following the the CharString Encoding sequence + * describe in Chapter 6 of the "Adobe Type1 Font Format" specification. + * The value in a byte indicates a command, a number, or subsequent bytes + * that are to be interpreted in a special way. + * + * CharString Number Encoding: + * A CharString byte containing the values from 32 through 255 inclusive + * indicate an integer. These values are decoded in four ranges. + * + * 1. A CharString byte containing a value, v, between 32 and 246 inclusive, + * indicate the integer v - 139. Thus, the integer values from -107 through + * 107 inclusive may be encoded in single byte. + * + * 2. A CharString byte containing a value, v, between 247 and 250 inclusive, + * indicates an integer involving the next byte, w, according to the formula: + * [(v - 247) x 256] + w + 108 + * + * 3. A CharString byte containing a value, v, between 251 and 254 inclusive, + * indicates an integer involving the next byte, w, according to the formula: + * -[(v - 251) * 256] - w - 108 + * + * 4. A CharString containing the value 255 indicates that the next 4 bytes + * are a two complement signed integer. The first of these bytes contains the + * highest order bits, the second byte contains the next higher order bits + * and the fourth byte contain the lowest order bits. + * + * + * CharString Command Encoding: + * CharStrings commands are encoded in 1 or 2 bytes. + * + * Single byte commands are encoded in 1 byte that contains a value between + * 0 and 31 inclusive. + * If a command byte contains the value 12, then the value in the next byte + * indicates a command. This "escape" mechanism allows many extra commands + * to be encoded and this encoding technique helps to minimize the length of + * the charStrings. + */ +var Type1CharString = (function Type1CharStringClosure() { + var COMMAND_MAP = { + 'hstem': [1], + 'vstem': [3], + 'vmoveto': [4], + 'rlineto': [5], + 'hlineto': [6], + 'vlineto': [7], + 'rrcurveto': [8], + 'callsubr': [10], + 'flex': [12, 35], + 'drop' : [12, 18], + 'endchar': [14], + 'rmoveto': [21], + 'hmoveto': [22], + 'vhcurveto': [30], + 'hvcurveto': [31] + }; + + function Type1CharString() { + this.width = 0; + this.lsb = 0; + this.flexing = false; + this.output = []; + this.stack = []; + } + + Type1CharString.prototype = { + convert: function Type1CharString_convert(encoded, subrs, + seacAnalysisEnabled) { + var count = encoded.length; + var error = false; + var wx, sbx, subrNumber; + for (var i = 0; i < count; i++) { + var value = encoded[i]; + if (value < 32) { + if (value === 12) { + value = (value << 8) + encoded[++i]; + } + switch (value) { + case 1: // hstem + if (!HINTING_ENABLED) { + this.stack = []; + break; + } + error = this.executeCommand(2, COMMAND_MAP.hstem); + break; + case 3: // vstem + if (!HINTING_ENABLED) { + this.stack = []; + break; + } + error = this.executeCommand(2, COMMAND_MAP.vstem); + break; + case 4: // vmoveto + if (this.flexing) { + if (this.stack.length < 1) { + error = true; + break; + } + // Add the dx for flex and but also swap the values so they are + // the right order. + var dy = this.stack.pop(); + this.stack.push(0, dy); + break; + } + error = this.executeCommand(1, COMMAND_MAP.vmoveto); + break; + case 5: // rlineto + error = this.executeCommand(2, COMMAND_MAP.rlineto); + break; + case 6: // hlineto + error = this.executeCommand(1, COMMAND_MAP.hlineto); + break; + case 7: // vlineto + error = this.executeCommand(1, COMMAND_MAP.vlineto); + break; + case 8: // rrcurveto + error = this.executeCommand(6, COMMAND_MAP.rrcurveto); + break; + case 9: // closepath + // closepath is a Type1 command that does not take argument and is + // useless in Type2 and it can simply be ignored. + this.stack = []; + break; + case 10: // callsubr + if (this.stack.length < 1) { + error = true; + break; + } + subrNumber = this.stack.pop(); + error = this.convert(subrs[subrNumber], subrs, + seacAnalysisEnabled); + break; + case 11: // return + return error; + case 13: // hsbw + if (this.stack.length < 2) { + error = true; + break; + } + // To convert to type2 we have to move the width value to the + // first part of the charstring and then use hmoveto with lsb. + wx = this.stack.pop(); + sbx = this.stack.pop(); + this.lsb = sbx; + this.width = wx; + this.stack.push(wx, sbx); + error = this.executeCommand(2, COMMAND_MAP.hmoveto); + break; + case 14: // endchar + this.output.push(COMMAND_MAP.endchar[0]); + break; + case 21: // rmoveto + if (this.flexing) { + break; + } + error = this.executeCommand(2, COMMAND_MAP.rmoveto); + break; + case 22: // hmoveto + if (this.flexing) { + // Add the dy for flex. + this.stack.push(0); + break; + } + error = this.executeCommand(1, COMMAND_MAP.hmoveto); + break; + case 30: // vhcurveto + error = this.executeCommand(4, COMMAND_MAP.vhcurveto); + break; + case 31: // hvcurveto + error = this.executeCommand(4, COMMAND_MAP.hvcurveto); + break; + case (12 << 8) + 0: // dotsection + // dotsection is a Type1 command to specify some hinting feature + // for dots that do not take a parameter and it can safely be + // ignored for Type2. + this.stack = []; + break; + case (12 << 8) + 1: // vstem3 + if (!HINTING_ENABLED) { + this.stack = []; + break; + } + // [vh]stem3 are Type1 only and Type2 supports [vh]stem with + // multiple parameters, so instead of returning [vh]stem3 take a + // shortcut and return [vhstem] instead. + error = this.executeCommand(2, COMMAND_MAP.vstem); + break; + case (12 << 8) + 2: // hstem3 + if (!HINTING_ENABLED) { + this.stack = []; + break; + } + // See vstem3. + error = this.executeCommand(2, COMMAND_MAP.hstem); + break; + case (12 << 8) + 6: // seac + // seac is like type 2's special endchar but it doesn't use the + // first argument asb, so remove it. + if (seacAnalysisEnabled) { + this.seac = this.stack.splice(-4, 4); + error = this.executeCommand(0, COMMAND_MAP.endchar); + } else { + error = this.executeCommand(4, COMMAND_MAP.endchar); + } + break; + case (12 << 8) + 7: // sbw + if (this.stack.length < 4) { + error = true; + break; + } + // To convert to type2 we have to move the width value to the + // first part of the charstring and then use rmoveto with + // (dx, dy). The height argument will not be used for vmtx and + // vhea tables reconstruction -- ignoring it. + var wy = this.stack.pop(); + wx = this.stack.pop(); + var sby = this.stack.pop(); + sbx = this.stack.pop(); + this.lsb = sbx; + this.width = wx; + this.stack.push(wx, sbx, sby); + error = this.executeCommand(3, COMMAND_MAP.rmoveto); + break; + case (12 << 8) + 12: // div + if (this.stack.length < 2) { + error = true; + break; + } + var num2 = this.stack.pop(); + var num1 = this.stack.pop(); + this.stack.push(num1 / num2); + break; + case (12 << 8) + 16: // callothersubr + if (this.stack.length < 2) { + error = true; + break; + } + subrNumber = this.stack.pop(); + var numArgs = this.stack.pop(); + if (subrNumber === 0 && numArgs === 3) { + var flexArgs = this.stack.splice(this.stack.length - 17, 17); + this.stack.push( + flexArgs[2] + flexArgs[0], // bcp1x + rpx + flexArgs[3] + flexArgs[1], // bcp1y + rpy + flexArgs[4], // bcp2x + flexArgs[5], // bcp2y + flexArgs[6], // p2x + flexArgs[7], // p2y + flexArgs[8], // bcp3x + flexArgs[9], // bcp3y + flexArgs[10], // bcp4x + flexArgs[11], // bcp4y + flexArgs[12], // p3x + flexArgs[13], // p3y + flexArgs[14] // flexDepth + // 15 = finalx unused by flex + // 16 = finaly unused by flex + ); + error = this.executeCommand(13, COMMAND_MAP.flex, true); + this.flexing = false; + this.stack.push(flexArgs[15], flexArgs[16]); + } else if (subrNumber === 1 && numArgs === 0) { + this.flexing = true; + } + break; + case (12 << 8) + 17: // pop + // Ignore this since it is only used with othersubr. + break; + case (12 << 8) + 33: // setcurrentpoint + // Ignore for now. + this.stack = []; + break; + default: + warn('Unknown type 1 charstring command of "' + value + '"'); + break; + } + if (error) { + break; + } + continue; + } else if (value <= 246) { + value = value - 139; + } else if (value <= 250) { + value = ((value - 247) * 256) + encoded[++i] + 108; + } else if (value <= 254) { + value = -((value - 251) * 256) - encoded[++i] - 108; + } else { + value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | + (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0; + } + this.stack.push(value); + } + return error; + }, + + executeCommand: function(howManyArgs, command, keepStack) { + var stackLength = this.stack.length; + if (howManyArgs > stackLength) { + return true; + } + var start = stackLength - howManyArgs; + for (var i = start; i < stackLength; i++) { + var value = this.stack[i]; + if (value === (value | 0)) { // int + this.output.push(28, (value >> 8) & 0xff, value & 0xff); + } else { // fixed point + value = (65536 * value) | 0; + this.output.push(255, + (value >> 24) & 0xFF, + (value >> 16) & 0xFF, + (value >> 8) & 0xFF, + value & 0xFF); + } + } + this.output.push.apply(this.output, command); + if (keepStack) { + this.stack.splice(start, howManyArgs); + } else { + this.stack.length = 0; + } + return false; + } + }; + + return Type1CharString; +})(); + +/* + * Type1Parser encapsulate the needed code for parsing a Type1 font + * program. Some of its logic depends on the Type2 charstrings + * structure. + * Note: this doesn't really parse the font since that would require evaluation + * of PostScript, but it is possible in most cases to extract what we need + * without a full parse. + */ +var Type1Parser = (function Type1ParserClosure() { + /* + * Decrypt a Sequence of Ciphertext Bytes to Produce the Original Sequence + * of Plaintext Bytes. The function took a key as a parameter which can be + * for decrypting the eexec block of for decoding charStrings. + */ + var EEXEC_ENCRYPT_KEY = 55665; + var CHAR_STRS_ENCRYPT_KEY = 4330; + + function isHexDigit(code) { + return code >= 48 && code <= 57 || // '0'-'9' + code >= 65 && code <= 70 || // 'A'-'F' + code >= 97 && code <= 102; // 'a'-'f' + } + + function decrypt(data, key, discardNumber) { + if (discardNumber >= data.length) { + return new Uint8Array(0); + } + var r = key | 0, c1 = 52845, c2 = 22719, i, j; + for (i = 0; i < discardNumber; i++) { + r = ((data[i] + r) * c1 + c2) & ((1 << 16) - 1); + } + var count = data.length - discardNumber; + var decrypted = new Uint8Array(count); + for (i = discardNumber, j = 0; j < count; i++, j++) { + var value = data[i]; + decrypted[j] = value ^ (r >> 8); + r = ((value + r) * c1 + c2) & ((1 << 16) - 1); + } + return decrypted; + } + + function decryptAscii(data, key, discardNumber) { + var r = key | 0, c1 = 52845, c2 = 22719; + var count = data.length, maybeLength = count >>> 1; + var decrypted = new Uint8Array(maybeLength); + var i, j; + for (i = 0, j = 0; i < count; i++) { + var digit1 = data[i]; + if (!isHexDigit(digit1)) { + continue; + } + i++; + var digit2; + while (i < count && !isHexDigit(digit2 = data[i])) { + i++; + } + if (i < count) { + var value = parseInt(String.fromCharCode(digit1, digit2), 16); + decrypted[j++] = value ^ (r >> 8); + r = ((value + r) * c1 + c2) & ((1 << 16) - 1); + } + } + return Array.prototype.slice.call(decrypted, discardNumber, j); + } + + function isSpecial(c) { + return c === 0x2F || // '/' + c === 0x5B || c === 0x5D || // '[', ']' + c === 0x7B || c === 0x7D || // '{', '}' + c === 0x28 || c === 0x29; // '(', ')' + } + + function Type1Parser(stream, encrypted, seacAnalysisEnabled) { + if (encrypted) { + var data = stream.getBytes(); + var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && + isHexDigit(data[2]) && isHexDigit(data[3])); + stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : + decryptAscii(data, EEXEC_ENCRYPT_KEY, 4)); + } + this.seacAnalysisEnabled = !!seacAnalysisEnabled; + + this.stream = stream; + this.nextChar(); + } + + Type1Parser.prototype = { + readNumberArray: function Type1Parser_readNumberArray() { + this.getToken(); // read '[' or '{' (arrays can start with either) + var array = []; + while (true) { + var token = this.getToken(); + if (token === null || token === ']' || token === '}') { + break; + } + array.push(parseFloat(token || 0)); + } + return array; + }, + + readNumber: function Type1Parser_readNumber() { + var token = this.getToken(); + return parseFloat(token || 0); + }, + + readInt: function Type1Parser_readInt() { + // Use '| 0' to prevent setting a double into length such as the double + // does not flow into the loop variable. + var token = this.getToken(); + return parseInt(token || 0, 10) | 0; + }, + + readBoolean: function Type1Parser_readBoolean() { + var token = this.getToken(); + + // Use 1 and 0 since that's what type2 charstrings use. + return token === 'true' ? 1 : 0; + }, + + nextChar : function Type1_nextChar() { + return (this.currentChar = this.stream.getByte()); + }, + + getToken: function Type1Parser_getToken() { + // Eat whitespace and comments. + var comment = false; + var ch = this.currentChar; + while (true) { + if (ch === -1) { + return null; + } + + if (comment) { + if (ch === 0x0A || ch === 0x0D) { + comment = false; + } + } else if (ch === 0x25) { // '%' + comment = true; + } else if (!Lexer.isSpace(ch)) { + break; + } + ch = this.nextChar(); + } + if (isSpecial(ch)) { + this.nextChar(); + return String.fromCharCode(ch); + } + var token = ''; + do { + token += String.fromCharCode(ch); + ch = this.nextChar(); + } while (ch >= 0 && !Lexer.isSpace(ch) && !isSpecial(ch)); + return token; + }, + + /* + * Returns an object containing a Subrs array and a CharStrings + * array extracted from and eexec encrypted block of data + */ + extractFontProgram: function Type1Parser_extractFontProgram() { + var stream = this.stream; + + var subrs = [], charstrings = []; + var privateData = Object.create(null); + privateData['lenIV'] = 4; + var program = { + subrs: [], + charstrings: [], + properties: { + 'privateData': privateData + } + }; + var token, length, data, lenIV, encoded; + while ((token = this.getToken()) !== null) { + if (token !== '/') { + continue; + } + token = this.getToken(); + switch (token) { + case 'CharStrings': + // The number immediately following CharStrings must be greater or + // equal to the number of CharStrings. + this.getToken(); + this.getToken(); // read in 'dict' + this.getToken(); // read in 'dup' + this.getToken(); // read in 'begin' + while(true) { + token = this.getToken(); + if (token === null || token === 'end') { + break; + } + + if (token !== '/') { + continue; + } + var glyph = this.getToken(); + length = this.readInt(); + this.getToken(); // read in 'RD' or '-|' + data = stream.makeSubStream(stream.pos, length); + lenIV = program.properties.privateData['lenIV']; + encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV); + // Skip past the required space and binary data. + stream.skip(length); + this.nextChar(); + token = this.getToken(); // read in 'ND' or '|-' + if (token === 'noaccess') { + this.getToken(); // read in 'def' + } + charstrings.push({ + glyph: glyph, + encoded: encoded + }); + } + break; + case 'Subrs': + var num = this.readInt(); + this.getToken(); // read in 'array' + while ((token = this.getToken()) === 'dup') { + var index = this.readInt(); + length = this.readInt(); + this.getToken(); // read in 'RD' or '-|' + data = stream.makeSubStream(stream.pos, length); + lenIV = program.properties.privateData['lenIV']; + encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV); + // Skip past the required space and binary data. + stream.skip(length); + this.nextChar(); + token = this.getToken(); // read in 'NP' or '|' + if (token === 'noaccess') { + this.getToken(); // read in 'put' + } + subrs[index] = encoded; + } + break; + case 'BlueValues': + case 'OtherBlues': + case 'FamilyBlues': + case 'FamilyOtherBlues': + var blueArray = this.readNumberArray(); + // *Blue* values may contain invalid data: disables reading of + // those values when hinting is disabled. + if (blueArray.length > 0 && (blueArray.length % 2) === 0 && + HINTING_ENABLED) { + program.properties.privateData[token] = blueArray; + } + break; + case 'StemSnapH': + case 'StemSnapV': + program.properties.privateData[token] = this.readNumberArray(); + break; + case 'StdHW': + case 'StdVW': + program.properties.privateData[token] = + this.readNumberArray()[0]; + break; + case 'BlueShift': + case 'lenIV': + case 'BlueFuzz': + case 'BlueScale': + case 'LanguageGroup': + case 'ExpansionFactor': + program.properties.privateData[token] = this.readNumber(); + break; + case 'ForceBold': + program.properties.privateData[token] = this.readBoolean(); + break; + } + } + + for (var i = 0; i < charstrings.length; i++) { + glyph = charstrings[i].glyph; + encoded = charstrings[i].encoded; + var charString = new Type1CharString(); + var error = charString.convert(encoded, subrs, + this.seacAnalysisEnabled); + var output = charString.output; + if (error) { + // It seems when FreeType encounters an error while evaluating a glyph + // that it completely ignores the glyph so we'll mimic that behaviour + // here and put an endchar to make the validator happy. + output = [14]; + } + program.charstrings.push({ + glyphName: glyph, + charstring: output, + width: charString.width, + lsb: charString.lsb, + seac: charString.seac + }); + } + + return program; + }, + + extractFontHeader: function Type1Parser_extractFontHeader(properties) { + var token; + while ((token = this.getToken()) !== null) { + if (token !== '/') { + continue; + } + token = this.getToken(); + switch (token) { + case 'FontMatrix': + var matrix = this.readNumberArray(); + properties.fontMatrix = matrix; + break; + case 'Encoding': + var encodingArg = this.getToken(); + var encoding; + if (!/^\d+$/.test(encodingArg)) { + // encoding name is specified + encoding = getEncoding(encodingArg); + } else { + encoding = []; + var size = parseInt(encodingArg, 10) | 0; + this.getToken(); // read in 'array' + + for (var j = 0; j < size; j++) { + token = this.getToken(); + // skipping till first dup or def (e.g. ignoring for statement) + while (token !== 'dup' && token !== 'def') { + token = this.getToken(); + if (token === null) { + return; // invalid header + } + } + if (token === 'def') { + break; // read all array data + } + var index = this.readInt(); + this.getToken(); // read in '/' + var glyph = this.getToken(); + encoding[index] = glyph; + this.getToken(); // read the in 'put' + } + } + properties.builtInEncoding = encoding; + break; + case 'FontBBox': + var fontBBox = this.readNumberArray(); + // adjusting ascent/descent + properties.ascent = fontBBox[3]; + properties.descent = fontBBox[1]; + properties.ascentScaled = true; + break; + } + } + } + }; + + return Type1Parser; +})(); + +exports.Type1Parser = Type1Parser; +})); + + (function (root, factory) { { factory((root.pdfjsCoreFonts = {}), root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser, root.pdfjsCoreGlyphList, root.pdfjsCoreCharsets, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, - root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode); + root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, + root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser); } }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreGlyphList, coreCharsets, coreFontRenderer, - coreEncodings, coreStandardFonts, coreUnicode) { + coreEncodings, coreStandardFonts, coreUnicode, + coreType1Parser, coreCFFParser) { var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX; var FontType = sharedUtil.FontType; @@ -24574,6 +27123,17 @@ var getSupplementalGlyphMapForArialBlack = var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor; var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues; var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph; +var Type1Parser = coreType1Parser.Type1Parser; +var CFFStandardStrings = coreCFFParser.CFFStandardStrings; +var CFFParser = coreCFFParser.CFFParser; +var CFFCompiler = coreCFFParser.CFFCompiler; +var CFF = coreCFFParser.CFF; +var CFFHeader = coreCFFParser.CFFHeader; +var CFFTopDict = coreCFFParser.CFFTopDict; +var CFFPrivateDict = coreCFFParser.CFFPrivateDict; +var CFFStrings = coreCFFParser.CFFStrings; +var CFFIndex = coreCFFParser.CFFIndex; +var CFFCharset = coreCFFParser.CFFCharset; // Unicode Private Use Area var PRIVATE_USE_OFFSET_START = 0xE000; @@ -24584,17 +27144,10 @@ var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false; // except for Type 3 fonts var PDF_GLYPH_SPACE_UNITS = 1000; -// Hinting is currently disabled due to unknown problems on windows -// in tracemonkey and various other pdfs with type1 fonts. -var HINTING_ENABLED = false; - -// Accented charactars are not displayed properly on windows, using this flag +// Accented charactars are not displayed properly on Windows, using this flag // to control analysis of seac charstrings. var SEAC_ANALYSIS_ENABLED = false; -// Maximum subroutine call depth of type 2 chartrings. Matches OTS. -var MAX_SUBR_NESTING = 10; - var FontFlags = { FixedPitch: 1, Serif: 2, @@ -25702,7 +28255,7 @@ var Font = (function FontClosure() { mimetype: null, encoding: null, get renderer() { - var renderer = FontRendererFactory.create(this); + var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED); return shadow(this, 'renderer', renderer); }, @@ -26950,7 +29503,8 @@ var Font = (function FontClosure() { try { // Trying to repair CFF file cffFile = new Stream(tables['CFF '].data); - var parser = new CFFParser(cffFile, properties); + var parser = new CFFParser(cffFile, properties, + SEAC_ANALYSIS_ENABLED); cff = parser.parse(); var compiler = new CFFCompiler(cff); tables['CFF '].data = compiler.compile(); @@ -27369,753 +29923,6 @@ function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) { return charCodeToGlyphId; } -/* - * CharStrings are encoded following the the CharString Encoding sequence - * describe in Chapter 6 of the "Adobe Type1 Font Format" specification. - * The value in a byte indicates a command, a number, or subsequent bytes - * that are to be interpreted in a special way. - * - * CharString Number Encoding: - * A CharString byte containing the values from 32 through 255 inclusive - * indicate an integer. These values are decoded in four ranges. - * - * 1. A CharString byte containing a value, v, between 32 and 246 inclusive, - * indicate the integer v - 139. Thus, the integer values from -107 through - * 107 inclusive may be encoded in single byte. - * - * 2. A CharString byte containing a value, v, between 247 and 250 inclusive, - * indicates an integer involving the next byte, w, according to the formula: - * [(v - 247) x 256] + w + 108 - * - * 3. A CharString byte containing a value, v, between 251 and 254 inclusive, - * indicates an integer involving the next byte, w, according to the formula: - * -[(v - 251) * 256] - w - 108 - * - * 4. A CharString containing the value 255 indicates that the next 4 bytes - * are a two complement signed integer. The first of these bytes contains the - * highest order bits, the second byte contains the next higher order bits - * and the fourth byte contain the lowest order bits. - * - * - * CharString Command Encoding: - * CharStrings commands are encoded in 1 or 2 bytes. - * - * Single byte commands are encoded in 1 byte that contains a value between - * 0 and 31 inclusive. - * If a command byte contains the value 12, then the value in the next byte - * indicates a command. This "escape" mechanism allows many extra commands - * to be encoded and this encoding technique helps to minimize the length of - * the charStrings. - */ -var Type1CharString = (function Type1CharStringClosure() { - var COMMAND_MAP = { - 'hstem': [1], - 'vstem': [3], - 'vmoveto': [4], - 'rlineto': [5], - 'hlineto': [6], - 'vlineto': [7], - 'rrcurveto': [8], - 'callsubr': [10], - 'flex': [12, 35], - 'drop' : [12, 18], - 'endchar': [14], - 'rmoveto': [21], - 'hmoveto': [22], - 'vhcurveto': [30], - 'hvcurveto': [31] - }; - - function Type1CharString() { - this.width = 0; - this.lsb = 0; - this.flexing = false; - this.output = []; - this.stack = []; - } - - Type1CharString.prototype = { - convert: function Type1CharString_convert(encoded, subrs) { - var count = encoded.length; - var error = false; - var wx, sbx, subrNumber; - for (var i = 0; i < count; i++) { - var value = encoded[i]; - if (value < 32) { - if (value === 12) { - value = (value << 8) + encoded[++i]; - } - switch (value) { - case 1: // hstem - if (!HINTING_ENABLED) { - this.stack = []; - break; - } - error = this.executeCommand(2, COMMAND_MAP.hstem); - break; - case 3: // vstem - if (!HINTING_ENABLED) { - this.stack = []; - break; - } - error = this.executeCommand(2, COMMAND_MAP.vstem); - break; - case 4: // vmoveto - if (this.flexing) { - if (this.stack.length < 1) { - error = true; - break; - } - // Add the dx for flex and but also swap the values so they are - // the right order. - var dy = this.stack.pop(); - this.stack.push(0, dy); - break; - } - error = this.executeCommand(1, COMMAND_MAP.vmoveto); - break; - case 5: // rlineto - error = this.executeCommand(2, COMMAND_MAP.rlineto); - break; - case 6: // hlineto - error = this.executeCommand(1, COMMAND_MAP.hlineto); - break; - case 7: // vlineto - error = this.executeCommand(1, COMMAND_MAP.vlineto); - break; - case 8: // rrcurveto - error = this.executeCommand(6, COMMAND_MAP.rrcurveto); - break; - case 9: // closepath - // closepath is a Type1 command that does not take argument and is - // useless in Type2 and it can simply be ignored. - this.stack = []; - break; - case 10: // callsubr - if (this.stack.length < 1) { - error = true; - break; - } - subrNumber = this.stack.pop(); - error = this.convert(subrs[subrNumber], subrs); - break; - case 11: // return - return error; - case 13: // hsbw - if (this.stack.length < 2) { - error = true; - break; - } - // To convert to type2 we have to move the width value to the - // first part of the charstring and then use hmoveto with lsb. - wx = this.stack.pop(); - sbx = this.stack.pop(); - this.lsb = sbx; - this.width = wx; - this.stack.push(wx, sbx); - error = this.executeCommand(2, COMMAND_MAP.hmoveto); - break; - case 14: // endchar - this.output.push(COMMAND_MAP.endchar[0]); - break; - case 21: // rmoveto - if (this.flexing) { - break; - } - error = this.executeCommand(2, COMMAND_MAP.rmoveto); - break; - case 22: // hmoveto - if (this.flexing) { - // Add the dy for flex. - this.stack.push(0); - break; - } - error = this.executeCommand(1, COMMAND_MAP.hmoveto); - break; - case 30: // vhcurveto - error = this.executeCommand(4, COMMAND_MAP.vhcurveto); - break; - case 31: // hvcurveto - error = this.executeCommand(4, COMMAND_MAP.hvcurveto); - break; - case (12 << 8) + 0: // dotsection - // dotsection is a Type1 command to specify some hinting feature - // for dots that do not take a parameter and it can safely be - // ignored for Type2. - this.stack = []; - break; - case (12 << 8) + 1: // vstem3 - if (!HINTING_ENABLED) { - this.stack = []; - break; - } - // [vh]stem3 are Type1 only and Type2 supports [vh]stem with - // multiple parameters, so instead of returning [vh]stem3 take a - // shortcut and return [vhstem] instead. - error = this.executeCommand(2, COMMAND_MAP.vstem); - break; - case (12 << 8) + 2: // hstem3 - if (!HINTING_ENABLED) { - this.stack = []; - break; - } - // See vstem3. - error = this.executeCommand(2, COMMAND_MAP.hstem); - break; - case (12 << 8) + 6: // seac - // seac is like type 2's special endchar but it doesn't use the - // first argument asb, so remove it. - if (SEAC_ANALYSIS_ENABLED) { - this.seac = this.stack.splice(-4, 4); - error = this.executeCommand(0, COMMAND_MAP.endchar); - } else { - error = this.executeCommand(4, COMMAND_MAP.endchar); - } - break; - case (12 << 8) + 7: // sbw - if (this.stack.length < 4) { - error = true; - break; - } - // To convert to type2 we have to move the width value to the - // first part of the charstring and then use rmoveto with - // (dx, dy). The height argument will not be used for vmtx and - // vhea tables reconstruction -- ignoring it. - var wy = this.stack.pop(); - wx = this.stack.pop(); - var sby = this.stack.pop(); - sbx = this.stack.pop(); - this.lsb = sbx; - this.width = wx; - this.stack.push(wx, sbx, sby); - error = this.executeCommand(3, COMMAND_MAP.rmoveto); - break; - case (12 << 8) + 12: // div - if (this.stack.length < 2) { - error = true; - break; - } - var num2 = this.stack.pop(); - var num1 = this.stack.pop(); - this.stack.push(num1 / num2); - break; - case (12 << 8) + 16: // callothersubr - if (this.stack.length < 2) { - error = true; - break; - } - subrNumber = this.stack.pop(); - var numArgs = this.stack.pop(); - if (subrNumber === 0 && numArgs === 3) { - var flexArgs = this.stack.splice(this.stack.length - 17, 17); - this.stack.push( - flexArgs[2] + flexArgs[0], // bcp1x + rpx - flexArgs[3] + flexArgs[1], // bcp1y + rpy - flexArgs[4], // bcp2x - flexArgs[5], // bcp2y - flexArgs[6], // p2x - flexArgs[7], // p2y - flexArgs[8], // bcp3x - flexArgs[9], // bcp3y - flexArgs[10], // bcp4x - flexArgs[11], // bcp4y - flexArgs[12], // p3x - flexArgs[13], // p3y - flexArgs[14] // flexDepth - // 15 = finalx unused by flex - // 16 = finaly unused by flex - ); - error = this.executeCommand(13, COMMAND_MAP.flex, true); - this.flexing = false; - this.stack.push(flexArgs[15], flexArgs[16]); - } else if (subrNumber === 1 && numArgs === 0) { - this.flexing = true; - } - break; - case (12 << 8) + 17: // pop - // Ignore this since it is only used with othersubr. - break; - case (12 << 8) + 33: // setcurrentpoint - // Ignore for now. - this.stack = []; - break; - default: - warn('Unknown type 1 charstring command of "' + value + '"'); - break; - } - if (error) { - break; - } - continue; - } else if (value <= 246) { - value = value - 139; - } else if (value <= 250) { - value = ((value - 247) * 256) + encoded[++i] + 108; - } else if (value <= 254) { - value = -((value - 251) * 256) - encoded[++i] - 108; - } else { - value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | - (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0; - } - this.stack.push(value); - } - return error; - }, - - executeCommand: function(howManyArgs, command, keepStack) { - var stackLength = this.stack.length; - if (howManyArgs > stackLength) { - return true; - } - var start = stackLength - howManyArgs; - for (var i = start; i < stackLength; i++) { - var value = this.stack[i]; - if (value === (value | 0)) { // int - this.output.push(28, (value >> 8) & 0xff, value & 0xff); - } else { // fixed point - value = (65536 * value) | 0; - this.output.push(255, - (value >> 24) & 0xFF, - (value >> 16) & 0xFF, - (value >> 8) & 0xFF, - value & 0xFF); - } - } - this.output.push.apply(this.output, command); - if (keepStack) { - this.stack.splice(start, howManyArgs); - } else { - this.stack.length = 0; - } - return false; - } - }; - - return Type1CharString; -})(); - -/* - * Type1Parser encapsulate the needed code for parsing a Type1 font - * program. Some of its logic depends on the Type2 charstrings - * structure. - * Note: this doesn't really parse the font since that would require evaluation - * of PostScript, but it is possible in most cases to extract what we need - * without a full parse. - */ -var Type1Parser = (function Type1ParserClosure() { - /* - * Decrypt a Sequence of Ciphertext Bytes to Produce the Original Sequence - * of Plaintext Bytes. The function took a key as a parameter which can be - * for decrypting the eexec block of for decoding charStrings. - */ - var EEXEC_ENCRYPT_KEY = 55665; - var CHAR_STRS_ENCRYPT_KEY = 4330; - - function isHexDigit(code) { - return code >= 48 && code <= 57 || // '0'-'9' - code >= 65 && code <= 70 || // 'A'-'F' - code >= 97 && code <= 102; // 'a'-'f' - } - - function decrypt(data, key, discardNumber) { - if (discardNumber >= data.length) { - return new Uint8Array(0); - } - var r = key | 0, c1 = 52845, c2 = 22719, i, j; - for (i = 0; i < discardNumber; i++) { - r = ((data[i] + r) * c1 + c2) & ((1 << 16) - 1); - } - var count = data.length - discardNumber; - var decrypted = new Uint8Array(count); - for (i = discardNumber, j = 0; j < count; i++, j++) { - var value = data[i]; - decrypted[j] = value ^ (r >> 8); - r = ((value + r) * c1 + c2) & ((1 << 16) - 1); - } - return decrypted; - } - - function decryptAscii(data, key, discardNumber) { - var r = key | 0, c1 = 52845, c2 = 22719; - var count = data.length, maybeLength = count >>> 1; - var decrypted = new Uint8Array(maybeLength); - var i, j; - for (i = 0, j = 0; i < count; i++) { - var digit1 = data[i]; - if (!isHexDigit(digit1)) { - continue; - } - i++; - var digit2; - while (i < count && !isHexDigit(digit2 = data[i])) { - i++; - } - if (i < count) { - var value = parseInt(String.fromCharCode(digit1, digit2), 16); - decrypted[j++] = value ^ (r >> 8); - r = ((value + r) * c1 + c2) & ((1 << 16) - 1); - } - } - return Array.prototype.slice.call(decrypted, discardNumber, j); - } - - function isSpecial(c) { - return c === 0x2F || // '/' - c === 0x5B || c === 0x5D || // '[', ']' - c === 0x7B || c === 0x7D || // '{', '}' - c === 0x28 || c === 0x29; // '(', ')' - } - - function Type1Parser(stream, encrypted) { - if (encrypted) { - var data = stream.getBytes(); - var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && - isHexDigit(data[2]) && isHexDigit(data[3])); - stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : - decryptAscii(data, EEXEC_ENCRYPT_KEY, 4)); - } - this.stream = stream; - this.nextChar(); - } - - Type1Parser.prototype = { - readNumberArray: function Type1Parser_readNumberArray() { - this.getToken(); // read '[' or '{' (arrays can start with either) - var array = []; - while (true) { - var token = this.getToken(); - if (token === null || token === ']' || token === '}') { - break; - } - array.push(parseFloat(token || 0)); - } - return array; - }, - - readNumber: function Type1Parser_readNumber() { - var token = this.getToken(); - return parseFloat(token || 0); - }, - - readInt: function Type1Parser_readInt() { - // Use '| 0' to prevent setting a double into length such as the double - // does not flow into the loop variable. - var token = this.getToken(); - return parseInt(token || 0, 10) | 0; - }, - - readBoolean: function Type1Parser_readBoolean() { - var token = this.getToken(); - - // Use 1 and 0 since that's what type2 charstrings use. - return token === 'true' ? 1 : 0; - }, - - nextChar : function Type1_nextChar() { - return (this.currentChar = this.stream.getByte()); - }, - - getToken: function Type1Parser_getToken() { - // Eat whitespace and comments. - var comment = false; - var ch = this.currentChar; - while (true) { - if (ch === -1) { - return null; - } - - if (comment) { - if (ch === 0x0A || ch === 0x0D) { - comment = false; - } - } else if (ch === 0x25) { // '%' - comment = true; - } else if (!Lexer.isSpace(ch)) { - break; - } - ch = this.nextChar(); - } - if (isSpecial(ch)) { - this.nextChar(); - return String.fromCharCode(ch); - } - var token = ''; - do { - token += String.fromCharCode(ch); - ch = this.nextChar(); - } while (ch >= 0 && !Lexer.isSpace(ch) && !isSpecial(ch)); - return token; - }, - - /* - * Returns an object containing a Subrs array and a CharStrings - * array extracted from and eexec encrypted block of data - */ - extractFontProgram: function Type1Parser_extractFontProgram() { - var stream = this.stream; - - var subrs = [], charstrings = []; - var privateData = Object.create(null); - privateData['lenIV'] = 4; - var program = { - subrs: [], - charstrings: [], - properties: { - 'privateData': privateData - } - }; - var token, length, data, lenIV, encoded; - while ((token = this.getToken()) !== null) { - if (token !== '/') { - continue; - } - token = this.getToken(); - switch (token) { - case 'CharStrings': - // The number immediately following CharStrings must be greater or - // equal to the number of CharStrings. - this.getToken(); - this.getToken(); // read in 'dict' - this.getToken(); // read in 'dup' - this.getToken(); // read in 'begin' - while(true) { - token = this.getToken(); - if (token === null || token === 'end') { - break; - } - - if (token !== '/') { - continue; - } - var glyph = this.getToken(); - length = this.readInt(); - this.getToken(); // read in 'RD' or '-|' - data = stream.makeSubStream(stream.pos, length); - lenIV = program.properties.privateData['lenIV']; - encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV); - // Skip past the required space and binary data. - stream.skip(length); - this.nextChar(); - token = this.getToken(); // read in 'ND' or '|-' - if (token === 'noaccess') { - this.getToken(); // read in 'def' - } - charstrings.push({ - glyph: glyph, - encoded: encoded - }); - } - break; - case 'Subrs': - var num = this.readInt(); - this.getToken(); // read in 'array' - while ((token = this.getToken()) === 'dup') { - var index = this.readInt(); - length = this.readInt(); - this.getToken(); // read in 'RD' or '-|' - data = stream.makeSubStream(stream.pos, length); - lenIV = program.properties.privateData['lenIV']; - encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV); - // Skip past the required space and binary data. - stream.skip(length); - this.nextChar(); - token = this.getToken(); // read in 'NP' or '|' - if (token === 'noaccess') { - this.getToken(); // read in 'put' - } - subrs[index] = encoded; - } - break; - case 'BlueValues': - case 'OtherBlues': - case 'FamilyBlues': - case 'FamilyOtherBlues': - var blueArray = this.readNumberArray(); - // *Blue* values may contain invalid data: disables reading of - // those values when hinting is disabled. - if (blueArray.length > 0 && (blueArray.length % 2) === 0 && - HINTING_ENABLED) { - program.properties.privateData[token] = blueArray; - } - break; - case 'StemSnapH': - case 'StemSnapV': - program.properties.privateData[token] = this.readNumberArray(); - break; - case 'StdHW': - case 'StdVW': - program.properties.privateData[token] = - this.readNumberArray()[0]; - break; - case 'BlueShift': - case 'lenIV': - case 'BlueFuzz': - case 'BlueScale': - case 'LanguageGroup': - case 'ExpansionFactor': - program.properties.privateData[token] = this.readNumber(); - break; - case 'ForceBold': - program.properties.privateData[token] = this.readBoolean(); - break; - } - } - - for (var i = 0; i < charstrings.length; i++) { - glyph = charstrings[i].glyph; - encoded = charstrings[i].encoded; - var charString = new Type1CharString(); - var error = charString.convert(encoded, subrs); - var output = charString.output; - if (error) { - // It seems when FreeType encounters an error while evaluating a glyph - // that it completely ignores the glyph so we'll mimic that behaviour - // here and put an endchar to make the validator happy. - output = [14]; - } - program.charstrings.push({ - glyphName: glyph, - charstring: output, - width: charString.width, - lsb: charString.lsb, - seac: charString.seac - }); - } - - return program; - }, - - extractFontHeader: function Type1Parser_extractFontHeader(properties) { - var token; - while ((token = this.getToken()) !== null) { - if (token !== '/') { - continue; - } - token = this.getToken(); - switch (token) { - case 'FontMatrix': - var matrix = this.readNumberArray(); - properties.fontMatrix = matrix; - break; - case 'Encoding': - var encodingArg = this.getToken(); - var encoding; - if (!/^\d+$/.test(encodingArg)) { - // encoding name is specified - encoding = getEncoding(encodingArg); - } else { - encoding = []; - var size = parseInt(encodingArg, 10) | 0; - this.getToken(); // read in 'array' - - for (var j = 0; j < size; j++) { - token = this.getToken(); - // skipping till first dup or def (e.g. ignoring for statement) - while (token !== 'dup' && token !== 'def') { - token = this.getToken(); - if (token === null) { - return; // invalid header - } - } - if (token === 'def') { - break; // read all array data - } - var index = this.readInt(); - this.getToken(); // read in '/' - var glyph = this.getToken(); - encoding[index] = glyph; - this.getToken(); // read the in 'put' - } - } - properties.builtInEncoding = encoding; - break; - case 'FontBBox': - var fontBBox = this.readNumberArray(); - // adjusting ascent/descent - properties.ascent = fontBBox[3]; - properties.descent = fontBBox[1]; - properties.ascentScaled = true; - break; - } - } - } - }; - - return Type1Parser; -})(); - -/** - * The CFF class takes a Type1 file and wrap it into a - * 'Compact Font Format' which itself embed Type2 charstrings. - */ -var CFFStandardStrings = [ - '.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent', - 'ampersand', 'quoteright', 'parenleft', 'parenright', 'asterisk', 'plus', - 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four', - 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less', - 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', - 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright', 'asciicircum', - 'underscore', 'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', - 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', - 'z', 'braceleft', 'bar', 'braceright', 'asciitilde', 'exclamdown', 'cent', - 'sterling', 'fraction', 'yen', 'florin', 'section', 'currency', - 'quotesingle', 'quotedblleft', 'guillemotleft', 'guilsinglleft', - 'guilsinglright', 'fi', 'fl', 'endash', 'dagger', 'daggerdbl', - 'periodcentered', 'paragraph', 'bullet', 'quotesinglbase', 'quotedblbase', - 'quotedblright', 'guillemotright', 'ellipsis', 'perthousand', 'questiondown', - 'grave', 'acute', 'circumflex', 'tilde', 'macron', 'breve', 'dotaccent', - 'dieresis', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron', 'emdash', - 'AE', 'ordfeminine', 'Lslash', 'Oslash', 'OE', 'ordmasculine', 'ae', - 'dotlessi', 'lslash', 'oslash', 'oe', 'germandbls', 'onesuperior', - 'logicalnot', 'mu', 'trademark', 'Eth', 'onehalf', 'plusminus', 'Thorn', - 'onequarter', 'divide', 'brokenbar', 'degree', 'thorn', 'threequarters', - 'twosuperior', 'registered', 'minus', 'eth', 'multiply', 'threesuperior', - 'copyright', 'Aacute', 'Acircumflex', 'Adieresis', 'Agrave', 'Aring', - 'Atilde', 'Ccedilla', 'Eacute', 'Ecircumflex', 'Edieresis', 'Egrave', - 'Iacute', 'Icircumflex', 'Idieresis', 'Igrave', 'Ntilde', 'Oacute', - 'Ocircumflex', 'Odieresis', 'Ograve', 'Otilde', 'Scaron', 'Uacute', - 'Ucircumflex', 'Udieresis', 'Ugrave', 'Yacute', 'Ydieresis', 'Zcaron', - 'aacute', 'acircumflex', 'adieresis', 'agrave', 'aring', 'atilde', - 'ccedilla', 'eacute', 'ecircumflex', 'edieresis', 'egrave', 'iacute', - 'icircumflex', 'idieresis', 'igrave', 'ntilde', 'oacute', 'ocircumflex', - 'odieresis', 'ograve', 'otilde', 'scaron', 'uacute', 'ucircumflex', - 'udieresis', 'ugrave', 'yacute', 'ydieresis', 'zcaron', 'exclamsmall', - 'Hungarumlautsmall', 'dollaroldstyle', 'dollarsuperior', 'ampersandsmall', - 'Acutesmall', 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader', - 'onedotenleader', 'zerooldstyle', 'oneoldstyle', 'twooldstyle', - 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle', - 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'commasuperior', - 'threequartersemdash', 'periodsuperior', 'questionsmall', 'asuperior', - 'bsuperior', 'centsuperior', 'dsuperior', 'esuperior', 'isuperior', - 'lsuperior', 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior', - 'tsuperior', 'ff', 'ffi', 'ffl', 'parenleftinferior', 'parenrightinferior', - 'Circumflexsmall', 'hyphensuperior', 'Gravesmall', 'Asmall', 'Bsmall', - 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall', - 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall', - 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall', - 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', 'onefitted', 'rupiah', - 'Tildesmall', 'exclamdownsmall', 'centoldstyle', 'Lslashsmall', - 'Scaronsmall', 'Zcaronsmall', 'Dieresissmall', 'Brevesmall', 'Caronsmall', - 'Dotaccentsmall', 'Macronsmall', 'figuredash', 'hypheninferior', - 'Ogoneksmall', 'Ringsmall', 'Cedillasmall', 'questiondownsmall', 'oneeighth', - 'threeeighths', 'fiveeighths', 'seveneighths', 'onethird', 'twothirds', - 'zerosuperior', 'foursuperior', 'fivesuperior', 'sixsuperior', - 'sevensuperior', 'eightsuperior', 'ninesuperior', 'zeroinferior', - 'oneinferior', 'twoinferior', 'threeinferior', 'fourinferior', - 'fiveinferior', 'sixinferior', 'seveninferior', 'eightinferior', - 'nineinferior', 'centinferior', 'dollarinferior', 'periodinferior', - 'commainferior', 'Agravesmall', 'Aacutesmall', 'Acircumflexsmall', - 'Atildesmall', 'Adieresissmall', 'Aringsmall', 'AEsmall', 'Ccedillasmall', - 'Egravesmall', 'Eacutesmall', 'Ecircumflexsmall', 'Edieresissmall', - 'Igravesmall', 'Iacutesmall', 'Icircumflexsmall', 'Idieresissmall', - 'Ethsmall', 'Ntildesmall', 'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall', - 'Otildesmall', 'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall', - 'Uacutesmall', 'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall', - 'Thornsmall', 'Ydieresissmall', '001.000', '001.001', '001.002', '001.003', - 'Black', 'Bold', 'Book', 'Light', 'Medium', 'Regular', 'Roman', 'Semibold' -]; - // Type1Font is also a CIDFontType0. var Type1Font = (function Type1FontClosure() { function findBlock(streamBytes, signature, startIndex) { @@ -28250,7 +30057,8 @@ var Type1Font = (function Type1FontClosure() { // Get the data block containing glyphs and subrs informations var headerBlock = getHeaderBlock(file, headerBlockLength); headerBlockLength = headerBlock.length; - var headerBlockParser = new Type1Parser(headerBlock.stream); + var headerBlockParser = new Type1Parser(headerBlock.stream, false, + SEAC_ANALYSIS_ENABLED); headerBlockParser.extractFontHeader(properties); if (pfbHeaderPresent) { @@ -28262,7 +30070,8 @@ var Type1Font = (function Type1FontClosure() { // Decrypt the data blocks and retrieve it's content var eexecBlock = getEexecBlock(file, eexecBlockLength); eexecBlockLength = eexecBlock.length; - var eexecBlockParser = new Type1Parser(eexecBlock.stream, true); + var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, + SEAC_ANALYSIS_ENABLED); var data = eexecBlockParser.extractFontProgram(); for (var info in data.properties) { properties[info] = data.properties[info]; @@ -28468,7 +30277,7 @@ var CFFFont = (function CFFFontClosure() { function CFFFont(file, properties) { this.properties = properties; - var parser = new CFFParser(file, properties); + var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED); this.cff = parser.parse(); var compiler = new CFFCompiler(this.cff); this.seacs = this.cff.seacs; @@ -28525,1524 +30334,6 @@ var CFFFont = (function CFFFontClosure() { return CFFFont; })(); -var CFFParser = (function CFFParserClosure() { - var CharstringValidationData = [ - null, - { id: 'hstem', min: 2, stackClearing: true, stem: true }, - null, - { id: 'vstem', min: 2, stackClearing: true, stem: true }, - { id: 'vmoveto', min: 1, stackClearing: true }, - { id: 'rlineto', min: 2, resetStack: true }, - { id: 'hlineto', min: 1, resetStack: true }, - { id: 'vlineto', min: 1, resetStack: true }, - { id: 'rrcurveto', min: 6, resetStack: true }, - null, - { id: 'callsubr', min: 1, undefStack: true }, - { id: 'return', min: 0, undefStack: true }, - null, // 12 - null, - { id: 'endchar', min: 0, stackClearing: true }, - null, - null, - null, - { id: 'hstemhm', min: 2, stackClearing: true, stem: true }, - { id: 'hintmask', min: 0, stackClearing: true }, - { id: 'cntrmask', min: 0, stackClearing: true }, - { id: 'rmoveto', min: 2, stackClearing: true }, - { id: 'hmoveto', min: 1, stackClearing: true }, - { id: 'vstemhm', min: 2, stackClearing: true, stem: true }, - { id: 'rcurveline', min: 8, resetStack: true }, - { id: 'rlinecurve', min: 8, resetStack: true }, - { id: 'vvcurveto', min: 4, resetStack: true }, - { id: 'hhcurveto', min: 4, resetStack: true }, - null, // shortint - { id: 'callgsubr', min: 1, undefStack: true }, - { id: 'vhcurveto', min: 4, resetStack: true }, - { id: 'hvcurveto', min: 4, resetStack: true } - ]; - var CharstringValidationData12 = [ - null, - null, - null, - { id: 'and', min: 2, stackDelta: -1 }, - { id: 'or', min: 2, stackDelta: -1 }, - { id: 'not', min: 1, stackDelta: 0 }, - null, - null, - null, - { id: 'abs', min: 1, stackDelta: 0 }, - { id: 'add', min: 2, stackDelta: -1, - stackFn: function stack_div(stack, index) { - stack[index - 2] = stack[index - 2] + stack[index - 1]; - } - }, - { id: 'sub', min: 2, stackDelta: -1, - stackFn: function stack_div(stack, index) { - stack[index - 2] = stack[index - 2] - stack[index - 1]; - } - }, - { id: 'div', min: 2, stackDelta: -1, - stackFn: function stack_div(stack, index) { - stack[index - 2] = stack[index - 2] / stack[index - 1]; - } - }, - null, - { id: 'neg', min: 1, stackDelta: 0, - stackFn: function stack_div(stack, index) { - stack[index - 1] = -stack[index - 1]; - } - }, - { id: 'eq', min: 2, stackDelta: -1 }, - null, - null, - { id: 'drop', min: 1, stackDelta: -1 }, - null, - { id: 'put', min: 2, stackDelta: -2 }, - { id: 'get', min: 1, stackDelta: 0 }, - { id: 'ifelse', min: 4, stackDelta: -3 }, - { id: 'random', min: 0, stackDelta: 1 }, - { id: 'mul', min: 2, stackDelta: -1, - stackFn: function stack_div(stack, index) { - stack[index - 2] = stack[index - 2] * stack[index - 1]; - } - }, - null, - { id: 'sqrt', min: 1, stackDelta: 0 }, - { id: 'dup', min: 1, stackDelta: 1 }, - { id: 'exch', min: 2, stackDelta: 0 }, - { id: 'index', min: 2, stackDelta: 0 }, - { id: 'roll', min: 3, stackDelta: -2 }, - null, - null, - null, - { id: 'hflex', min: 7, resetStack: true }, - { id: 'flex', min: 13, resetStack: true }, - { id: 'hflex1', min: 9, resetStack: true }, - { id: 'flex1', min: 11, resetStack: true } - ]; - - function CFFParser(file, properties) { - this.bytes = file.getBytes(); - this.properties = properties; - } - CFFParser.prototype = { - parse: function CFFParser_parse() { - var properties = this.properties; - var cff = new CFF(); - this.cff = cff; - - // The first five sections must be in order, all the others are reached - // via offsets contained in one of the below. - var header = this.parseHeader(); - var nameIndex = this.parseIndex(header.endPos); - var topDictIndex = this.parseIndex(nameIndex.endPos); - var stringIndex = this.parseIndex(topDictIndex.endPos); - var globalSubrIndex = this.parseIndex(stringIndex.endPos); - - var topDictParsed = this.parseDict(topDictIndex.obj.get(0)); - var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings); - - cff.header = header.obj; - cff.names = this.parseNameIndex(nameIndex.obj); - cff.strings = this.parseStringIndex(stringIndex.obj); - cff.topDict = topDict; - cff.globalSubrIndex = globalSubrIndex.obj; - - this.parsePrivateDict(cff.topDict); - - cff.isCIDFont = topDict.hasName('ROS'); - - var charStringOffset = topDict.getByName('CharStrings'); - var charStringIndex = this.parseIndex(charStringOffset).obj; - - var fontMatrix = topDict.getByName('FontMatrix'); - if (fontMatrix) { - properties.fontMatrix = fontMatrix; - } - - var fontBBox = topDict.getByName('FontBBox'); - if (fontBBox) { - // adjusting ascent/descent - properties.ascent = fontBBox[3]; - properties.descent = fontBBox[1]; - properties.ascentScaled = true; - } - - var charset, encoding; - if (cff.isCIDFont) { - var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj; - for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) { - var dictRaw = fdArrayIndex.get(i); - var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), - cff.strings); - this.parsePrivateDict(fontDict); - cff.fdArray.push(fontDict); - } - // cid fonts don't have an encoding - encoding = null; - charset = this.parseCharsets(topDict.getByName('charset'), - charStringIndex.count, cff.strings, true); - cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), - charStringIndex.count); - } else { - charset = this.parseCharsets(topDict.getByName('charset'), - charStringIndex.count, cff.strings, false); - encoding = this.parseEncoding(topDict.getByName('Encoding'), - properties, - cff.strings, charset.charset); - } - - cff.charset = charset; - cff.encoding = encoding; - - var charStringsAndSeacs = this.parseCharStrings( - charStringIndex, - topDict.privateDict.subrsIndex, - globalSubrIndex.obj, - cff.fdSelect, - cff.fdArray); - cff.charStrings = charStringsAndSeacs.charStrings; - cff.seacs = charStringsAndSeacs.seacs; - cff.widths = charStringsAndSeacs.widths; - - return cff; - }, - parseHeader: function CFFParser_parseHeader() { - var bytes = this.bytes; - var bytesLength = bytes.length; - var offset = 0; - - // Prevent an infinite loop, by checking that the offset is within the - // bounds of the bytes array. Necessary in empty, or invalid, font files. - while (offset < bytesLength && bytes[offset] !== 1) { - ++offset; - } - if (offset >= bytesLength) { - error('Invalid CFF header'); - } else if (offset !== 0) { - info('cff data is shifted'); - bytes = bytes.subarray(offset); - this.bytes = bytes; - } - var major = bytes[0]; - var minor = bytes[1]; - var hdrSize = bytes[2]; - var offSize = bytes[3]; - var header = new CFFHeader(major, minor, hdrSize, offSize); - return { obj: header, endPos: hdrSize }; - }, - parseDict: function CFFParser_parseDict(dict) { - var pos = 0; - - function parseOperand() { - var value = dict[pos++]; - if (value === 30) { - return parseFloatOperand(pos); - } else if (value === 28) { - value = dict[pos++]; - value = ((value << 24) | (dict[pos++] << 16)) >> 16; - return value; - } else if (value === 29) { - value = dict[pos++]; - value = (value << 8) | dict[pos++]; - value = (value << 8) | dict[pos++]; - value = (value << 8) | dict[pos++]; - return value; - } else if (value >= 32 && value <= 246) { - return value - 139; - } else if (value >= 247 && value <= 250) { - return ((value - 247) * 256) + dict[pos++] + 108; - } else if (value >= 251 && value <= 254) { - return -((value - 251) * 256) - dict[pos++] - 108; - } else { - error('255 is not a valid DICT command'); - } - return -1; - } - - function parseFloatOperand() { - var str = ''; - var eof = 15; - var lookup = ['0', '1', '2', '3', '4', '5', '6', '7', '8', - '9', '.', 'E', 'E-', null, '-']; - var length = dict.length; - while (pos < length) { - var b = dict[pos++]; - var b1 = b >> 4; - var b2 = b & 15; - - if (b1 === eof) { - break; - } - str += lookup[b1]; - - if (b2 === eof) { - break; - } - str += lookup[b2]; - } - return parseFloat(str); - } - - var operands = []; - var entries = []; - - pos = 0; - var end = dict.length; - while (pos < end) { - var b = dict[pos]; - if (b <= 21) { - if (b === 12) { - b = (b << 8) | dict[++pos]; - } - entries.push([b, operands]); - operands = []; - ++pos; - } else { - operands.push(parseOperand()); - } - } - return entries; - }, - parseIndex: function CFFParser_parseIndex(pos) { - var cffIndex = new CFFIndex(); - var bytes = this.bytes; - var count = (bytes[pos++] << 8) | bytes[pos++]; - var offsets = []; - var end = pos; - var i, ii; - - if (count !== 0) { - var offsetSize = bytes[pos++]; - // add 1 for offset to determine size of last object - var startPos = pos + ((count + 1) * offsetSize) - 1; - - for (i = 0, ii = count + 1; i < ii; ++i) { - var offset = 0; - for (var j = 0; j < offsetSize; ++j) { - offset <<= 8; - offset += bytes[pos++]; - } - offsets.push(startPos + offset); - } - end = offsets[count]; - } - for (i = 0, ii = offsets.length - 1; i < ii; ++i) { - var offsetStart = offsets[i]; - var offsetEnd = offsets[i + 1]; - cffIndex.add(bytes.subarray(offsetStart, offsetEnd)); - } - return {obj: cffIndex, endPos: end}; - }, - parseNameIndex: function CFFParser_parseNameIndex(index) { - var names = []; - for (var i = 0, ii = index.count; i < ii; ++i) { - var name = index.get(i); - // OTS doesn't allow names to be over 127 characters. - var length = Math.min(name.length, 127); - var data = []; - // OTS also only permits certain characters in the name. - for (var j = 0; j < length; ++j) { - var c = name[j]; - if (j === 0 && c === 0) { - data[j] = c; - continue; - } - if ((c < 33 || c > 126) || c === 91 /* [ */ || c === 93 /* ] */ || - c === 40 /* ( */ || c === 41 /* ) */ || c === 123 /* { */ || - c === 125 /* } */ || c === 60 /* < */ || c === 62 /* > */ || - c === 47 /* / */ || c === 37 /* % */ || c === 35 /* # */) { - data[j] = 95; - continue; - } - data[j] = c; - } - names.push(bytesToString(data)); - } - return names; - }, - parseStringIndex: function CFFParser_parseStringIndex(index) { - var strings = new CFFStrings(); - for (var i = 0, ii = index.count; i < ii; ++i) { - var data = index.get(i); - strings.add(bytesToString(data)); - } - return strings; - }, - createDict: function CFFParser_createDict(Type, dict, strings) { - var cffDict = new Type(strings); - for (var i = 0, ii = dict.length; i < ii; ++i) { - var pair = dict[i]; - var key = pair[0]; - var value = pair[1]; - cffDict.setByKey(key, value); - } - return cffDict; - }, - parseCharString: function CFFParser_parseCharString(state, data, - localSubrIndex, - globalSubrIndex) { - if (state.callDepth > MAX_SUBR_NESTING) { - return false; - } - var stackSize = state.stackSize; - var stack = state.stack; - - var length = data.length; - - for (var j = 0; j < length;) { - var value = data[j++]; - var validationCommand = null; - if (value === 12) { - var q = data[j++]; - if (q === 0) { - // The CFF specification state that the 'dotsection' command - // (12, 0) is deprecated and treated as a no-op, but all Type2 - // charstrings processors should support them. Unfortunately - // the font sanitizer don't. As a workaround the sequence (12, 0) - // is replaced by a useless (0, hmoveto). - data[j - 2] = 139; - data[j - 1] = 22; - stackSize = 0; - } else { - validationCommand = CharstringValidationData12[q]; - } - } else if (value === 28) { // number (16 bit) - stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16)) >> 16; - j += 2; - stackSize++; - } else if (value === 14) { - if (stackSize >= 4) { - stackSize -= 4; - if (SEAC_ANALYSIS_ENABLED) { - state.seac = stack.slice(stackSize, stackSize + 4); - return false; - } - } - validationCommand = CharstringValidationData[value]; - } else if (value >= 32 && value <= 246) { // number - stack[stackSize] = value - 139; - stackSize++; - } else if (value >= 247 && value <= 254) { // number (+1 bytes) - stack[stackSize] = (value < 251 ? - ((value - 247) << 8) + data[j] + 108 : - -((value - 251) << 8) - data[j] - 108); - j++; - stackSize++; - } else if (value === 255) { // number (32 bit) - stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16) | - (data[j + 2] << 8) | data[j + 3]) / 65536; - j += 4; - stackSize++; - } else if (value === 19 || value === 20) { - state.hints += stackSize >> 1; - // skipping right amount of hints flag data - j += (state.hints + 7) >> 3; - stackSize %= 2; - validationCommand = CharstringValidationData[value]; - } else if (value === 10 || value === 29) { - var subrsIndex; - if (value === 10) { - subrsIndex = localSubrIndex; - } else { - subrsIndex = globalSubrIndex; - } - if (!subrsIndex) { - validationCommand = CharstringValidationData[value]; - warn('Missing subrsIndex for ' + validationCommand.id); - return false; - } - var bias = 32768; - if (subrsIndex.count < 1240) { - bias = 107; - } else if (subrsIndex.count < 33900) { - bias = 1131; - } - var subrNumber = stack[--stackSize] + bias; - if (subrNumber < 0 || subrNumber >= subrsIndex.count) { - validationCommand = CharstringValidationData[value]; - warn('Out of bounds subrIndex for ' + validationCommand.id); - return false; - } - state.stackSize = stackSize; - state.callDepth++; - var valid = this.parseCharString(state, subrsIndex.get(subrNumber), - localSubrIndex, globalSubrIndex); - if (!valid) { - return false; - } - state.callDepth--; - stackSize = state.stackSize; - continue; - } else if (value === 11) { - state.stackSize = stackSize; - return true; - } else { - validationCommand = CharstringValidationData[value]; - } - if (validationCommand) { - if (validationCommand.stem) { - state.hints += stackSize >> 1; - } - if ('min' in validationCommand) { - if (!state.undefStack && stackSize < validationCommand.min) { - warn('Not enough parameters for ' + validationCommand.id + - '; actual: ' + stackSize + - ', expected: ' + validationCommand.min); - return false; - } - } - if (state.firstStackClearing && validationCommand.stackClearing) { - state.firstStackClearing = false; - // the optional character width can be found before the first - // stack-clearing command arguments - stackSize -= validationCommand.min; - if (stackSize >= 2 && validationCommand.stem) { - // there are even amount of arguments for stem commands - stackSize %= 2; - } else if (stackSize > 1) { - warn('Found too many parameters for stack-clearing command'); - } - if (stackSize > 0 && stack[stackSize - 1] >= 0) { - state.width = stack[stackSize - 1]; - } - } - if ('stackDelta' in validationCommand) { - if ('stackFn' in validationCommand) { - validationCommand.stackFn(stack, stackSize); - } - stackSize += validationCommand.stackDelta; - } else if (validationCommand.stackClearing) { - stackSize = 0; - } else if (validationCommand.resetStack) { - stackSize = 0; - state.undefStack = false; - } else if (validationCommand.undefStack) { - stackSize = 0; - state.undefStack = true; - state.firstStackClearing = false; - } - } - } - state.stackSize = stackSize; - return true; - }, - parseCharStrings: function CFFParser_parseCharStrings(charStrings, - localSubrIndex, - globalSubrIndex, - fdSelect, - fdArray) { - var seacs = []; - var widths = []; - var count = charStrings.count; - for (var i = 0; i < count; i++) { - var charstring = charStrings.get(i); - var state = { - callDepth: 0, - stackSize: 0, - stack: [], - undefStack: true, - hints: 0, - firstStackClearing: true, - seac: null, - width: null - }; - var valid = true; - var localSubrToUse = null; - if (fdSelect && fdArray.length) { - var fdIndex = fdSelect.getFDIndex(i); - if (fdIndex === -1) { - warn('Glyph index is not in fd select.'); - valid = false; - } - if (fdIndex >= fdArray.length) { - warn('Invalid fd index for glyph index.'); - valid = false; - } - if (valid) { - localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex; - } - } else if (localSubrIndex) { - localSubrToUse = localSubrIndex; - } - if (valid) { - valid = this.parseCharString(state, charstring, localSubrToUse, - globalSubrIndex); - } - if (state.width !== null) { - widths[i] = state.width; - } - if (state.seac !== null) { - seacs[i] = state.seac; - } - if (!valid) { - // resetting invalid charstring to single 'endchar' - charStrings.set(i, new Uint8Array([14])); - } - } - return { charStrings: charStrings, seacs: seacs, widths: widths }; - }, - emptyPrivateDictionary: - function CFFParser_emptyPrivateDictionary(parentDict) { - var privateDict = this.createDict(CFFPrivateDict, [], - parentDict.strings); - parentDict.setByKey(18, [0, 0]); - parentDict.privateDict = privateDict; - }, - parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) { - // no private dict, do nothing - if (!parentDict.hasName('Private')) { - this.emptyPrivateDictionary(parentDict); - return; - } - var privateOffset = parentDict.getByName('Private'); - // make sure the params are formatted correctly - if (!isArray(privateOffset) || privateOffset.length !== 2) { - parentDict.removeByName('Private'); - return; - } - var size = privateOffset[0]; - var offset = privateOffset[1]; - // remove empty dicts or ones that refer to invalid location - if (size === 0 || offset >= this.bytes.length) { - this.emptyPrivateDictionary(parentDict); - return; - } - - var privateDictEnd = offset + size; - var dictData = this.bytes.subarray(offset, privateDictEnd); - var dict = this.parseDict(dictData); - var privateDict = this.createDict(CFFPrivateDict, dict, - parentDict.strings); - parentDict.privateDict = privateDict; - - // Parse the Subrs index also since it's relative to the private dict. - if (!privateDict.getByName('Subrs')) { - return; - } - var subrsOffset = privateDict.getByName('Subrs'); - var relativeOffset = offset + subrsOffset; - // Validate the offset. - if (subrsOffset === 0 || relativeOffset >= this.bytes.length) { - this.emptyPrivateDictionary(parentDict); - return; - } - var subrsIndex = this.parseIndex(relativeOffset); - privateDict.subrsIndex = subrsIndex.obj; - }, - parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) { - if (pos === 0) { - return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, - ISOAdobeCharset); - } else if (pos === 1) { - return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, - ExpertCharset); - } else if (pos === 2) { - return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, - ExpertSubsetCharset); - } - - var bytes = this.bytes; - var start = pos; - var format = bytes[pos++]; - var charset = ['.notdef']; - var id, count, i; - - // subtract 1 for the .notdef glyph - length -= 1; - - switch (format) { - case 0: - for (i = 0; i < length; i++) { - id = (bytes[pos++] << 8) | bytes[pos++]; - charset.push(cid ? id : strings.get(id)); - } - break; - case 1: - while (charset.length <= length) { - id = (bytes[pos++] << 8) | bytes[pos++]; - count = bytes[pos++]; - for (i = 0; i <= count; i++) { - charset.push(cid ? id++ : strings.get(id++)); - } - } - break; - case 2: - while (charset.length <= length) { - id = (bytes[pos++] << 8) | bytes[pos++]; - count = (bytes[pos++] << 8) | bytes[pos++]; - for (i = 0; i <= count; i++) { - charset.push(cid ? id++ : strings.get(id++)); - } - } - break; - default: - error('Unknown charset format'); - } - // Raw won't be needed if we actually compile the charset. - var end = pos; - var raw = bytes.subarray(start, end); - - return new CFFCharset(false, format, charset, raw); - }, - parseEncoding: function CFFParser_parseEncoding(pos, - properties, - strings, - charset) { - var encoding = Object.create(null); - var bytes = this.bytes; - var predefined = false; - var hasSupplement = false; - var format, i, ii; - var raw = null; - - function readSupplement() { - var supplementsCount = bytes[pos++]; - for (i = 0; i < supplementsCount; i++) { - var code = bytes[pos++]; - var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff); - encoding[code] = charset.indexOf(strings.get(sid)); - } - } - - if (pos === 0 || pos === 1) { - predefined = true; - format = pos; - var baseEncoding = pos ? ExpertEncoding : StandardEncoding; - for (i = 0, ii = charset.length; i < ii; i++) { - var index = baseEncoding.indexOf(charset[i]); - if (index !== -1) { - encoding[index] = i; - } - } - } else { - var dataStart = pos; - format = bytes[pos++]; - switch (format & 0x7f) { - case 0: - var glyphsCount = bytes[pos++]; - for (i = 1; i <= glyphsCount; i++) { - encoding[bytes[pos++]] = i; - } - break; - - case 1: - var rangesCount = bytes[pos++]; - var gid = 1; - for (i = 0; i < rangesCount; i++) { - var start = bytes[pos++]; - var left = bytes[pos++]; - for (var j = start; j <= start + left; j++) { - encoding[j] = gid++; - } - } - break; - - default: - error('Unknow encoding format: ' + format + ' in CFF'); - break; - } - var dataEnd = pos; - if (format & 0x80) { - // The font sanitizer does not support CFF encoding with a - // supplement, since the encoding is not really used to map - // between gid to glyph, let's overwrite what is declared in - // the top dictionary to let the sanitizer think the font use - // StandardEncoding, that's a lie but that's ok. - bytes[dataStart] &= 0x7f; - readSupplement(); - hasSupplement = true; - } - raw = bytes.subarray(dataStart, dataEnd); - } - format = format & 0x7f; - return new CFFEncoding(predefined, format, encoding, raw); - }, - parseFDSelect: function CFFParser_parseFDSelect(pos, length) { - var start = pos; - var bytes = this.bytes; - var format = bytes[pos++]; - var fdSelect = []; - var i; - - switch (format) { - case 0: - for (i = 0; i < length; ++i) { - var id = bytes[pos++]; - fdSelect.push(id); - } - break; - case 3: - var rangesCount = (bytes[pos++] << 8) | bytes[pos++]; - for (i = 0; i < rangesCount; ++i) { - var first = (bytes[pos++] << 8) | bytes[pos++]; - var fdIndex = bytes[pos++]; - var next = (bytes[pos] << 8) | bytes[pos + 1]; - for (var j = first; j < next; ++j) { - fdSelect.push(fdIndex); - } - } - // Advance past the sentinel(next). - pos += 2; - break; - default: - error('Unknown fdselect format ' + format); - break; - } - var end = pos; - return new CFFFDSelect(fdSelect, bytes.subarray(start, end)); - } - }; - return CFFParser; -})(); - -// Compact Font Format -var CFF = (function CFFClosure() { - function CFF() { - this.header = null; - this.names = []; - this.topDict = null; - this.strings = new CFFStrings(); - this.globalSubrIndex = null; - - // The following could really be per font, but since we only have one font - // store them here. - this.encoding = null; - this.charset = null; - this.charStrings = null; - this.fdArray = []; - this.fdSelect = null; - - this.isCIDFont = false; - } - return CFF; -})(); - -var CFFHeader = (function CFFHeaderClosure() { - function CFFHeader(major, minor, hdrSize, offSize) { - this.major = major; - this.minor = minor; - this.hdrSize = hdrSize; - this.offSize = offSize; - } - return CFFHeader; -})(); - -var CFFStrings = (function CFFStringsClosure() { - function CFFStrings() { - this.strings = []; - } - CFFStrings.prototype = { - get: function CFFStrings_get(index) { - if (index >= 0 && index <= 390) { - return CFFStandardStrings[index]; - } - if (index - 391 <= this.strings.length) { - return this.strings[index - 391]; - } - return CFFStandardStrings[0]; - }, - add: function CFFStrings_add(value) { - this.strings.push(value); - }, - get count() { - return this.strings.length; - } - }; - return CFFStrings; -})(); - -var CFFIndex = (function CFFIndexClosure() { - function CFFIndex() { - this.objects = []; - this.length = 0; - } - CFFIndex.prototype = { - add: function CFFIndex_add(data) { - this.length += data.length; - this.objects.push(data); - }, - set: function CFFIndex_set(index, data) { - this.length += data.length - this.objects[index].length; - this.objects[index] = data; - }, - get: function CFFIndex_get(index) { - return this.objects[index]; - }, - get count() { - return this.objects.length; - } - }; - return CFFIndex; -})(); - -var CFFDict = (function CFFDictClosure() { - function CFFDict(tables, strings) { - this.keyToNameMap = tables.keyToNameMap; - this.nameToKeyMap = tables.nameToKeyMap; - this.defaults = tables.defaults; - this.types = tables.types; - this.opcodes = tables.opcodes; - this.order = tables.order; - this.strings = strings; - this.values = Object.create(null); - } - CFFDict.prototype = { - // value should always be an array - setByKey: function CFFDict_setByKey(key, value) { - if (!(key in this.keyToNameMap)) { - return false; - } - // ignore empty values - if (value.length === 0) { - return true; - } - var type = this.types[key]; - // remove the array wrapping these types of values - if (type === 'num' || type === 'sid' || type === 'offset') { - value = value[0]; - } - this.values[key] = value; - return true; - }, - setByName: function CFFDict_setByName(name, value) { - if (!(name in this.nameToKeyMap)) { - error('Invalid dictionary name "' + name + '"'); - } - this.values[this.nameToKeyMap[name]] = value; - }, - hasName: function CFFDict_hasName(name) { - return this.nameToKeyMap[name] in this.values; - }, - getByName: function CFFDict_getByName(name) { - if (!(name in this.nameToKeyMap)) { - error('Invalid dictionary name "' + name + '"'); - } - var key = this.nameToKeyMap[name]; - if (!(key in this.values)) { - return this.defaults[key]; - } - return this.values[key]; - }, - removeByName: function CFFDict_removeByName(name) { - delete this.values[this.nameToKeyMap[name]]; - } - }; - CFFDict.createTables = function CFFDict_createTables(layout) { - var tables = { - keyToNameMap: {}, - nameToKeyMap: {}, - defaults: {}, - types: {}, - opcodes: {}, - order: [] - }; - for (var i = 0, ii = layout.length; i < ii; ++i) { - var entry = layout[i]; - var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0]; - tables.keyToNameMap[key] = entry[1]; - tables.nameToKeyMap[entry[1]] = key; - tables.types[key] = entry[2]; - tables.defaults[key] = entry[3]; - tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]]; - tables.order.push(key); - } - return tables; - }; - return CFFDict; -})(); - -var CFFTopDict = (function CFFTopDictClosure() { - var layout = [ - [[12, 30], 'ROS', ['sid', 'sid', 'num'], null], - [[12, 20], 'SyntheticBase', 'num', null], - [0, 'version', 'sid', null], - [1, 'Notice', 'sid', null], - [[12, 0], 'Copyright', 'sid', null], - [2, 'FullName', 'sid', null], - [3, 'FamilyName', 'sid', null], - [4, 'Weight', 'sid', null], - [[12, 1], 'isFixedPitch', 'num', 0], - [[12, 2], 'ItalicAngle', 'num', 0], - [[12, 3], 'UnderlinePosition', 'num', -100], - [[12, 4], 'UnderlineThickness', 'num', 50], - [[12, 5], 'PaintType', 'num', 0], - [[12, 6], 'CharstringType', 'num', 2], - [[12, 7], 'FontMatrix', ['num', 'num', 'num', 'num', 'num', 'num'], - [0.001, 0, 0, 0.001, 0, 0]], - [13, 'UniqueID', 'num', null], - [5, 'FontBBox', ['num', 'num', 'num', 'num'], [0, 0, 0, 0]], - [[12, 8], 'StrokeWidth', 'num', 0], - [14, 'XUID', 'array', null], - [15, 'charset', 'offset', 0], - [16, 'Encoding', 'offset', 0], - [17, 'CharStrings', 'offset', 0], - [18, 'Private', ['offset', 'offset'], null], - [[12, 21], 'PostScript', 'sid', null], - [[12, 22], 'BaseFontName', 'sid', null], - [[12, 23], 'BaseFontBlend', 'delta', null], - [[12, 31], 'CIDFontVersion', 'num', 0], - [[12, 32], 'CIDFontRevision', 'num', 0], - [[12, 33], 'CIDFontType', 'num', 0], - [[12, 34], 'CIDCount', 'num', 8720], - [[12, 35], 'UIDBase', 'num', null], - // XXX: CID Fonts on DirectWrite 6.1 only seem to work if FDSelect comes - // before FDArray. - [[12, 37], 'FDSelect', 'offset', null], - [[12, 36], 'FDArray', 'offset', null], - [[12, 38], 'FontName', 'sid', null] - ]; - var tables = null; - function CFFTopDict(strings) { - if (tables === null) { - tables = CFFDict.createTables(layout); - } - CFFDict.call(this, tables, strings); - this.privateDict = null; - } - CFFTopDict.prototype = Object.create(CFFDict.prototype); - return CFFTopDict; -})(); - -var CFFPrivateDict = (function CFFPrivateDictClosure() { - var layout = [ - [6, 'BlueValues', 'delta', null], - [7, 'OtherBlues', 'delta', null], - [8, 'FamilyBlues', 'delta', null], - [9, 'FamilyOtherBlues', 'delta', null], - [[12, 9], 'BlueScale', 'num', 0.039625], - [[12, 10], 'BlueShift', 'num', 7], - [[12, 11], 'BlueFuzz', 'num', 1], - [10, 'StdHW', 'num', null], - [11, 'StdVW', 'num', null], - [[12, 12], 'StemSnapH', 'delta', null], - [[12, 13], 'StemSnapV', 'delta', null], - [[12, 14], 'ForceBold', 'num', 0], - [[12, 17], 'LanguageGroup', 'num', 0], - [[12, 18], 'ExpansionFactor', 'num', 0.06], - [[12, 19], 'initialRandomSeed', 'num', 0], - [20, 'defaultWidthX', 'num', 0], - [21, 'nominalWidthX', 'num', 0], - [19, 'Subrs', 'offset', null] - ]; - var tables = null; - function CFFPrivateDict(strings) { - if (tables === null) { - tables = CFFDict.createTables(layout); - } - CFFDict.call(this, tables, strings); - this.subrsIndex = null; - } - CFFPrivateDict.prototype = Object.create(CFFDict.prototype); - return CFFPrivateDict; -})(); - -var CFFCharsetPredefinedTypes = { - ISO_ADOBE: 0, - EXPERT: 1, - EXPERT_SUBSET: 2 -}; -var CFFCharset = (function CFFCharsetClosure() { - function CFFCharset(predefined, format, charset, raw) { - this.predefined = predefined; - this.format = format; - this.charset = charset; - this.raw = raw; - } - return CFFCharset; -})(); - -var CFFEncoding = (function CFFEncodingClosure() { - function CFFEncoding(predefined, format, encoding, raw) { - this.predefined = predefined; - this.format = format; - this.encoding = encoding; - this.raw = raw; - } - return CFFEncoding; -})(); - -var CFFFDSelect = (function CFFFDSelectClosure() { - function CFFFDSelect(fdSelect, raw) { - this.fdSelect = fdSelect; - this.raw = raw; - } - CFFFDSelect.prototype = { - getFDIndex: function CFFFDSelect_get(glyphIndex) { - if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) { - return -1; - } - return this.fdSelect[glyphIndex]; - } - }; - return CFFFDSelect; -})(); - -// Helper class to keep track of where an offset is within the data and helps -// filling in that offset once it's known. -var CFFOffsetTracker = (function CFFOffsetTrackerClosure() { - function CFFOffsetTracker() { - this.offsets = Object.create(null); - } - CFFOffsetTracker.prototype = { - isTracking: function CFFOffsetTracker_isTracking(key) { - return key in this.offsets; - }, - track: function CFFOffsetTracker_track(key, location) { - if (key in this.offsets) { - error('Already tracking location of ' + key); - } - this.offsets[key] = location; - }, - offset: function CFFOffsetTracker_offset(value) { - for (var key in this.offsets) { - this.offsets[key] += value; - } - }, - setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, - values, - output) { - if (!(key in this.offsets)) { - error('Not tracking location of ' + key); - } - var data = output.data; - var dataOffset = this.offsets[key]; - var size = 5; - for (var i = 0, ii = values.length; i < ii; ++i) { - var offset0 = i * size + dataOffset; - var offset1 = offset0 + 1; - var offset2 = offset0 + 2; - var offset3 = offset0 + 3; - var offset4 = offset0 + 4; - // It's easy to screw up offsets so perform this sanity check. - if (data[offset0] !== 0x1d || data[offset1] !== 0 || - data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) { - error('writing to an offset that is not empty'); - } - var value = values[i]; - data[offset0] = 0x1d; - data[offset1] = (value >> 24) & 0xFF; - data[offset2] = (value >> 16) & 0xFF; - data[offset3] = (value >> 8) & 0xFF; - data[offset4] = value & 0xFF; - } - } - }; - return CFFOffsetTracker; -})(); - -// Takes a CFF and converts it to the binary representation. -var CFFCompiler = (function CFFCompilerClosure() { - function CFFCompiler(cff) { - this.cff = cff; - } - CFFCompiler.prototype = { - compile: function CFFCompiler_compile() { - var cff = this.cff; - var output = { - data: [], - length: 0, - add: function CFFCompiler_add(data) { - this.data = this.data.concat(data); - this.length = this.data.length; - } - }; - - // Compile the five entries that must be in order. - var header = this.compileHeader(cff.header); - output.add(header); - - var nameIndex = this.compileNameIndex(cff.names); - output.add(nameIndex); - - if (cff.isCIDFont) { - // The spec is unclear on how font matrices should relate to each other - // when there is one in the main top dict and the sub top dicts. - // Windows handles this differently than linux and osx so we have to - // normalize to work on all. - // Rules based off of some mailing list discussions: - // - If main font has a matrix and subfont doesn't, use the main matrix. - // - If no main font matrix and there is a subfont matrix, use the - // subfont matrix. - // - If both have matrices, concat together. - // - If neither have matrices, use default. - // To make this work on all platforms we move the top matrix into each - // sub top dict and concat if necessary. - if (cff.topDict.hasName('FontMatrix')) { - var base = cff.topDict.getByName('FontMatrix'); - cff.topDict.removeByName('FontMatrix'); - for (var i = 0, ii = cff.fdArray.length; i < ii; i++) { - var subDict = cff.fdArray[i]; - var matrix = base.slice(0); - if (subDict.hasName('FontMatrix')) { - matrix = Util.transform(matrix, subDict.getByName('FontMatrix')); - } - subDict.setByName('FontMatrix', matrix); - } - } - } - - var compiled = this.compileTopDicts([cff.topDict], - output.length, - cff.isCIDFont); - output.add(compiled.output); - var topDictTracker = compiled.trackers[0]; - - var stringIndex = this.compileStringIndex(cff.strings.strings); - output.add(stringIndex); - - var globalSubrIndex = this.compileIndex(cff.globalSubrIndex); - output.add(globalSubrIndex); - - // Now start on the other entries that have no specfic order. - if (cff.encoding && cff.topDict.hasName('Encoding')) { - if (cff.encoding.predefined) { - topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], - output); - } else { - var encoding = this.compileEncoding(cff.encoding); - topDictTracker.setEntryLocation('Encoding', [output.length], output); - output.add(encoding); - } - } - - if (cff.charset && cff.topDict.hasName('charset')) { - if (cff.charset.predefined) { - topDictTracker.setEntryLocation('charset', [cff.charset.format], - output); - } else { - var charset = this.compileCharset(cff.charset); - topDictTracker.setEntryLocation('charset', [output.length], output); - output.add(charset); - } - } - - var charStrings = this.compileCharStrings(cff.charStrings); - topDictTracker.setEntryLocation('CharStrings', [output.length], output); - output.add(charStrings); - - if (cff.isCIDFont) { - // For some reason FDSelect must be in front of FDArray on windows. OSX - // and linux don't seem to care. - topDictTracker.setEntryLocation('FDSelect', [output.length], output); - var fdSelect = this.compileFDSelect(cff.fdSelect.raw); - output.add(fdSelect); - // It is unclear if the sub font dictionary can have CID related - // dictionary keys, but the sanitizer doesn't like them so remove them. - compiled = this.compileTopDicts(cff.fdArray, output.length, true); - topDictTracker.setEntryLocation('FDArray', [output.length], output); - output.add(compiled.output); - var fontDictTrackers = compiled.trackers; - - this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output); - } - - this.compilePrivateDicts([cff.topDict], [topDictTracker], output); - - // If the font data ends with INDEX whose object data is zero-length, - // the sanitizer will bail out. Add a dummy byte to avoid that. - output.add([0]); - - return output.data; - }, - encodeNumber: function CFFCompiler_encodeNumber(value) { - if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) { // isInt - return this.encodeInteger(value); - } else { - return this.encodeFloat(value); - } - }, - encodeFloat: function CFFCompiler_encodeFloat(num) { - var value = num.toString(); - - // rounding inaccurate doubles - var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value); - if (m) { - var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length)); - value = (Math.round(num * epsilon) / epsilon).toString(); - } - - var nibbles = ''; - var i, ii; - for (i = 0, ii = value.length; i < ii; ++i) { - var a = value[i]; - if (a === 'e') { - nibbles += value[++i] === '-' ? 'c' : 'b'; - } else if (a === '.') { - nibbles += 'a'; - } else if (a === '-') { - nibbles += 'e'; - } else { - nibbles += a; - } - } - nibbles += (nibbles.length & 1) ? 'f' : 'ff'; - var out = [30]; - for (i = 0, ii = nibbles.length; i < ii; i += 2) { - out.push(parseInt(nibbles.substr(i, 2), 16)); - } - return out; - }, - encodeInteger: function CFFCompiler_encodeInteger(value) { - var code; - if (value >= -107 && value <= 107) { - code = [value + 139]; - } else if (value >= 108 && value <= 1131) { - value = [value - 108]; - code = [(value >> 8) + 247, value & 0xFF]; - } else if (value >= -1131 && value <= -108) { - value = -value - 108; - code = [(value >> 8) + 251, value & 0xFF]; - } else if (value >= -32768 && value <= 32767) { - code = [0x1c, (value >> 8) & 0xFF, value & 0xFF]; - } else { - code = [0x1d, - (value >> 24) & 0xFF, - (value >> 16) & 0xFF, - (value >> 8) & 0xFF, - value & 0xFF]; - } - return code; - }, - compileHeader: function CFFCompiler_compileHeader(header) { - return [ - header.major, - header.minor, - header.hdrSize, - header.offSize - ]; - }, - compileNameIndex: function CFFCompiler_compileNameIndex(names) { - var nameIndex = new CFFIndex(); - for (var i = 0, ii = names.length; i < ii; ++i) { - nameIndex.add(stringToBytes(names[i])); - } - return this.compileIndex(nameIndex); - }, - compileTopDicts: function CFFCompiler_compileTopDicts(dicts, - length, - removeCidKeys) { - var fontDictTrackers = []; - var fdArrayIndex = new CFFIndex(); - for (var i = 0, ii = dicts.length; i < ii; ++i) { - var fontDict = dicts[i]; - if (removeCidKeys) { - fontDict.removeByName('CIDFontVersion'); - fontDict.removeByName('CIDFontRevision'); - fontDict.removeByName('CIDFontType'); - fontDict.removeByName('CIDCount'); - fontDict.removeByName('UIDBase'); - } - var fontDictTracker = new CFFOffsetTracker(); - var fontDictData = this.compileDict(fontDict, fontDictTracker); - fontDictTrackers.push(fontDictTracker); - fdArrayIndex.add(fontDictData); - fontDictTracker.offset(length); - } - fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers); - return { - trackers: fontDictTrackers, - output: fdArrayIndex - }; - }, - compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, - trackers, - output) { - for (var i = 0, ii = dicts.length; i < ii; ++i) { - var fontDict = dicts[i]; - assert(fontDict.privateDict && fontDict.hasName('Private'), - 'There must be an private dictionary.'); - var privateDict = fontDict.privateDict; - var privateDictTracker = new CFFOffsetTracker(); - var privateDictData = this.compileDict(privateDict, privateDictTracker); - - var outputLength = output.length; - privateDictTracker.offset(outputLength); - if (!privateDictData.length) { - // The private dictionary was empty, set the output length to zero to - // ensure the offset length isn't out of bounds in the eyes of the - // sanitizer. - outputLength = 0; - } - - trackers[i].setEntryLocation('Private', - [privateDictData.length, outputLength], - output); - output.add(privateDictData); - - if (privateDict.subrsIndex && privateDict.hasName('Subrs')) { - var subrs = this.compileIndex(privateDict.subrsIndex); - privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], - output); - output.add(subrs); - } - } - }, - compileDict: function CFFCompiler_compileDict(dict, offsetTracker) { - var out = []; - // The dictionary keys must be in a certain order. - var order = dict.order; - for (var i = 0; i < order.length; ++i) { - var key = order[i]; - if (!(key in dict.values)) { - continue; - } - var values = dict.values[key]; - var types = dict.types[key]; - if (!isArray(types)) { - types = [types]; - } - if (!isArray(values)) { - values = [values]; - } - - // Remove any empty dict values. - if (values.length === 0) { - continue; - } - - for (var j = 0, jj = types.length; j < jj; ++j) { - var type = types[j]; - var value = values[j]; - switch (type) { - case 'num': - case 'sid': - out = out.concat(this.encodeNumber(value)); - break; - case 'offset': - // For offsets we just insert a 32bit integer so we don't have to - // deal with figuring out the length of the offset when it gets - // replaced later on by the compiler. - var name = dict.keyToNameMap[key]; - // Some offsets have the offset and the length, so just record the - // position of the first one. - if (!offsetTracker.isTracking(name)) { - offsetTracker.track(name, out.length); - } - out = out.concat([0x1d, 0, 0, 0, 0]); - break; - case 'array': - case 'delta': - out = out.concat(this.encodeNumber(value)); - for (var k = 1, kk = values.length; k < kk; ++k) { - out = out.concat(this.encodeNumber(values[k])); - } - break; - default: - error('Unknown data type of ' + type); - break; - } - } - out = out.concat(dict.opcodes[key]); - } - return out; - }, - compileStringIndex: function CFFCompiler_compileStringIndex(strings) { - var stringIndex = new CFFIndex(); - for (var i = 0, ii = strings.length; i < ii; ++i) { - stringIndex.add(stringToBytes(strings[i])); - } - return this.compileIndex(stringIndex); - }, - compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() { - var globalSubrIndex = this.cff.globalSubrIndex; - this.out.writeByteArray(this.compileIndex(globalSubrIndex)); - }, - compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) { - return this.compileIndex(charStrings); - }, - compileCharset: function CFFCompiler_compileCharset(charset) { - return this.compileTypedArray(charset.raw); - }, - compileEncoding: function CFFCompiler_compileEncoding(encoding) { - return this.compileTypedArray(encoding.raw); - }, - compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) { - return this.compileTypedArray(fdSelect); - }, - compileTypedArray: function CFFCompiler_compileTypedArray(data) { - var out = []; - for (var i = 0, ii = data.length; i < ii; ++i) { - out[i] = data[i]; - } - return out; - }, - compileIndex: function CFFCompiler_compileIndex(index, trackers) { - trackers = trackers || []; - var objects = index.objects; - // First 2 bytes contains the number of objects contained into this index - var count = objects.length; - - // If there is no object, just create an index. This technically - // should just be [0, 0] but OTS has an issue with that. - if (count === 0) { - return [0, 0, 0]; - } - - var data = [(count >> 8) & 0xFF, count & 0xff]; - - var lastOffset = 1, i; - for (i = 0; i < count; ++i) { - lastOffset += objects[i].length; - } - - var offsetSize; - if (lastOffset < 0x100) { - offsetSize = 1; - } else if (lastOffset < 0x10000) { - offsetSize = 2; - } else if (lastOffset < 0x1000000) { - offsetSize = 3; - } else { - offsetSize = 4; - } - - // Next byte contains the offset size use to reference object in the file - data.push(offsetSize); - - // Add another offset after this one because we need a new offset - var relativeOffset = 1; - for (i = 0; i < count + 1; i++) { - if (offsetSize === 1) { - data.push(relativeOffset & 0xFF); - } else if (offsetSize === 2) { - data.push((relativeOffset >> 8) & 0xFF, - relativeOffset & 0xFF); - } else if (offsetSize === 3) { - data.push((relativeOffset >> 16) & 0xFF, - (relativeOffset >> 8) & 0xFF, - relativeOffset & 0xFF); - } else { - data.push((relativeOffset >>> 24) & 0xFF, - (relativeOffset >> 16) & 0xFF, - (relativeOffset >> 8) & 0xFF, - relativeOffset & 0xFF); - } - - if (objects[i]) { - relativeOffset += objects[i].length; - } - } - - for (i = 0; i < count; i++) { - // Notify the tracker where the object will be offset in the data. - if (trackers[i]) { - trackers[i].offset(data.length); - } - for (var j = 0, jj = objects[i].length; j < jj; j++) { - data.push(objects[i][j]); - } - } - return data; - } - }; - return CFFCompiler; -})(); - -function _enableSeacAnalysis(enabled) { - exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED = enabled; -} - // Workaround for seac on Windows. (function checkSeacSupport() { if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) { @@ -30061,240 +30352,12 @@ function _enableSeacAnalysis(enabled) { })(); exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED; -exports.CFFCompiler = CFFCompiler; -exports.CFFIndex = CFFIndex; -exports.CFFParser = CFFParser; -exports.CFFStrings = CFFStrings; exports.ErrorFont = ErrorFont; -exports.FontFlags = FontFlags; exports.Font = Font; +exports.FontFlags = FontFlags; exports.IdentityToUnicodeMap = IdentityToUnicodeMap; exports.ToUnicodeMap = ToUnicodeMap; -exports.Type1Parser = Type1Parser; exports.getFontType = getFontType; -exports._enableSeacAnalysis = _enableSeacAnalysis; - -// TODO refactor to remove cyclic dependency on font_renderer.js -coreFontRenderer._setCoreFonts(exports); -})); - - -(function (root, factory) { - { - factory((root.pdfjsCorePsParser = {}), root.pdfjsSharedUtil, - root.pdfjsCoreParser); - } -}(this, function (exports, sharedUtil, coreParser) { - -var error = sharedUtil.error; -var EOF = coreParser.EOF; -var Lexer = coreParser.Lexer; - -var PostScriptParser = (function PostScriptParserClosure() { - function PostScriptParser(lexer) { - this.lexer = lexer; - this.operators = []; - this.token = null; - this.prev = null; - } - PostScriptParser.prototype = { - nextToken: function PostScriptParser_nextToken() { - this.prev = this.token; - this.token = this.lexer.getToken(); - }, - accept: function PostScriptParser_accept(type) { - if (this.token.type === type) { - this.nextToken(); - return true; - } - return false; - }, - expect: function PostScriptParser_expect(type) { - if (this.accept(type)) { - return true; - } - error('Unexpected symbol: found ' + this.token.type + ' expected ' + - type + '.'); - }, - parse: function PostScriptParser_parse() { - this.nextToken(); - this.expect(PostScriptTokenTypes.LBRACE); - this.parseBlock(); - this.expect(PostScriptTokenTypes.RBRACE); - return this.operators; - }, - parseBlock: function PostScriptParser_parseBlock() { - while (true) { - if (this.accept(PostScriptTokenTypes.NUMBER)) { - this.operators.push(this.prev.value); - } else if (this.accept(PostScriptTokenTypes.OPERATOR)) { - this.operators.push(this.prev.value); - } else if (this.accept(PostScriptTokenTypes.LBRACE)) { - this.parseCondition(); - } else { - return; - } - } - }, - parseCondition: function PostScriptParser_parseCondition() { - // Add two place holders that will be updated later - var conditionLocation = this.operators.length; - this.operators.push(null, null); - - this.parseBlock(); - this.expect(PostScriptTokenTypes.RBRACE); - if (this.accept(PostScriptTokenTypes.IF)) { - // The true block is right after the 'if' so it just falls through on - // true else it jumps and skips the true block. - this.operators[conditionLocation] = this.operators.length; - this.operators[conditionLocation + 1] = 'jz'; - } else if (this.accept(PostScriptTokenTypes.LBRACE)) { - var jumpLocation = this.operators.length; - this.operators.push(null, null); - var endOfTrue = this.operators.length; - this.parseBlock(); - this.expect(PostScriptTokenTypes.RBRACE); - this.expect(PostScriptTokenTypes.IFELSE); - // The jump is added at the end of the true block to skip the false - // block. - this.operators[jumpLocation] = this.operators.length; - this.operators[jumpLocation + 1] = 'j'; - - this.operators[conditionLocation] = endOfTrue; - this.operators[conditionLocation + 1] = 'jz'; - } else { - error('PS Function: error parsing conditional.'); - } - } - }; - return PostScriptParser; -})(); - -var PostScriptTokenTypes = { - LBRACE: 0, - RBRACE: 1, - NUMBER: 2, - OPERATOR: 3, - IF: 4, - IFELSE: 5 -}; - -var PostScriptToken = (function PostScriptTokenClosure() { - function PostScriptToken(type, value) { - this.type = type; - this.value = value; - } - - var opCache = Object.create(null); - - PostScriptToken.getOperator = function PostScriptToken_getOperator(op) { - var opValue = opCache[op]; - if (opValue) { - return opValue; - } - return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op); - }; - - PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, - '{'); - PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, - '}'); - PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF'); - PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, - 'IFELSE'); - return PostScriptToken; -})(); - -var PostScriptLexer = (function PostScriptLexerClosure() { - function PostScriptLexer(stream) { - this.stream = stream; - this.nextChar(); - - this.strBuf = []; - } - PostScriptLexer.prototype = { - nextChar: function PostScriptLexer_nextChar() { - return (this.currentChar = this.stream.getByte()); - }, - getToken: function PostScriptLexer_getToken() { - var comment = false; - var ch = this.currentChar; - - // skip comments - while (true) { - if (ch < 0) { - return EOF; - } - - if (comment) { - if (ch === 0x0A || ch === 0x0D) { - comment = false; - } - } else if (ch === 0x25) { // '%' - comment = true; - } else if (!Lexer.isSpace(ch)) { - break; - } - ch = this.nextChar(); - } - switch (ch | 0) { - case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: // '0'-'4' - case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: // '5'-'9' - case 0x2B: case 0x2D: case 0x2E: // '+', '-', '.' - return new PostScriptToken(PostScriptTokenTypes.NUMBER, - this.getNumber()); - case 0x7B: // '{' - this.nextChar(); - return PostScriptToken.LBRACE; - case 0x7D: // '}' - this.nextChar(); - return PostScriptToken.RBRACE; - } - // operator - var strBuf = this.strBuf; - strBuf.length = 0; - strBuf[0] = String.fromCharCode(ch); - - while ((ch = this.nextChar()) >= 0 && // and 'A'-'Z', 'a'-'z' - ((ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A))) { - strBuf.push(String.fromCharCode(ch)); - } - var str = strBuf.join(''); - switch (str.toLowerCase()) { - case 'if': - return PostScriptToken.IF; - case 'ifelse': - return PostScriptToken.IFELSE; - default: - return PostScriptToken.getOperator(str); - } - }, - getNumber: function PostScriptLexer_getNumber() { - var ch = this.currentChar; - var strBuf = this.strBuf; - strBuf.length = 0; - strBuf[0] = String.fromCharCode(ch); - - while ((ch = this.nextChar()) >= 0) { - if ((ch >= 0x30 && ch <= 0x39) || // '0'-'9' - ch === 0x2D || ch === 0x2E) { // '-', '.' - strBuf.push(String.fromCharCode(ch)); - } else { - break; - } - } - var value = parseFloat(strBuf.join('')); - if (isNaN(value)) { - error('Invalid floating point number: ' + value); - } - return value; - } - }; - return PostScriptLexer; -})(); - -exports.PostScriptLexer = PostScriptLexer; -exports.PostScriptParser = PostScriptParser; })); diff --git a/browser/extensions/pdfjs/content/web/debugger.js b/browser/extensions/pdfjs/content/web/debugger.js index 19d29163dd19..bd3e5620d08e 100644 --- a/browser/extensions/pdfjs/content/web/debugger.js +++ b/browser/extensions/pdfjs/content/web/debugger.js @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* globals PDFJS */ +/* globals pdfjsLib */ 'use strict'; @@ -307,8 +307,8 @@ var Stepper = (function StepperClosure() { this.table = table; if (!opMap) { opMap = Object.create(null); - for (var key in PDFJS.OPS) { - opMap[PDFJS.OPS[key]] = key; + for (var key in pdfjsLib.OPS) { + opMap[pdfjsLib.OPS[key]] = key; } } }, @@ -460,7 +460,7 @@ var Stats = (function Stats() { manager: null, init: function init() { this.panel.setAttribute('style', 'padding: 5px;'); - PDFJS.enableStats = true; + pdfjsLib.PDFJS.enableStats = true; }, enabled: false, active: false, diff --git a/browser/extensions/pdfjs/content/web/viewer.js b/browser/extensions/pdfjs/content/web/viewer.js index 191390f0a82e..e9e33d485588 100644 --- a/browser/extensions/pdfjs/content/web/viewer.js +++ b/browser/extensions/pdfjs/content/web/viewer.js @@ -1,4 +1,4 @@ -/* Copyright 2012 Mozilla Foundation +/* Copyright 2016 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,20 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* globals PDFJS, PDFBug, FirefoxCom, Stats, ProgressBar, DownloadManager, - getPDFFileNameFromURL, PDFHistory, Preferences, SidebarView, - ViewHistory, Stats, PDFThumbnailViewer, URL, noContextMenuHandler, - SecondaryToolbar, PasswordPrompt, PDFPresentationMode, PDFSidebar, - PDFDocumentProperties, HandTool, Promise, PDFLinkService, - PDFOutlineViewer, PDFAttachmentViewer, OverlayManager, - PDFFindController, PDFFindBar, PDFViewer, PDFRenderingQueue, - PresentationModeState, parseQueryString, RenderingStates, - UNKNOWN_SCALE, DEFAULT_SCALE_VALUE, - IGNORE_CURRENT_POSITION_ON_ZOOM: true */ +/*globals require, parseQueryString, chrome, PDFViewerApplication */ 'use strict'; var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf'; + + var DEFAULT_SCALE_DELTA = 1.1; var MIN_SCALE = 0.25; var MAX_SCALE = 10.0; @@ -41,8 +34,6 @@ function configure(PDFJS) { PDFJS.cMapPacked = true; } -var mozL10n = document.mozL10n || document.webL10n; - var CSS_UNITS = 96.0 / 72.0; var DEFAULT_SCALE_VALUE = 'auto'; @@ -52,6 +43,56 @@ var MAX_AUTO_SCALE = 1.25; var SCROLLBAR_PADDING = 40; var VERTICAL_PADDING = 5; +var mozL10n = document.mozL10n || document.webL10n; + +if (typeof PDFJS === 'undefined') { + (typeof window !== 'undefined' ? window : this).PDFJS = {}; +} + +/** + * Disables fullscreen support, and by extension Presentation Mode, + * in browsers which support the fullscreen API. + * @var {boolean} + */ +PDFJS.disableFullscreen = (PDFJS.disableFullscreen === undefined ? + false : PDFJS.disableFullscreen); + +/** + * Enables CSS only zooming. + * @var {boolean} + */ +PDFJS.useOnlyCssZoom = (PDFJS.useOnlyCssZoom === undefined ? + false : PDFJS.useOnlyCssZoom); + +/** + * The maximum supported canvas size in total pixels e.g. width * height. + * The default value is 4096 * 4096. Use -1 for no limit. + * @var {number} + */ +PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ? + 16777216 : PDFJS.maxCanvasPixels); + +/** + * Disables saving of the last position of the viewed PDF. + * @var {boolean} + */ +PDFJS.disableHistory = (PDFJS.disableHistory === undefined ? + false : PDFJS.disableHistory); + +/** + * Disables creation of the text layer that used for text selection and search. + * @var {boolean} + */ +PDFJS.disableTextLayer = (PDFJS.disableTextLayer === undefined ? + false : PDFJS.disableTextLayer); + +/** + * Disables maintaining the current position in the document when zooming. + */ +PDFJS.ignoreCurrentPositionOnZoom = (PDFJS.ignoreCurrentPositionOnZoom === + undefined ? false : PDFJS.ignoreCurrentPositionOnZoom); + + /** * Returns scale factor for the canvas. It makes sense for the HiDPI displays. * @return {Object} The object with horizontal (sx) and vertical (sy) @@ -585,9 +626,6 @@ var Preferences = { - - - var FirefoxCom = (function FirefoxComClosure() { return { /** @@ -659,7 +697,7 @@ var DownloadManager = (function DownloadManagerClosure() { downloadData: function DownloadManager_downloadData(data, filename, contentType) { - var blobUrl = PDFJS.createObjectURL(data, contentType); + var blobUrl = pdfjsLib.createObjectURL(data, contentType, false); FirefoxCom.request('download', { blobUrl: blobUrl, @@ -3000,7 +3038,7 @@ var PasswordPrompt = { var promptString = mozL10n.get('password_label', null, 'Enter the password to open this PDF file.'); - if (this.reason === PDFJS.PasswordResponses.INCORRECT_PASSWORD) { + if (this.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) { promptString = mozL10n.get('password_invalid', null, 'Invalid password. Please try again.'); } @@ -3241,7 +3279,6 @@ var PresentationModeState = { FULLSCREEN: 3, }; -var IGNORE_CURRENT_POSITION_ON_ZOOM = false; var DEFAULT_CACHE_SIZE = 10; @@ -3552,19 +3589,18 @@ var PDFPageView = (function PDFPageViewClosure() { }); var isScalingRestricted = false; - if (this.canvas && PDFJS.maxCanvasPixels > 0) { + if (this.canvas && pdfjsLib.PDFJS.maxCanvasPixels > 0) { var outputScale = this.outputScale; var pixelsInViewport = this.viewport.width * this.viewport.height; - var maxScale = Math.sqrt(PDFJS.maxCanvasPixels / pixelsInViewport); if (((Math.floor(this.viewport.width) * outputScale.sx) | 0) * ((Math.floor(this.viewport.height) * outputScale.sy) | 0) > - PDFJS.maxCanvasPixels) { + pdfjsLib.PDFJS.maxCanvasPixels) { isScalingRestricted = true; } } if (this.canvas) { - if (PDFJS.useOnlyCssZoom || + if (pdfjsLib.PDFJS.useOnlyCssZoom || (this.hasRestrictedScaling && isScalingRestricted)) { this.cssTransform(this.canvas, true); @@ -3598,7 +3634,7 @@ var PDFPageView = (function PDFPageViewClosure() { }, cssTransform: function PDFPageView_transform(canvas, redrawAnnotations) { - var CustomStyle = PDFJS.CustomStyle; + var CustomStyle = pdfjsLib.CustomStyle; // Scale canvas, canvas wrapper, and page container. var width = this.viewport.width; @@ -3718,7 +3754,7 @@ var PDFPageView = (function PDFPageViewClosure() { var outputScale = getOutputScale(ctx); this.outputScale = outputScale; - if (PDFJS.useOnlyCssZoom) { + if (pdfjsLib.PDFJS.useOnlyCssZoom) { var actualSizeViewport = viewport.clone({scale: CSS_UNITS}); // Use a scale that will make the canvas be the original intended size // of the page. @@ -3727,9 +3763,10 @@ var PDFPageView = (function PDFPageViewClosure() { outputScale.scaled = true; } - if (PDFJS.maxCanvasPixels > 0) { + if (pdfjsLib.PDFJS.maxCanvasPixels > 0) { var pixelsInViewport = viewport.width * viewport.height; - var maxScale = Math.sqrt(PDFJS.maxCanvasPixels / pixelsInViewport); + var maxScale = + Math.sqrt(pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport); if (outputScale.sx > maxScale || outputScale.sy > maxScale) { outputScale.sx = maxScale; outputScale.sy = maxScale; @@ -3896,7 +3933,7 @@ var PDFPageView = (function PDFPageViewClosure() { }, beforePrint: function PDFPageView_beforePrint() { - var CustomStyle = PDFJS.CustomStyle; + var CustomStyle = pdfjsLib.CustomStyle; var pdfPage = this.pdfPage; var viewport = pdfPage.getViewport(1); @@ -4020,7 +4057,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { this.textDivs = []; var textLayerFrag = document.createDocumentFragment(); - this.textLayerRenderTask = PDFJS.renderTextLayer({ + this.textLayerRenderTask = pdfjsLib.renderTextLayer({ textContent: this.textContent, container: textLayerFrag, viewport: this.viewport, @@ -4323,7 +4360,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() { if (self.div) { // If an annotationLayer already exists, refresh its children's // transformation matrices. - PDFJS.AnnotationLayer.update(parameters); + pdfjsLib.AnnotationLayer.update(parameters); } else { // Create an annotation layer div and render the annotations // if there is at least one annotation. @@ -4336,7 +4373,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() { self.pageDiv.appendChild(self.div); parameters.div = self.div; - PDFJS.AnnotationLayer.render(parameters); + pdfjsLib.AnnotationLayer.render(parameters); if (typeof mozL10n !== 'undefined') { mozL10n.translate(self.div); } @@ -4628,7 +4665,7 @@ var PDFViewer = (function pdfViewer() { var viewport = pdfPage.getViewport(scale * CSS_UNITS); for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) { var textLayerFactory = null; - if (!PDFJS.disableTextLayer) { + if (!pdfjsLib.PDFJS.disableTextLayer) { textLayerFactory = this; } var pageView = new PDFPageView({ @@ -4650,7 +4687,7 @@ var PDFViewer = (function pdfViewer() { // starts to create the correct size canvas. Wait until one page is // rendered so we don't tie up too many resources early on. onePageRendered.then(function () { - if (!PDFJS.disableAutoFetch) { + if (!pdfjsLib.PDFJS.disableAutoFetch) { var getPagesLeft = pagesCount; for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) { pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) { @@ -4740,7 +4777,7 @@ var PDFViewer = (function pdfViewer() { if (!noScroll) { var page = this._currentPageNumber, dest; - if (this._location && !IGNORE_CURRENT_POSITION_ON_ZOOM && + if (this._location && !pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom && !(this.isInPresentationMode || this.isChangingPresentationMode)) { page = this._location.pageNumber; dest = [null, { name: 'XYZ' }, this._location.left, @@ -6074,7 +6111,7 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() { */ _bindLink: function PDFOutlineViewer_bindLink(element, item) { if (item.url) { - PDFJS.addLinkAttributes(element, { url: item.url }); + pdfjsLib.addLinkAttributes(element, { url: item.url }); return; } var linkService = this.linkService; @@ -6183,7 +6220,7 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() { this._bindLink(element, item); this._setStyles(element, item); element.textContent = - PDFJS.removeNullCharacters(item.title) || DEFAULT_TITLE; + pdfjsLib.removeNullCharacters(item.title) || DEFAULT_TITLE; div.appendChild(element); @@ -6297,12 +6334,12 @@ var PDFAttachmentViewer = (function PDFAttachmentViewerClosure() { for (var i = 0; i < attachmentsCount; i++) { var item = attachments[names[i]]; - var filename = PDFJS.getFilenameFromUrl(item.filename); + var filename = pdfjsLib.getFilenameFromUrl(item.filename); var div = document.createElement('div'); div.className = 'attachmentsItem'; var button = document.createElement('button'); this._bindLink(button, item.content, filename); - button.textContent = PDFJS.removeNullCharacters(filename); + button.textContent = pdfjsLib.removeNullCharacters(filename); div.appendChild(button); this.container.appendChild(div); } @@ -6355,6 +6392,8 @@ var PDFViewerApplication = { // called once when the document is loaded initialize: function pdfViewInitialize() { + configure(pdfjsLib.PDFJS); + var pdfRenderingQueue = new PDFRenderingQueue(); pdfRenderingQueue.onIdle = this.cleanup.bind(this); this.pdfRenderingQueue = pdfRenderingQueue; @@ -6508,6 +6547,7 @@ var PDFViewerApplication = { this.pdfSidebar.onToggled = this.forceRendering.bind(this); var self = this; + var PDFJS = pdfjsLib.PDFJS; var initializedPromise = Promise.all([ Preferences.get('enableWebGL').then(function resolved(value) { PDFJS.disableWebGL = !value; @@ -6574,6 +6614,10 @@ var PDFViewerApplication = { }); }, + run: function pdfViewRun() { + this.initialize().then(webViewerInitialized); + }, + zoomIn: function pdfViewZoomIn(ticks) { var newScale = this.pdfViewer.currentScale; do { @@ -6610,7 +6654,7 @@ var PDFViewerApplication = { var canvas = document.createElement('canvas'); var value = 'mozPrintCallback' in canvas; - return PDFJS.shadow(this, 'supportsPrinting', value); + return pdfjsLib.shadow(this, 'supportsPrinting', value); }, get supportsFullscreen() { @@ -6624,38 +6668,38 @@ var PDFViewerApplication = { document.msFullscreenEnabled === false) { support = false; } - if (support && PDFJS.disableFullscreen === true) { + if (support && pdfjsLib.PDFJS.disableFullscreen === true) { support = false; } - return PDFJS.shadow(this, 'supportsFullscreen', support); + return pdfjsLib.shadow(this, 'supportsFullscreen', support); }, get supportsIntegratedFind() { var support = false; support = FirefoxCom.requestSync('supportsIntegratedFind'); - return PDFJS.shadow(this, 'supportsIntegratedFind', support); + return pdfjsLib.shadow(this, 'supportsIntegratedFind', support); }, get supportsDocumentFonts() { var support = true; support = FirefoxCom.requestSync('supportsDocumentFonts'); - return PDFJS.shadow(this, 'supportsDocumentFonts', support); + return pdfjsLib.shadow(this, 'supportsDocumentFonts', support); }, get supportsDocumentColors() { var support = true; support = FirefoxCom.requestSync('supportsDocumentColors'); - return PDFJS.shadow(this, 'supportsDocumentColors', support); + return pdfjsLib.shadow(this, 'supportsDocumentColors', support); }, get loadingBar() { var bar = new ProgressBar('#loadingBar', {}); - return PDFJS.shadow(this, 'loadingBar', bar); + return pdfjsLib.shadow(this, 'loadingBar', bar); }, get supportedMouseWheelZoomModifierKeys() { @@ -6665,15 +6709,16 @@ var PDFViewerApplication = { }; support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys'); - return PDFJS.shadow(this, 'supportedMouseWheelZoomModifierKeys', support); + return pdfjsLib.shadow(this, 'supportedMouseWheelZoomModifierKeys', + support); }, initPassiveLoading: function pdfViewInitPassiveLoading() { function FirefoxComDataRangeTransport(length, initialData) { - PDFJS.PDFDataRangeTransport.call(this, length, initialData); + pdfjsLib.PDFDataRangeTransport.call(this, length, initialData); } FirefoxComDataRangeTransport.prototype = - Object.create(PDFJS.PDFDataRangeTransport.prototype); + Object.create(pdfjsLib.PDFDataRangeTransport.prototype); FirefoxComDataRangeTransport.prototype.requestDataRange = function FirefoxComDataRangeTransport_requestDataRange(begin, end) { FirefoxCom.request('requestDataRange', { begin: begin, end: end }); @@ -6738,7 +6783,8 @@ var PDFViewerApplication = { setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) { this.url = url; try { - this.setTitle(decodeURIComponent(PDFJS.getFilenameFromUrl(url)) || url); + this.setTitle(decodeURIComponent( + pdfjsLib.getFilenameFromUrl(url)) || url); } catch (e) { // decodeURIComponent may throw URIError, // fall back to using the unprocessed url in that case @@ -6849,7 +6895,7 @@ var PDFViewerApplication = { var self = this; self.downloadComplete = false; - var loadingTask = PDFJS.getDocument(parameters); + var loadingTask = pdfjsLib.getDocument(parameters); this.pdfLoadingTask = loadingTask; loadingTask.onPassword = function passwordNeeded(updatePassword, reason) { @@ -6874,15 +6920,15 @@ var PDFViewerApplication = { var loadingErrorMessage = mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.'); - if (exception instanceof PDFJS.InvalidPDFException) { + if (exception instanceof pdfjsLib.InvalidPDFException) { // change error message also for other builds loadingErrorMessage = mozL10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.'); - } else if (exception instanceof PDFJS.MissingPDFException) { + } else if (exception instanceof pdfjsLib.MissingPDFException) { // special message for missing PDF's loadingErrorMessage = mozL10n.get('missing_file_error', null, 'Missing PDF file.'); - } else if (exception instanceof PDFJS.UnexpectedResponseException) { + } else if (exception instanceof pdfjsLib.UnexpectedResponseException) { loadingErrorMessage = mozL10n.get('unexpected_response_error', null, 'Unexpected server response.'); } @@ -6928,7 +6974,7 @@ var PDFViewerApplication = { this.pdfDocument.getData().then( function getDataSuccess(data) { - var blob = PDFJS.createBlob(data, 'application/pdf'); + var blob = pdfjsLib.createBlob(data, 'application/pdf'); downloadManager.download(blob, url, filename); }, downloadByUrl // Error occurred try downloading with just the url. @@ -6961,7 +7007,7 @@ var PDFViewerApplication = { */ error: function pdfViewError(message, moreInfo) { var moreInfoText = mozL10n.get('error_version_info', - {version: PDFJS.version || '?', build: PDFJS.build || '?'}, + {version: pdfjsLib.version || '?', build: pdfjsLib.build || '?'}, 'PDF.js v{{version}} (build: {{build}})') + '\n'; if (moreInfo) { moreInfoText += @@ -7003,7 +7049,7 @@ var PDFViewerApplication = { // the loading bar will not be completely filled, nor will it be hidden. // To prevent displaying a partially filled loading bar permanently, we // hide it when no data has been loaded during a certain amount of time. - if (PDFJS.disableAutoFetch && percent) { + if (pdfjsLib.PDFJS.disableAutoFetch && percent) { if (this.disableAutoFetchLoadingBarTimeout) { clearTimeout(this.disableAutoFetchLoadingBarTimeout); this.disableAutoFetchLoadingBarTimeout = null; @@ -7063,7 +7109,7 @@ var PDFViewerApplication = { self.loadingBar.setWidth(document.getElementById('viewer')); - if (!PDFJS.disableHistory && !self.isViewerEmbedded) { + if (!pdfjsLib.PDFJS.disableHistory && !self.isViewerEmbedded) { // The browsing history is only enabled when the viewer is standalone, // i.e. not when it is embedded in a web page. if (!self.preferenceShowPreviousViewOnLoad) { @@ -7136,7 +7182,7 @@ var PDFViewerApplication = { pdfDocument.getJavaScript().then(function(javaScript) { if (javaScript.length) { console.warn('Warning: JavaScript is not supported'); - self.fallback(PDFJS.UNSUPPORTED_FEATURES.javaScript); + self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.javaScript); } // Hack to support auto printing. var regex = /\bprint\s*\(/; @@ -7173,8 +7219,8 @@ var PDFViewerApplication = { console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + - ' (PDF.js: ' + (PDFJS.version || '-') + - (!PDFJS.disableWebGL ? ' [WebGL]' : '') + ')'); + ' (PDF.js: ' + (pdfjsLib.version || '-') + + (!pdfjsLib.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')'); var pdfTitle; if (metadata && metadata.has('dc:title')) { @@ -7195,7 +7241,7 @@ var PDFViewerApplication = { if (info.IsAcroFormPresent) { console.warn('Warning: AcroForm/XFA is not supported'); - self.fallback(PDFJS.UNSUPPORTED_FEATURES.forms); + self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.forms); } var versionId = String(info.PDFFormatVersion).slice(-1) | 0; @@ -7398,18 +7444,13 @@ var PDFViewerApplication = { }; - -function webViewerLoad(evt) { - configure(PDFJS); - PDFViewerApplication.initialize().then(webViewerInitialized); -} - function webViewerInitialized() { var file = window.location.href.split('#')[0]; document.getElementById('openFile').setAttribute('hidden', 'true'); document.getElementById('secondaryOpenFile').setAttribute('hidden', 'true'); + var PDFJS = pdfjsLib.PDFJS; if (PDFViewerApplication.preferencePdfBugEnabled) { // Special debugging flags in the hash section of the URL. @@ -7444,7 +7485,7 @@ function webViewerInitialized() { PDFJS.verbosity = hashParams['verbosity'] | 0; } if ('ignorecurrentpositiononzoom' in hashParams) { - IGNORE_CURRENT_POSITION_ON_ZOOM = + PDFJS.ignoreCurrentPositionOnZoom = (hashParams['ignorecurrentpositiononzoom'] === 'true'); } if ('textlayer' in hashParams) { @@ -7565,8 +7606,6 @@ function webViewerInitialized() { } -document.addEventListener('DOMContentLoaded', webViewerLoad, true); - document.addEventListener('pagerendered', function (e) { var pageNumber = e.detail.pageNumber; var pageIndex = pageNumber - 1; @@ -7579,7 +7618,7 @@ document.addEventListener('pagerendered', function (e) { thumbnailView.setImage(pageView); } - if (PDFJS.pdfBug && Stats.enabled && pageView.stats) { + if (pdfjsLib.PDFJS.pdfBug && Stats.enabled && pageView.stats) { Stats.add(pageNumber, pageView.stats); } @@ -7830,7 +7869,7 @@ window.addEventListener('pagechange', function pagechange(evt) { document.getElementById('lastPage').disabled = (page >= numPages); // we need to update stats - if (PDFJS.pdfBug && Stats.enabled) { + if (pdfjsLib.PDFJS.pdfBug && Stats.enabled) { var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1); if (pageView.stats) { Stats.add(page, pageView.stats); @@ -7838,6 +7877,7 @@ window.addEventListener('pagechange', function pagechange(evt) { } }, true); +var zoomDisabled = false, zoomDisabledTimeout; function handleMouseWheel(evt) { var MOUSE_WHEEL_DELTA_FACTOR = 40; var ticks = (evt.type === 'DOMMouseScroll') ? -evt.detail : @@ -7857,6 +7897,10 @@ function handleMouseWheel(evt) { } // Only zoom the pages, not the entire viewer. evt.preventDefault(); + // NOTE: this check must be placed *after* preventDefault. + if (zoomDisabled) { + return; + } var previousScale = pdfViewer.currentScale; @@ -7874,6 +7918,12 @@ function handleMouseWheel(evt) { pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor; pdfViewer.container.scrollTop += dy * scaleCorrectionFactor; } + } else { + zoomDisabled = true; + clearTimeout(zoomDisabledTimeout); + zoomDisabledTimeout = setTimeout(function () { + zoomDisabled = false; + }, 1000); } } @@ -8138,3 +8188,12 @@ window.addEventListener('afterprint', function afterPrint(evt) { }); })(); + + +function webViewerLoad() { + window.pdfjsLib = window.pdfjsDistBuildPdf; + PDFViewerApplication.run(); +} + +document.addEventListener('DOMContentLoaded', webViewerLoad, true); + diff --git a/browser/extensions/pocket/bootstrap.js b/browser/extensions/pocket/bootstrap.js index 1c867e78a93c..e65128507116 100644 --- a/browser/extensions/pocket/bootstrap.js +++ b/browser/extensions/pocket/bootstrap.js @@ -273,7 +273,7 @@ var PocketContextMenu = { "accesskey": gPocketBundle.GetStringFromName("saveLinkToPocketCmd.accesskey"), "oncommand": "Pocket.savePage(gContextMenu.browser, gContextMenu.linkURL);" }); - sibling = document.getElementById("context-savelink"); + let sibling = document.getElementById("context-savelink"); if (sibling.nextSibling) { sibling.parentNode.insertBefore(menu, sibling.nextSibling); } else { @@ -360,6 +360,7 @@ function pktUIGetter(prop, window) { get: function() { // delete any getters for properties loaded from main.js so we only load main.js once delete window.pktUI; + delete window.pktApi; delete window.pktUIMessaging; Services.scriptloader.loadSubScript("chrome://pocket/content/main.js", window); return window[prop]; @@ -402,6 +403,7 @@ var PocketOverlay = { this.removeStyles(window); // remove script getters/objects delete window.Pocket; + delete window.pktApi; delete window.pktUI; delete window.pktUIMessaging; } @@ -421,6 +423,7 @@ var PocketOverlay = { "chrome://pocket/content/Pocket.jsm"); // Can't use XPCOMUtils for these because the scripts try to define the variables // on window, and so the defineProperty inside defineLazyGetter fails. + Object.defineProperty(window, "pktApi", pktUIGetter("pktApi", window)); Object.defineProperty(window, "pktUI", pktUIGetter("pktUI", window)); Object.defineProperty(window, "pktUIMessaging", pktUIGetter("pktUIMessaging", window)); }, diff --git a/browser/extensions/pocket/test/browser_pocket_ui_check.js b/browser/extensions/pocket/test/browser_pocket_ui_check.js index 3a763251f8d0..12aeaffd60fa 100644 --- a/browser/extensions/pocket/test/browser_pocket_ui_check.js +++ b/browser/extensions/pocket/test/browser_pocket_ui_check.js @@ -11,13 +11,20 @@ function checkElements(expectPresent, l) { } } -add_task(function*() { - let enabledOnStartup = yield promisePocketEnabled(); +add_task(function* test_setup() { + let clearValue = Services.prefs.prefHasUserValue("extensions.pocket.enabled"); + let enabledOnStartup = Services.prefs.getBoolPref("extensions.pocket.enabled"); registerCleanupFunction(() => { - // Extra insurance that this is disabled again, but it should have been set - // in promisePocketReset. - Services.prefs.setBoolPref("extensions.pocket.enabled", enabledOnStartup); + if (clearValue) { + Services.prefs.clearUserPref("extensions.pocket.enabled"); + } else { + Services.prefs.setBoolPref("extensions.pocket.enabled", enabledOnStartup); + } }); +}); + +add_task(function*() { + yield promisePocketEnabled(); checkWindowProperties(true, ["Pocket", "pktUI", "pktUIMessaging"]); checkElements(true, ["pocket-button", "panelMenu_pocket", "menu_pocket", "BMB_pocket", diff --git a/browser/modules/test/head.js b/browser/modules/test/head.js index 665e3550faf1..e407f22f39af 100644 --- a/browser/modules/test/head.js +++ b/browser/modules/test/head.js @@ -21,6 +21,7 @@ function waitForConditionPromise(condition, timeoutMsg, tryCount=NUMBER_OF_TRIES } tries++; setTimeout(checkCondition, SINGLE_TRY_TIMEOUT); + return undefined; } setTimeout(checkCondition, SINGLE_TRY_TIMEOUT); return defer.promise; diff --git a/browser/themes/linux/browser.css b/browser/themes/linux/browser.css index dab2f55c7115..99b9b321de08 100644 --- a/browser/themes/linux/browser.css +++ b/browser/themes/linux/browser.css @@ -69,6 +69,10 @@ background-image: linear-gradient(@toolbarHighlight@, @toolbarHighlight@); } +#navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar):-moz-lwtheme { + background-image: linear-gradient(@toolbarHighlightLWT@, @toolbarHighlightLWT@); +} + #navigator-toolbox > toolbar:not(:-moz-lwtheme):not(#toolbar-menubar):not(#TabsToolbar) { -moz-appearance: none; border-style: none; @@ -108,6 +112,10 @@ padding-bottom: 2px; } +#nav-bar:-moz-lwtheme { + box-shadow: 0 1px 0 @toolbarHighlightLWT@ inset; +} + #nav-bar-overflow-button { -moz-image-region: rect(-5px, 12px, 11px, -4px); } @@ -1789,7 +1797,13 @@ toolbarbutton.chevron > .toolbarbutton-icon { %include ../shared/fullscreen/warning.inc.css %include ../../../devtools/client/themes/responsivedesign.inc.css %include ../../../devtools/client/themes/commandline.inc.css + %include ../shared/plugin-doorhanger.inc.css + +notification.pluginVulnerable > .notification-inner > .messageCloseButton:not(:hover) { + background-image: -moz-image-rect(url("chrome://global/skin/icons/close.svg"), 0, 80, 16, 64); +} + %include ../shared/login-doorhanger.inc.css %include downloads/indicator.css diff --git a/browser/themes/linux/linuxShared.inc b/browser/themes/linux/linuxShared.inc index 976d4ed96785..96a92b4b9645 100644 --- a/browser/themes/linux/linuxShared.inc +++ b/browser/themes/linux/linuxShared.inc @@ -4,7 +4,8 @@ %filter substitution -%define toolbarHighlight rgba(255,255,255,.4) +%define toolbarHighlight hsla(0,0%,100%,.05) +%define toolbarHighlightLWT rgba(255,255,255,.4) %define fgTabTexture linear-gradient(transparent 2px, @toolbarHighlight@ 2px, @toolbarHighlight@) -%define fgTabTextureLWT @fgTabTexture@ +%define fgTabTextureLWT linear-gradient(transparent 2px, @toolbarHighlightLWT@ 2px, @toolbarHighlightLWT@) %define fgTabBackgroundColor -moz-dialog diff --git a/browser/themes/windows/browser.css b/browser/themes/windows/browser.css index 7493bc55508d..cdad26888c9d 100644 --- a/browser/themes/windows/browser.css +++ b/browser/themes/windows/browser.css @@ -2501,7 +2501,19 @@ notification[value="translation"] { %include ../shared/fullscreen/warning.inc.css %include ../../../devtools/client/themes/responsivedesign.inc.css %include ../../../devtools/client/themes/commandline.inc.css + %include ../shared/plugin-doorhanger.inc.css + +notification.pluginVulnerable > .notification-inner > .messageCloseButton { + list-style-image: url("chrome://global/skin/icons/close-inverted.png"); +} + +@media (min-resolution: 1.1dppx) { + notification.pluginVulnerable > .notification-inner > .messageCloseButton { + list-style-image: url("chrome://global/skin/icons/close-inverted@2x.png"); + } +} + %include ../shared/login-doorhanger.inc.css %include downloads/indicator.css diff --git a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabsInTitlebar.jsm b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabsInTitlebar.jsm index df5a1e8a2383..5b9d7d9b9213 100644 --- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabsInTitlebar.jsm +++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabsInTitlebar.jsm @@ -24,6 +24,7 @@ this.TabsInTitlebar = { return Promise.reject("TabsInTitlebar isn't supported on Linux"); } Services.prefs.setBoolPref(PREF_TABS_IN_TITLEBAR, true); + return undefined; }), }, diff --git a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Toolbars.jsm b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Toolbars.jsm index d20ded5d31ea..d01208887274 100644 --- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Toolbars.jsm +++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Toolbars.jsm @@ -37,6 +37,7 @@ this.Toolbars = { if (browserWindow.fullScreen) { return Promise.reject("The bookmark toolbar and menubar are not shown in fullscreen."); } + return undefined; }), }, diff --git a/devtools/.eslintrc b/devtools/.eslintrc index aae6b406a586..65c073f2fb27 100644 --- a/devtools/.eslintrc +++ b/devtools/.eslintrc @@ -71,7 +71,7 @@ // Enforce one true comma style. "comma-style": [2, "last"], // Warn about cyclomatic complexity in functions. - "complexity": 2, + "complexity": [2, 35], // Require return statements to either always or never specify values. "consistent-return": 2, // Don't warn for inconsistent naming when capturing this (not so important @@ -177,8 +177,6 @@ "no-empty": 2, // Disallow the use of empty character classes in regular expressions. "no-empty-character-class": 2, - // Disallow use of labels for anything other then loops and switches. - "no-empty-label": 2, // Disallow use of eval(). We have other APIs to evaluate code in content. "no-eval": 2, // Disallow assigning to the exception in a catch block. @@ -324,8 +322,8 @@ "sort-vars": 0, // Deprecated, will be removed in 1.0. "space-after-function-name": 0, - // Require a space after keywords. - "space-after-keywords": [2, "always"], + // Require a space around all keywords. + "keyword-spacing": 2, // Require a space before the start brace of a block. "space-before-blocks": [2, "always"], // Deprecated, will be removed in 1.0. @@ -340,8 +338,6 @@ "space-in-parens": [2, "never"], // Require spaces around operators, except for a|0. "space-infix-ops": [2, {"int32Hint": true}], - // Require a space after return, throw, and case. - "space-return-throw-case": 2, // Require spaces before/after unary operators (words on by default, // nonwords off by default). "space-unary-ops": [2, { "words": true, "nonwords": false }], @@ -396,7 +392,7 @@ // disallow labels that share a name with a variable "no-label-var": 0, // disallow use of labeled statements - "no-labels": 0, + "no-labels": 2, // disallow unnecessary nested blocks "no-lone-blocks": 0, // disallow creation of functions within loops diff --git a/devtools/client/aboutdebugging/aboutdebugging.css b/devtools/client/aboutdebugging/aboutdebugging.css index 929729a5bb27..d1116c0d78dd 100644 --- a/devtools/client/aboutdebugging/aboutdebugging.css +++ b/devtools/client/aboutdebugging/aboutdebugging.css @@ -47,20 +47,22 @@ button { /* Targets */ .targets { - margin-bottom: 25px; + margin-bottom: 35px; } -.target { +.target-container { margin-top: 5px; min-height: 34px; display: flex; flex-direction: row; - align-items: center; + align-items: baseline; } .target-icon { height: 24px; - margin-right: 5px; + margin: 6px 5px 0 0; + /* override the icon alignment and center it using margin-top */ + align-self: flex-start; } .target-icon:not([src]) { @@ -71,15 +73,55 @@ button { filter: invert(30%); } -.target-details { +.target { flex: 1; } +.target-details { + margin: 0; + padding: 0; + list-style-type: none +} + +.target-detail { + font-size: 12px; + margin-top: 7px; +} + +.target-detail a { + cursor: pointer; +} + +.target-detail > :not(:first-child) { + margin-left: 8px; +} + .addons-controls { display: flex; flex-direction: row; } +.addons-install-error { + background-color: #f3b0b0; + padding: 5px 10px; + margin: 5px 4px 5px 0px; +} + +.addons-install-error .warning { + background-image: url(chrome://devtools/skin/images/alerticon-warning.png); + background-size: 13px 12px; + margin-right: 10px; + display: inline-block; + width: 13px; + height: 12px; +} + +@media (min-resolution: 1.1dppx) { + .addons-install-error .warning { + background-image: url(chrome://devtools/skin/images/alerticon-warning@2x.png); + } +} + .addons-options { flex: 1; } diff --git a/devtools/client/aboutdebugging/components/addon-target.js b/devtools/client/aboutdebugging/components/addon-target.js index ea9a60af982f..df73b9ae267e 100644 --- a/devtools/client/aboutdebugging/components/addon-target.js +++ b/devtools/client/aboutdebugging/components/addon-target.js @@ -23,13 +23,13 @@ module.exports = createClass({ render() { let { target, debugDisabled } = this.props; - return dom.div({ className: "target" }, + return dom.div({ className: "target-container" }, dom.img({ className: "target-icon", role: "presentation", src: target.icon }), - dom.div({ className: "target-details" }, + dom.div({ className: "target" }, dom.div({ className: "target-name" }, target.name) ), dom.button({ diff --git a/devtools/client/aboutdebugging/components/addons-controls.js b/devtools/client/aboutdebugging/components/addons-controls.js index 6ad6f03bf7d2..87f68007add1 100644 --- a/devtools/client/aboutdebugging/components/addons-controls.js +++ b/devtools/client/aboutdebugging/components/addons-controls.js @@ -11,10 +11,12 @@ loader.lazyImporter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm"); const { Cc, Ci } = require("chrome"); -const { createClass, DOM: dom } = +const { createFactory, createClass, DOM: dom } = require("devtools/client/shared/vendor/react"); const Services = require("Services"); +const AddonsInstallError = createFactory(require("./addons-install-error")); + const Strings = Services.strings.createBundle( "chrome://devtools/locale/aboutdebugging.properties"); @@ -24,10 +26,17 @@ const MORE_INFO_URL = "https://developer.mozilla.org/docs/Tools" + module.exports = createClass({ displayName: "AddonsControls", + getInitialState() { + return { + installError: null, + }; + }, + render() { let { debugDisabled } = this.props; - return dom.div({ className: "addons-controls" }, + return dom.div({ className: "addons-top" }, + dom.div({ className: "addons-controls" }, dom.div({ className: "addons-options" }, dom.input({ id: "enable-addon-debugging", @@ -49,7 +58,8 @@ module.exports = createClass({ id: "load-addon-from-file", onClick: this.loadAddonFromFile, }, Strings.GetStringFromName("loadTemporaryAddon")) - ); + ), + AddonsInstallError({ error: this.state.installError })); }, onEnableAddonDebuggingChange(event) { @@ -59,6 +69,7 @@ module.exports = createClass({ }, loadAddonFromFile() { + this.setState({ installError: null }); let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); fp.init(window, Strings.GetStringFromName("selectAddonFromFile2"), @@ -73,11 +84,10 @@ module.exports = createClass({ if (!file.isDirectory() && !file.leafName.endsWith(".xpi")) { file = file.parent; } - try { - AddonManager.installTemporaryAddon(file); - } catch (e) { - window.alert("Error while installing the addon:\n" + e.message + "\n"); - throw e; - } + + AddonManager.installTemporaryAddon(file) + .catch(e => { + this.setState({ installError: e.message }); + }); }, }); diff --git a/devtools/client/aboutdebugging/components/addons-install-error.js b/devtools/client/aboutdebugging/components/addons-install-error.js new file mode 100644 index 000000000000..a196bbc2524f --- /dev/null +++ b/devtools/client/aboutdebugging/components/addons-install-error.js @@ -0,0 +1,22 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* eslint-env browser */ +"use strict"; + +const { createClass, DOM: dom } = require("devtools/client/shared/vendor/react"); + +module.exports = createClass({ + displayName: "AddonsInstallError", + + render() { + if (!this.props.error) { + return null; + } + let text = `There was an error during installation: ${this.props.error}`; + return dom.div({ className: "addons-install-error" }, + dom.div({ className: "warning" }), + dom.span({}, text)); + } +}); diff --git a/devtools/client/aboutdebugging/components/moz.build b/devtools/client/aboutdebugging/components/moz.build index eb3e2888e05a..af519f2dd84c 100644 --- a/devtools/client/aboutdebugging/components/moz.build +++ b/devtools/client/aboutdebugging/components/moz.build @@ -6,7 +6,9 @@ DevToolsModules( 'aboutdebugging.js', 'addon-target.js', 'addons-controls.js', + 'addons-install-error.js', 'addons-tab.js', + 'service-worker-target.js', 'tab-header.js', 'tab-menu-entry.js', 'tab-menu.js', diff --git a/devtools/client/aboutdebugging/components/service-worker-target.js b/devtools/client/aboutdebugging/components/service-worker-target.js new file mode 100644 index 000000000000..f0dfc4ff5d73 --- /dev/null +++ b/devtools/client/aboutdebugging/components/service-worker-target.js @@ -0,0 +1,111 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* eslint-env browser */ + +"use strict"; + +const { createClass, DOM: dom } = + require("devtools/client/shared/vendor/react"); +const { debugWorker } = require("../modules/worker"); +const Services = require("Services"); + +const Strings = Services.strings.createBundle( + "chrome://devtools/locale/aboutdebugging.properties"); + +module.exports = createClass({ + displayName: "ServiceWorkerTarget", + + render() { + let { target, debugDisabled } = this.props; + let isRunning = this.isRunning(); + + return dom.div({ className: "target-container" }, + dom.img({ + className: "target-icon", + role: "presentation", + src: target.icon + }), + dom.div({ className: "target" }, + dom.div({ className: "target-name" }, target.name), + dom.ul({ className: "target-details" }, + dom.li({ className: "target-detail" }, + dom.strong(null, Strings.GetStringFromName("scope")), + dom.span({ className: "service-worker-scope" }, target.scope), + dom.a({ + onClick: this.unregister, + className: "unregister-link" + }, Strings.GetStringFromName("unregister")) + ) + ) + ), + (isRunning ? + [ + dom.button({ + className: "push-button", + onClick: this.push + }, Strings.GetStringFromName("push")), + dom.button({ + className: "debug-button", + onClick: this.debug, + disabled: debugDisabled + }, Strings.GetStringFromName("debug")) + ] : + dom.button({ + className: "start-button", + onClick: this.start + }, Strings.GetStringFromName("start")) + ) + ); + }, + + debug() { + if (!this.isRunning()) { + // If the worker is not running, we can't debug it. + return; + } + + let { client, target } = this.props; + debugWorker(client, target.workerActor); + }, + + push() { + if (!this.isRunning()) { + // If the worker is not running, we can't push to it. + return; + } + + let { client, target } = this.props; + client.request({ + to: target.workerActor, + type: "push" + }); + }, + + start() { + if (this.isRunning()) { + // If the worker is already running, we can't start it. + return; + } + + let { client, target } = this.props; + client.request({ + to: target.registrationActor, + type: "start" + }); + }, + + unregister() { + let { client, target } = this.props; + client.request({ + to: target.registrationActor, + type: "unregister" + }); + }, + + isRunning() { + // We know the target is running if it has a worker actor. + return !!this.props.target.workerActor; + }, +}); diff --git a/devtools/client/aboutdebugging/components/worker-target.js b/devtools/client/aboutdebugging/components/worker-target.js index 1a3ec040ce4c..040dd8c5d89c 100644 --- a/devtools/client/aboutdebugging/components/worker-target.js +++ b/devtools/client/aboutdebugging/components/worker-target.js @@ -3,19 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* eslint-env browser */ -/* globals gDevTools, TargetFactory, Toolbox */ "use strict"; -loader.lazyRequireGetter(this, "gDevTools", - "devtools/client/framework/devtools", true); -loader.lazyRequireGetter(this, "TargetFactory", - "devtools/client/framework/target", true); -loader.lazyRequireGetter(this, "Toolbox", - "devtools/client/framework/toolbox", true); - const { createClass, DOM: dom } = require("devtools/client/shared/vendor/react"); +const { debugWorker } = require("../modules/worker"); const Services = require("Services"); const Strings = Services.strings.createBundle( @@ -26,86 +19,26 @@ module.exports = createClass({ render() { let { target, debugDisabled } = this.props; - let isRunning = this.isRunning(); - let isServiceWorker = this.isServiceWorker(); - return dom.div({ className: "target" }, + return dom.div({ className: "target-container" }, dom.img({ className: "target-icon", role: "presentation", src: target.icon }), - dom.div({ className: "target-details" }, + dom.div({ className: "target" }, dom.div({ className: "target-name" }, target.name) ), - (isRunning && isServiceWorker ? - dom.button({ - className: "push-button", - onClick: this.push - }, Strings.GetStringFromName("push")) : - null - ), - (isRunning ? - dom.button({ - className: "debug-button", - onClick: this.debug, - disabled: debugDisabled - }, Strings.GetStringFromName("debug")) : - dom.button({ - className: "start-button", - onClick: this.start - }, Strings.GetStringFromName("start")) - ) + dom.button({ + className: "debug-button", + onClick: this.debug, + disabled: debugDisabled + }, Strings.GetStringFromName("debug")) ); }, debug() { let { client, target } = this.props; - if (!this.isRunning()) { - // If the worker is not running, we can't debug it. - return; - } - client.attachWorker(target.workerActor, (response, workerClient) => { - let workerTarget = TargetFactory.forWorker(workerClient); - gDevTools.showToolbox(workerTarget, "jsdebugger", Toolbox.HostType.WINDOW) - .then(toolbox => { - toolbox.once("destroy", () => workerClient.detach()); - }); - }); - }, - - push() { - let { client, target } = this.props; - if (!this.isRunning()) { - // If the worker is not running, we can't push to it. - return; - } - client.request({ - to: target.workerActor, - type: "push" - }); - }, - - start() { - let { client, target } = this.props; - if (!this.isServiceWorker() || this.isRunning()) { - // Either the worker is already running, or it's not a service worker, in - // which case we don't know how to start it. - return; - } - client.request({ - to: target.registrationActor, - type: "start" - }); - }, - - isRunning() { - // We know the target is running if it has a worker actor. - return !!this.props.target.workerActor; - }, - - isServiceWorker() { - // We know the target is a service worker if it has a registration actor. - return !!this.props.target.registrationActor; - }, + debugWorker(client, target.workerActor); + } }); diff --git a/devtools/client/aboutdebugging/components/workers-tab.js b/devtools/client/aboutdebugging/components/workers-tab.js index 425122d2d875..3b26c6d797d7 100644 --- a/devtools/client/aboutdebugging/components/workers-tab.js +++ b/devtools/client/aboutdebugging/components/workers-tab.js @@ -7,12 +7,13 @@ const { Ci } = require("chrome"); const { createClass, createFactory, DOM: dom } = require("devtools/client/shared/vendor/react"); -const { Task } = require("resource://gre/modules/Task.jsm"); +const { getWorkerForms } = require("../modules/worker"); const Services = require("Services"); const TabHeader = createFactory(require("./tab-header")); const TargetList = createFactory(require("./target-list")); const WorkerTarget = createFactory(require("./worker-target")); +const ServiceWorkerTarget = createFactory(require("./service-worker-target")); const Strings = Services.strings.createBundle( "chrome://devtools/locale/aboutdebugging.properties"); @@ -50,7 +51,6 @@ module.exports = createClass({ render() { let { client } = this.props; let { workers } = this.state; - let targetClass = WorkerTarget; return dom.div({ id: "tab-workers", @@ -67,21 +67,21 @@ module.exports = createClass({ client, id: "service-workers", name: Strings.GetStringFromName("serviceWorkers"), - targetClass, + targetClass: ServiceWorkerTarget, targets: workers.service }), TargetList({ client, id: "shared-workers", name: Strings.GetStringFromName("sharedWorkers"), - targetClass, + targetClass: WorkerTarget, targets: workers.shared }), TargetList({ client, id: "other-workers", name: Strings.GetStringFromName("otherWorkers"), - targetClass, + targetClass: WorkerTarget, targets: workers.other }) )); @@ -90,7 +90,7 @@ module.exports = createClass({ update() { let workers = this.getInitialState().workers; - this.getWorkerForms().then(forms => { + getWorkerForms(this.props.client).then(forms => { forms.registrations.forEach(form => { workers.service.push({ icon: WorkerIcon, @@ -136,40 +136,5 @@ module.exports = createClass({ this.setState({ workers }); }); - }, - - getWorkerForms: Task.async(function*() { - let client = this.props.client; - let registrations = []; - let workers = []; - - try { - // List service worker registrations - ({ registrations } = - yield client.mainRoot.listServiceWorkerRegistrations()); - - // List workers from the Parent process - ({ workers } = yield client.mainRoot.listWorkers()); - - // And then from the Child processes - let { processes } = yield client.mainRoot.listProcesses(); - for (let process of processes) { - // Ignore parent process - if (process.parent) { - continue; - } - let { form } = yield client.getProcess(process.id); - let processActor = form.actor; - let response = yield client.request({ - to: processActor, - type: "listWorkers" - }); - workers = workers.concat(response.workers); - } - } catch (e) { - // Something went wrong, maybe our client is disconnected? - } - - return { registrations, workers }; - }), + } }); diff --git a/devtools/client/aboutdebugging/modules/moz.build b/devtools/client/aboutdebugging/modules/moz.build new file mode 100644 index 000000000000..79e9df0babe9 --- /dev/null +++ b/devtools/client/aboutdebugging/modules/moz.build @@ -0,0 +1,7 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DevToolsModules( + 'worker.js', +) diff --git a/devtools/client/aboutdebugging/modules/worker.js b/devtools/client/aboutdebugging/modules/worker.js new file mode 100644 index 000000000000..a767d409b7b2 --- /dev/null +++ b/devtools/client/aboutdebugging/modules/worker.js @@ -0,0 +1,77 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const { Task } = require("resource://gre/modules/Task.jsm"); + +loader.lazyRequireGetter(this, "gDevTools", + "devtools/client/framework/devtools", true); +loader.lazyRequireGetter(this, "TargetFactory", + "devtools/client/framework/target", true); +loader.lazyRequireGetter(this, "Toolbox", + "devtools/client/framework/toolbox", true); + +/** + * Open a window-hosted toolbox to debug the worker associated to the provided + * worker actor. + * + * @param {DebuggerClient} client + * @param {Object} workerActor + * worker actor form to debug + */ +exports.debugWorker = function(client, workerActor) { + client.attachWorker(workerActor, (response, workerClient) => { + let workerTarget = TargetFactory.forWorker(workerClient); + gDevTools.showToolbox(workerTarget, "jsdebugger", Toolbox.HostType.WINDOW) + .then(toolbox => { + toolbox.once("destroy", () => workerClient.detach()); + }); + }); +}; + +/** + * Retrieve all service worker registrations as well as workers from the parent + * and child processes. + * + * @param {DebuggerClient} client + * @return {Object} + * - {Array} registrations + * Array of ServiceWorkerRegistrationActor forms + * - {Array} workers + * Array of WorkerActor forms + */ +exports.getWorkerForms = Task.async(function* (client) { + let registrations = []; + let workers = []; + + try { + // List service worker registrations + ({ registrations } = + yield client.mainRoot.listServiceWorkerRegistrations()); + + // List workers from the Parent process + ({ workers } = yield client.mainRoot.listWorkers()); + + // And then from the Child processes + let { processes } = yield client.mainRoot.listProcesses(); + for (let process of processes) { + // Ignore parent process + if (process.parent) { + continue; + } + let { form } = yield client.getProcess(process.id); + let processActor = form.actor; + let response = yield client.request({ + to: processActor, + type: "listWorkers" + }); + workers = workers.concat(response.workers); + } + } catch (e) { + // Something went wrong, maybe our client is disconnected? + } + + return { registrations, workers }; +}); diff --git a/devtools/client/aboutdebugging/moz.build b/devtools/client/aboutdebugging/moz.build index cc2f3c28b07b..176f63fbb5a3 100644 --- a/devtools/client/aboutdebugging/moz.build +++ b/devtools/client/aboutdebugging/moz.build @@ -6,6 +6,7 @@ DIRS += [ 'components', + 'modules', ] BROWSER_CHROME_MANIFESTS += [ diff --git a/devtools/client/aboutdebugging/test/addons/bad/manifest.json b/devtools/client/aboutdebugging/test/addons/bad/manifest.json new file mode 100644 index 000000000000..4ab10b4de726 --- /dev/null +++ b/devtools/client/aboutdebugging/test/addons/bad/manifest.json @@ -0,0 +1 @@ +this is not valid json diff --git a/devtools/client/aboutdebugging/test/browser.ini b/devtools/client/aboutdebugging/test/browser.ini index 920ab03466f7..2079f6948185 100644 --- a/devtools/client/aboutdebugging/test/browser.ini +++ b/devtools/client/aboutdebugging/test/browser.ini @@ -5,6 +5,7 @@ support-files = head.js addons/unpacked/bootstrap.js addons/unpacked/install.rdf + addons/bad/manifest.json service-workers/empty-sw.html service-workers/empty-sw.js service-workers/push-sw.html @@ -17,4 +18,5 @@ support-files = [browser_service_workers_push.js] [browser_service_workers_start.js] [browser_service_workers_timeout.js] +[browser_service_workers_unregister.js] skip-if = true # Bug 1232931 diff --git a/devtools/client/aboutdebugging/test/browser_addons_install.js b/devtools/client/aboutdebugging/test/browser_addons_install.js index 70a8e3a54534..64d236253cb8 100644 --- a/devtools/client/aboutdebugging/test/browser_addons_install.js +++ b/devtools/client/aboutdebugging/test/browser_addons_install.js @@ -28,3 +28,30 @@ add_task(function* () { yield closeAboutDebugging(tab); }); + +add_task(function* () { + let { tab, document } = yield openAboutDebugging("addons"); + + // Start an observer that looks for the install error before + // actually doing the install + let top = document.querySelector(".addons-top"); + let promise = waitForMutation(top, { childList: true }); + + // Mock the file picker to select a test addon + let MockFilePicker = SpecialPowers.MockFilePicker; + MockFilePicker.init(null); + let file = getSupportsFile("addons/bad/manifest.json"); + MockFilePicker.returnFiles = [file.file]; + + // Trigger the file picker by clicking on the button + document.getElementById("load-addon-from-file").click(); + + // Now wait for the install error to appear. + yield promise; + + // And check that it really is there. + let err = document.querySelector(".addons-install-error"); + isnot(err, null, "Addon install error message appeared"); + + yield closeAboutDebugging(tab); +}); diff --git a/devtools/client/aboutdebugging/test/browser_service_workers_unregister.js b/devtools/client/aboutdebugging/test/browser_service_workers_unregister.js new file mode 100644 index 000000000000..8294a40abf0d --- /dev/null +++ b/devtools/client/aboutdebugging/test/browser_service_workers_unregister.js @@ -0,0 +1,77 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* eslint-disable mozilla/no-cpows-in-tests */ +/* global sendAsyncMessage */ + +"use strict"; + +// Test that clicking on the unregister link in the Service Worker details works +// as intended in about:debugging. +// It should unregister the service worker, which should trigger an update of +// the displayed list of service workers. + +// Service workers can't be loaded from chrome://, but http:// is ok with +// dom.serviceWorkers.testing.enabled turned on. +const HTTP_ROOT = CHROME_ROOT.replace( + "chrome://mochitests/content/", "http://mochi.test:8888/"); +const SCOPE = HTTP_ROOT + "service-workers/"; +const SERVICE_WORKER = SCOPE + "empty-sw.js"; +const TAB_URL = SCOPE + "empty-sw.html"; + +add_task(function* () { + info("Turn on workers via mochitest http."); + yield new Promise(done => { + let options = { "set": [ + // Accept workers from mochitest's http. + ["dom.serviceWorkers.testing.enabled", true], + ]}; + SpecialPowers.pushPrefEnv(options, done); + }); + + let { tab, document } = yield openAboutDebugging("workers"); + + // Listen for mutations in the service-workers list. + let serviceWorkersElement = document.getElementById("service-workers"); + let onMutation = waitForMutation(serviceWorkersElement, { childList: true }); + + // Open a tab that registers an empty service worker. + let swTab = yield addTab(TAB_URL); + + // Wait for the service workers-list to update. + yield onMutation; + + // Check that the service worker appears in the UI. + assertHasTarget(true, document, "service-workers", SERVICE_WORKER); + + info("Ensure that the registration resolved before trying to interact with " + + "the service worker."); + yield waitForServiceWorkerRegistered(swTab); + ok(true, "Service worker registration resolved"); + + let targets = document.querySelectorAll("#service-workers .target"); + is(targets.length, 1, "One service worker is now displayed."); + + let target = targets[0]; + let name = target.querySelector(".target-name"); + is(name.textContent, SERVICE_WORKER, "Found the service worker in the list"); + + info("Check the scope displayed scope is correct"); + let scope = target.querySelector(".service-worker-scope"); + is(scope.textContent, SCOPE, + "The expected scope is displayed in the service worker info."); + + info("Unregister the service worker via the unregister link."); + let unregisterLink = target.querySelector(".unregister-link"); + ok(unregisterLink, "Found the unregister link"); + + onMutation = waitForMutation(serviceWorkersElement, { childList: true }); + unregisterLink.click(); + yield onMutation; + + is(document.querySelector("#service-workers .target"), null, + "No service worker displayed anymore."); + + yield removeTab(swTab); + yield closeAboutDebugging(tab); +}); diff --git a/devtools/client/animationinspector/animation-controller.js b/devtools/client/animationinspector/animation-controller.js index 6346f82e0154..3065388d512e 100644 --- a/devtools/client/animationinspector/animation-controller.js +++ b/devtools/client/animationinspector/animation-controller.js @@ -35,7 +35,7 @@ var gToolbox, gInspector; * Startup the animationinspector controller and view, called by the sidebar * widget when loading/unloading the iframe into the tab. */ -var startup = Task.async(function*(inspector) { +var startup = Task.async(function* (inspector) { gInspector = inspector; gToolbox = inspector.toolbox; @@ -56,7 +56,7 @@ var startup = Task.async(function*(inspector) { * Shutdown the animationinspector controller and view, called by the sidebar * widget when loading/unloading the iframe into the tab. */ -var shutdown = Task.async(function*() { +var shutdown = Task.async(function* () { yield AnimationsController.destroy(); // Don't assume that AnimationsPanel is defined here, it's in another file. if (typeof AnimationsPanel !== "undefined") { @@ -79,7 +79,7 @@ function destroy() { * @param {Target} target The current toolbox target. * @return {Object} An object with boolean properties. */ -var getServerTraits = Task.async(function*(target) { +var getServerTraits = Task.async(function* (target) { let config = [ { name: "hasToggleAll", actor: "animations", method: "toggleAll" }, @@ -135,7 +135,7 @@ var AnimationsController = { PLAYERS_UPDATED_EVENT: "players-updated", ALL_ANIMATIONS_TOGGLED_EVENT: "all-animations-toggled", - initialize: Task.async(function*() { + initialize: Task.async(function* () { if (this.initialized) { yield this.initialized.promise; return; @@ -169,7 +169,7 @@ var AnimationsController = { this.initialized.resolve(); }), - destroy: Task.async(function*() { + destroy: Task.async(function* () { if (!this.initialized) { return; } @@ -215,13 +215,13 @@ var AnimationsController = { gInspector.sidebar.getCurrentTabID() == "animationinspector"; }, - onPanelVisibilityChange: Task.async(function*() { + onPanelVisibilityChange: Task.async(function* () { if (this.isPanelVisible()) { this.onNewNodeFront(); } }), - onNewNodeFront: Task.async(function*() { + onNewNodeFront: Task.async(function* () { // Ignore if the panel isn't visible or the node selection hasn't changed. if (!this.isPanelVisible() || this.nodeFront === gInspector.selection.nodeFront) { @@ -265,7 +265,7 @@ var AnimationsController = { * if they should be played. * @return {Promise} Resolves when the playState has been changed. */ - toggleCurrentAnimations: Task.async(function*(shouldPause) { + toggleCurrentAnimations: Task.async(function* (shouldPause) { if (this.traits.hasToggleSeveral) { yield this.animationsFront.toggleSeveral(this.animationPlayers, shouldPause); @@ -288,7 +288,7 @@ var AnimationsController = { * @param {Boolean} shouldPause Should the animations be paused too. * @return {Promise} Resolves when the current time has been set. */ - setCurrentTimeAll: Task.async(function*(time, shouldPause) { + setCurrentTimeAll: Task.async(function* (time, shouldPause) { if (this.traits.hasSetCurrentTimes) { yield this.animationsFront.setCurrentTimes(this.animationPlayers, time, shouldPause); @@ -309,7 +309,7 @@ var AnimationsController = { * @param {Number} rate. * @return {Promise} Resolves when the rate has been set. */ - setPlaybackRateAll: Task.async(function*(rate) { + setPlaybackRateAll: Task.async(function* (rate) { if (this.traits.hasSetPlaybackRates) { // If the backend can set all playback rates at the same time, use that. yield this.animationsFront.setPlaybackRates(this.animationPlayers, rate); @@ -327,7 +327,7 @@ var AnimationsController = { // called again. animationPlayers: [], - refreshAnimationPlayers: Task.async(function*(nodeFront) { + refreshAnimationPlayers: Task.async(function* (nodeFront) { this.destroyAnimationPlayers(); this.animationPlayers = yield this.animationsFront diff --git a/devtools/client/animationinspector/animation-panel.js b/devtools/client/animationinspector/animation-panel.js index 01a3c67f1017..cb67864481c4 100644 --- a/devtools/client/animationinspector/animation-panel.js +++ b/devtools/client/animationinspector/animation-panel.js @@ -22,7 +22,7 @@ var AnimationsPanel = { UI_UPDATED_EVENT: "ui-updated", PANEL_INITIALIZED: "panel-initialized", - initialize: Task.async(function*() { + initialize: Task.async(function* () { if (AnimationsController.destroyed) { console.warn("Could not initialize the animation-panel, controller " + "was destroyed"); @@ -79,7 +79,7 @@ var AnimationsPanel = { this.emit(this.PANEL_INITIALIZED); }), - destroy: Task.async(function*() { + destroy: Task.async(function* () { if (!this.initialized) { return; } @@ -205,7 +205,7 @@ var AnimationsPanel = { * Toggle (pause/play) all animations in the current target * and update the UI the toggleAll button. */ - toggleAll: Task.async(function*() { + toggleAll: Task.async(function* () { this.toggleAllButtonEl.classList.toggle("paused"); yield AnimationsController.toggleAll(); }), @@ -280,7 +280,9 @@ var AnimationsPanel = { this.setCurrentTimeAllPromise = AnimationsController.setCurrentTimeAll(time, true) .catch(error => console.error(error)) - .then(() => this.setCurrentTimeAllPromise = null); + .then(() => { + this.setCurrentTimeAllPromise = null; + }); } this.displayTimelineCurrentTime(); @@ -296,7 +298,7 @@ var AnimationsPanel = { * useful after the playState or currentTime has been changed and in case the * animations aren't auto-refreshing), and then refresh the UI. */ - refreshAnimationsStateAndUI: Task.async(function*() { + refreshAnimationsStateAndUI: Task.async(function* () { for (let player of AnimationsController.animationPlayers) { yield player.refreshState(); } @@ -307,7 +309,7 @@ var AnimationsPanel = { * Refresh the list of animations UI. This will empty the panel and re-render * the various components again. */ - refreshAnimationsUI: Task.async(function*() { + refreshAnimationsUI: Task.async(function* () { // Empty the whole panel first. this.togglePlayers(true); diff --git a/devtools/client/animationinspector/components/animation-details.js b/devtools/client/animationinspector/components/animation-details.js index 0d3d797ec419..055839143376 100644 --- a/devtools/client/animationinspector/components/animation-details.js +++ b/devtools/client/animationinspector/components/animation-details.js @@ -62,7 +62,7 @@ AnimationDetails.prototype = { * @return {Object} A list of tracks, one per animated property, each * with a list of keyframes */ - getTracks: Task.async(function*() { + getTracks: Task.async(function* () { let tracks = {}; /* @@ -112,7 +112,7 @@ AnimationDetails.prototype = { return tracks; }), - render: Task.async(function*(animation) { + render: Task.async(function* (animation) { this.unrender(); if (!animation) { diff --git a/devtools/client/animationinspector/components/animation-target-node.js b/devtools/client/animationinspector/components/animation-target-node.js index ed97d0d17e10..55e5a60343d4 100644 --- a/devtools/client/animationinspector/components/animation-target-node.js +++ b/devtools/client/animationinspector/components/animation-target-node.js @@ -41,7 +41,7 @@ AnimationTargetNode.prototype = { this.isDestroyed = true; }, - render: Task.async(function*(playerFront) { + render: Task.async(function* (playerFront) { // Get the nodeFront from the cache if it was stored previously. let nodeFront = nodeFronts.get(playerFront); diff --git a/devtools/client/animationinspector/test/browser_animation_animated_properties_displayed.js b/devtools/client/animationinspector/test/browser_animation_animated_properties_displayed.js index d77837e02a50..4d0a64c2de84 100644 --- a/devtools/client/animationinspector/test/browser_animation_animated_properties_displayed.js +++ b/devtools/client/animationinspector/test/browser_animation_animated_properties_displayed.js @@ -21,7 +21,7 @@ const EXPECTED_PROPERTIES = [ "width" ].sort(); -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_keyframes.html"); let {panel} = yield openAnimationInspector(); let timeline = panel.animationsTimelineComponent; diff --git a/devtools/client/animationinspector/test/browser_animation_click_selects_animation.js b/devtools/client/animationinspector/test/browser_animation_click_selects_animation.js index b35b95dffc43..be0826ad7a74 100644 --- a/devtools/client/animationinspector/test/browser_animation_click_selects_animation.js +++ b/devtools/client/animationinspector/test/browser_animation_click_selects_animation.js @@ -7,7 +7,7 @@ // Check that animations displayed in the timeline can be selected by clicking // them, and that this emits the right events and adds the right classes. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel} = yield openAnimationInspector(); let timeline = panel.animationsTimelineComponent; diff --git a/devtools/client/animationinspector/test/browser_animation_controller_exposes_document_currentTime.js b/devtools/client/animationinspector/test/browser_animation_controller_exposes_document_currentTime.js index ed992dccb808..f6f3ae84052a 100644 --- a/devtools/client/animationinspector/test/browser_animation_controller_exposes_document_currentTime.js +++ b/devtools/client/animationinspector/test/browser_animation_controller_exposes_document_currentTime.js @@ -7,7 +7,7 @@ // Test that the controller provides the document.timeline currentTime (at least // the last known version since new animations were added). -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel, controller} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_empty_on_invalid_nodes.js b/devtools/client/animationinspector/test/browser_animation_empty_on_invalid_nodes.js index a34188dd3dc7..e68af7f5a39b 100644 --- a/devtools/client/animationinspector/test/browser_animation_empty_on_invalid_nodes.js +++ b/devtools/client/animationinspector/test/browser_animation_empty_on_invalid_nodes.js @@ -12,7 +12,7 @@ const { LocalizationHelper } = require("devtools/client/shared/l10n"); const STRINGS_URI = "chrome://devtools/locale/animationinspector.properties"; const L10N = new LocalizationHelper(STRINGS_URI); -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel, window} = yield openAnimationInspector(); let {document} = window; diff --git a/devtools/client/animationinspector/test/browser_animation_keyframe_click_to_set_time.js b/devtools/client/animationinspector/test/browser_animation_keyframe_click_to_set_time.js index 73541fd704e8..9088d97af962 100644 --- a/devtools/client/animationinspector/test/browser_animation_keyframe_click_to_set_time.js +++ b/devtools/client/animationinspector/test/browser_animation_keyframe_click_to_set_time.js @@ -7,7 +7,7 @@ // Test that animated properties' keyframes can be clicked, and that doing so // sets the current time in the timeline. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_keyframes.html"); let {panel} = yield openAnimationInspector(); let timeline = panel.animationsTimelineComponent; diff --git a/devtools/client/animationinspector/test/browser_animation_keyframe_markers.js b/devtools/client/animationinspector/test/browser_animation_keyframe_markers.js index 2a51a4d91ad0..e8a7ed286025 100644 --- a/devtools/client/animationinspector/test/browser_animation_keyframe_markers.js +++ b/devtools/client/animationinspector/test/browser_animation_keyframe_markers.js @@ -21,7 +21,7 @@ const EXPECTED_PROPERTIES = [ "width" ]; -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_keyframes.html"); let {panel} = yield openAnimationInspector(); let timeline = panel.animationsTimelineComponent; diff --git a/devtools/client/animationinspector/test/browser_animation_mutations_with_same_names.js b/devtools/client/animationinspector/test/browser_animation_mutations_with_same_names.js index 920efc4ec79a..c3d1dfe97fc3 100644 --- a/devtools/client/animationinspector/test/browser_animation_mutations_with_same_names.js +++ b/devtools/client/animationinspector/test/browser_animation_mutations_with_same_names.js @@ -9,7 +9,7 @@ // displayed (which should be true as long as these animations apply to // different nodes). -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_negative_animation.html"); let {controller, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_panel_exists.js b/devtools/client/animationinspector/test/browser_animation_panel_exists.js index e758e199938f..1f12605a5578 100644 --- a/devtools/client/animationinspector/test/browser_animation_panel_exists.js +++ b/devtools/client/animationinspector/test/browser_animation_panel_exists.js @@ -6,7 +6,7 @@ // Test that the animation panel sidebar exists -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8,welcome to the animation panel"); let {panel, controller} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_participate_in_inspector_update.js b/devtools/client/animationinspector/test/browser_animation_participate_in_inspector_update.js index 27986fab5613..fec529568503 100644 --- a/devtools/client/animationinspector/test/browser_animation_participate_in_inspector_update.js +++ b/devtools/client/animationinspector/test/browser_animation_participate_in_inspector_update.js @@ -10,7 +10,7 @@ requestLongerTimeout(2); // inspector-updated event. This means that the test verifies that the // inspector-updated event is emitted *after* the animation panel is ready. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel, controller} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_playerFronts_are_refreshed.js b/devtools/client/animationinspector/test/browser_animation_playerFronts_are_refreshed.js index 377019030252..7144adf6cd4d 100644 --- a/devtools/client/animationinspector/test/browser_animation_playerFronts_are_refreshed.js +++ b/devtools/client/animationinspector/test/browser_animation_playerFronts_are_refreshed.js @@ -9,7 +9,7 @@ requestLongerTimeout(2); // Check that the AnimationPlayerFront objects lifecycle is managed by the // AnimationController. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {controller, inspector} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_playerWidgets_appear_on_panel_init.js b/devtools/client/animationinspector/test/browser_animation_playerWidgets_appear_on_panel_init.js index 3375706c4c85..ceefd3194756 100644 --- a/devtools/client/animationinspector/test/browser_animation_playerWidgets_appear_on_panel_init.js +++ b/devtools/client/animationinspector/test/browser_animation_playerWidgets_appear_on_panel_init.js @@ -9,7 +9,7 @@ const { ANIMATION_TYPES } = require("devtools/server/actors/animation"); -add_task(function*() { +add_task(function* () { yield new Promise(resolve => { SpecialPowers.pushPrefEnv({"set": [ ["dom.animations-api.core.enabled", true] diff --git a/devtools/client/animationinspector/test/browser_animation_playerWidgets_target_nodes.js b/devtools/client/animationinspector/test/browser_animation_playerWidgets_target_nodes.js index 5f649539379e..1fbaa7ae3b69 100644 --- a/devtools/client/animationinspector/test/browser_animation_playerWidgets_target_nodes.js +++ b/devtools/client/animationinspector/test/browser_animation_playerWidgets_target_nodes.js @@ -8,7 +8,7 @@ requestLongerTimeout(2); // Test that player widgets display information about target nodes -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_pseudo_elements.js b/devtools/client/animationinspector/test/browser_animation_pseudo_elements.js index de02ee3d1f15..c6cc3218c593 100644 --- a/devtools/client/animationinspector/test/browser_animation_pseudo_elements.js +++ b/devtools/client/animationinspector/test/browser_animation_pseudo_elements.js @@ -6,7 +6,7 @@ // Test that animated pseudo-elements do show in the timeline. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_pseudo_elements.html"); let {inspector, panel} = yield openAnimationInspector(); let timeline = panel.animationsTimelineComponent; diff --git a/devtools/client/animationinspector/test/browser_animation_refresh_on_added_animation.js b/devtools/client/animationinspector/test/browser_animation_refresh_on_added_animation.js index d6d9d83668fa..0bc652476d29 100644 --- a/devtools/client/animationinspector/test/browser_animation_refresh_on_added_animation.js +++ b/devtools/client/animationinspector/test/browser_animation_refresh_on_added_animation.js @@ -8,7 +8,7 @@ requestLongerTimeout(2); // Test that the panel content refreshes when new animations are added. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_refresh_on_removed_animation.js b/devtools/client/animationinspector/test/browser_animation_refresh_on_removed_animation.js index 4c559bdc277e..011d4a08629a 100644 --- a/devtools/client/animationinspector/test/browser_animation_refresh_on_removed_animation.js +++ b/devtools/client/animationinspector/test/browser_animation_refresh_on_removed_animation.js @@ -8,7 +8,7 @@ requestLongerTimeout(2); // Test that the panel content refreshes when animations are removed. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_refresh_when_active.js b/devtools/client/animationinspector/test/browser_animation_refresh_when_active.js index fc17fa4c49b9..6fb244b1eb77 100644 --- a/devtools/client/animationinspector/test/browser_animation_refresh_when_active.js +++ b/devtools/client/animationinspector/test/browser_animation_refresh_when_active.js @@ -8,7 +8,7 @@ requestLongerTimeout(2); // Test that the panel only refreshes when it is visible in the sidebar. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_running_on_compositor.js b/devtools/client/animationinspector/test/browser_animation_running_on_compositor.js index 2f91b6af767f..ba9e324c5c28 100644 --- a/devtools/client/animationinspector/test/browser_animation_running_on_compositor.js +++ b/devtools/client/animationinspector/test/browser_animation_running_on_compositor.js @@ -14,7 +14,7 @@ const { LocalizationHelper } = require("devtools/client/shared/l10n"); const STRINGS_URI = "chrome://devtools/locale/animationinspector.properties"; const L10N = new LocalizationHelper(STRINGS_URI); -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel} = yield openAnimationInspector(); let timeline = panel.animationsTimelineComponent; diff --git a/devtools/client/animationinspector/test/browser_animation_same_nb_of_playerWidgets_and_playerFronts.js b/devtools/client/animationinspector/test/browser_animation_same_nb_of_playerWidgets_and_playerFronts.js index acca367c9c32..a3aa8974cb54 100644 --- a/devtools/client/animationinspector/test/browser_animation_same_nb_of_playerWidgets_and_playerFronts.js +++ b/devtools/client/animationinspector/test/browser_animation_same_nb_of_playerWidgets_and_playerFronts.js @@ -9,7 +9,7 @@ requestLongerTimeout(2); // Check that when playerFronts are updated, the same number of playerWidgets // are created in the panel. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel, controller} = yield openAnimationInspector(); let timeline = panel.animationsTimelineComponent; diff --git a/devtools/client/animationinspector/test/browser_animation_shows_player_on_valid_node.js b/devtools/client/animationinspector/test/browser_animation_shows_player_on_valid_node.js index 89c0ae0b37be..57e6a68fbc5d 100644 --- a/devtools/client/animationinspector/test/browser_animation_shows_player_on_valid_node.js +++ b/devtools/client/animationinspector/test/browser_animation_shows_player_on_valid_node.js @@ -9,7 +9,7 @@ requestLongerTimeout(2); // Test that the panel shows an animation player when an animated node is // selected. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_spacebar_toggles_animations.js b/devtools/client/animationinspector/test/browser_animation_spacebar_toggles_animations.js index 12b08fc62882..593dbe685c21 100644 --- a/devtools/client/animationinspector/test/browser_animation_spacebar_toggles_animations.js +++ b/devtools/client/animationinspector/test/browser_animation_spacebar_toggles_animations.js @@ -10,7 +10,7 @@ // because there's an other test that does this : // browser_animation_toggle_button_toggles_animation.js -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel, inspector, window, controller} = yield openAnimationInspector(); let {toggleAllButtonEl} = panel; diff --git a/devtools/client/animationinspector/test/browser_animation_spacebar_toggles_node_animations.js b/devtools/client/animationinspector/test/browser_animation_spacebar_toggles_node_animations.js index 1e818c158d65..d407070e0176 100644 --- a/devtools/client/animationinspector/test/browser_animation_spacebar_toggles_node_animations.js +++ b/devtools/client/animationinspector/test/browser_animation_spacebar_toggles_node_animations.js @@ -10,7 +10,7 @@ // There are animations in the test page and since, by default, the node // is selected, animations will be displayed in the timeline, so the timeline // play/resume button will be displayed -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel, window} = yield openAnimationInspector(); let {playTimelineButtonEl} = panel; diff --git a/devtools/client/animationinspector/test/browser_animation_target_highlight_select.js b/devtools/client/animationinspector/test/browser_animation_target_highlight_select.js index 824a93ffaba5..de14e6aca682 100644 --- a/devtools/client/animationinspector/test/browser_animation_target_highlight_select.js +++ b/devtools/client/animationinspector/test/browser_animation_target_highlight_select.js @@ -9,7 +9,7 @@ requestLongerTimeout(2); // Test that the DOM element targets displayed in animation player widgets can // be used to highlight elements in the DOM and select them in the inspector. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {toolbox, inspector, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_target_highlighter_lock.js b/devtools/client/animationinspector/test/browser_animation_target_highlighter_lock.js index 19e9215e34d9..46345d548d68 100644 --- a/devtools/client/animationinspector/test/browser_animation_target_highlighter_lock.js +++ b/devtools/client/animationinspector/test/browser_animation_target_highlighter_lock.js @@ -9,7 +9,7 @@ requestLongerTimeout(2); // Test that the DOM element targets displayed in animation player widgets can // be used to highlight elements in the DOM and select them in the inspector. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_currentTime.js b/devtools/client/animationinspector/test/browser_animation_timeline_currentTime.js index f0048723eb10..7eaba78674b6 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_currentTime.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_currentTime.js @@ -10,7 +10,7 @@ requestLongerTimeout(2); // changes when animations are playing, gets back to 0 when animations are // rewound, and stops when animations are paused. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_header.js b/devtools/client/animationinspector/test/browser_animation_timeline_header.js index cd16f1539237..9a5a547a7985 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_header.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_header.js @@ -14,7 +14,7 @@ const {findOptimalTimeInterval, TimeScale} = require("devtools/client/animationi // animation-timeline.js const TIME_GRADUATION_MIN_SPACING = 40; -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_iterationStart.js b/devtools/client/animationinspector/test/browser_animation_timeline_iterationStart.js index ffdde0c0e10d..5116adff3360 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_iterationStart.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_iterationStart.js @@ -6,7 +6,7 @@ // Check that the iteration start is displayed correctly in time blocks. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_script_animation.html"); let {panel} = yield openAnimationInspector(); let timelineComponent = panel.animationsTimelineComponent; diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_pause_button.js b/devtools/client/animationinspector/test/browser_animation_timeline_pause_button.js index d76c7e089625..ed5d0b41e45e 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_pause_button.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_pause_button.js @@ -16,7 +16,7 @@ requestLongerTimeout(2); // And test that clicking the button once the scrubber has reached the end of // the timeline does the right thing. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel, inspector} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_rate_selector.js b/devtools/client/animationinspector/test/browser_animation_timeline_rate_selector.js index 3801a0eec9b3..4d7cb93d8d7a 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_rate_selector.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_rate_selector.js @@ -12,7 +12,7 @@ requestLongerTimeout(2); // all have the same rate, or that it displays the empty value in case they // have mixed rates. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel, controller, inspector, toolbox} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_rewind_button.js b/devtools/client/animationinspector/test/browser_animation_timeline_rewind_button.js index b16ac1332a48..90328b328887 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_rewind_button.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_rewind_button.js @@ -12,7 +12,7 @@ requestLongerTimeout(2); // reset to 0, and that the scrubber stops moving and is positioned to the // start. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel, controller} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_exists.js b/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_exists.js index ecf1664a3ce1..9fa22e007340 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_exists.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_exists.js @@ -8,7 +8,7 @@ requestLongerTimeout(2); // Check that the timeline does have a scrubber element. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_movable.js b/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_movable.js index 0eda7a47d036..a690dd78e0a3 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_movable.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_movable.js @@ -12,7 +12,7 @@ requestLongerTimeout(2); // state. // Finally, also check that the scrubber can be moved using the scrubber handle. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_moves.js b/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_moves.js index 85ad95a6852b..778ce2e55d5f 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_moves.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_scrubber_moves.js @@ -11,7 +11,7 @@ requestLongerTimeout(2); // measures the position of the scrubber once, then waits for some time to pass // and measures its position again. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_shows_delay.js b/devtools/client/animationinspector/test/browser_animation_timeline_shows_delay.js index fe4879f72b30..8082eb0cf9ce 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_shows_delay.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_shows_delay.js @@ -11,7 +11,7 @@ requestLongerTimeout(2); // Also check that negative delays do not overflow the UI, and are shown like // positive delays. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_shows_endDelay.js b/devtools/client/animationinspector/test/browser_animation_timeline_shows_endDelay.js index fe10a9e8a0d3..2c9f60746e2d 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_shows_endDelay.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_shows_endDelay.js @@ -11,7 +11,7 @@ requestLongerTimeout(2); // Also check that negative endDelays do not overflow the UI, and are shown // like positive endDelays. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_end_delay.html"); let {inspector, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_shows_iterations.js b/devtools/client/animationinspector/test/browser_animation_timeline_shows_iterations.js index 560012e8e30c..dd6b4e5b3d6f 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_shows_iterations.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_shows_iterations.js @@ -9,7 +9,7 @@ requestLongerTimeout(2); // Check that the timeline is displays as many iteration elements as there are // iterations in an animation. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_shows_time_info.js b/devtools/client/animationinspector/test/browser_animation_timeline_shows_time_info.js index ecb1caaff6aa..6927ab5f3f71 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_shows_time_info.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_shows_time_info.js @@ -9,7 +9,7 @@ requestLongerTimeout(2); // Check that the timeline displays animations' duration, delay iteration // counts and iteration start in tooltips. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel, controller} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_takes_rate_into_account.js b/devtools/client/animationinspector/test/browser_animation_timeline_takes_rate_into_account.js index 87c190063517..b6c685bdefa1 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_takes_rate_into_account.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_takes_rate_into_account.js @@ -11,7 +11,7 @@ // of which may have a different rate than others. Those that have had their // rate changed have a delay = delay/rate and a duration = duration/rate. -add_task(function*() { +add_task(function* () { yield new Promise(resolve => { SpecialPowers.pushPrefEnv({"set": [ ["dom.animations-api.core.enabled", true] diff --git a/devtools/client/animationinspector/test/browser_animation_timeline_ui.js b/devtools/client/animationinspector/test/browser_animation_timeline_ui.js index e9492dcacca4..ee9a8a7c72c4 100644 --- a/devtools/client/animationinspector/test/browser_animation_timeline_ui.js +++ b/devtools/client/animationinspector/test/browser_animation_timeline_ui.js @@ -8,7 +8,7 @@ requestLongerTimeout(2); // Check that the timeline contains the right elements. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_toggle_button_resets_on_navigate.js b/devtools/client/animationinspector/test/browser_animation_toggle_button_resets_on_navigate.js index fad64105b55e..d9a92b905d6b 100644 --- a/devtools/client/animationinspector/test/browser_animation_toggle_button_resets_on_navigate.js +++ b/devtools/client/animationinspector/test/browser_animation_toggle_button_resets_on_navigate.js @@ -8,7 +8,7 @@ requestLongerTimeout(2); // Test that a page navigation resets the state of the global toggle button. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_toggle_button_toggles_animations.js b/devtools/client/animationinspector/test/browser_animation_toggle_button_toggles_animations.js index 81d8503cd085..4d55e0433437 100644 --- a/devtools/client/animationinspector/test/browser_animation_toggle_button_toggles_animations.js +++ b/devtools/client/animationinspector/test/browser_animation_toggle_button_toggles_animations.js @@ -11,7 +11,7 @@ requestLongerTimeout(2); // animations have been paused (including inside iframes) because there's an // actor test in /devtools/server/tests/browser/ that does this. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/browser_animation_toolbar_exists.js b/devtools/client/animationinspector/test/browser_animation_toolbar_exists.js index 0f321082256d..aa8b69e02fb8 100644 --- a/devtools/client/animationinspector/test/browser_animation_toolbar_exists.js +++ b/devtools/client/animationinspector/test/browser_animation_toolbar_exists.js @@ -11,7 +11,7 @@ requestLongerTimeout(2); // Also test that this toolbar gets replaced by the timeline toolbar when there // are animations to be displayed. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {inspector, window} = yield openAnimationInspector(); let doc = window.document; diff --git a/devtools/client/animationinspector/test/browser_animation_ui_updates_when_animation_data_changes.js b/devtools/client/animationinspector/test/browser_animation_ui_updates_when_animation_data_changes.js index 8e348dd29891..aa71fd9af3a8 100644 --- a/devtools/client/animationinspector/test/browser_animation_ui_updates_when_animation_data_changes.js +++ b/devtools/client/animationinspector/test/browser_animation_ui_updates_when_animation_data_changes.js @@ -9,7 +9,7 @@ requestLongerTimeout(2); // Verify that if the animation's duration, iterations or delay change in // content, then the widget reflects the changes. -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_simple_animation.html"); let {panel, controller, inspector} = yield openAnimationInspector(); diff --git a/devtools/client/animationinspector/test/doc_end_delay.html b/devtools/client/animationinspector/test/doc_end_delay.html index d6c79aeeb4b1..02018bc8a4a2 100644 --- a/devtools/client/animationinspector/test/doc_end_delay.html +++ b/devtools/client/animationinspector/test/doc_end_delay.html @@ -16,45 +16,54 @@
diff --git a/devtools/client/animationinspector/test/doc_multiple_animation_types.html b/devtools/client/animationinspector/test/doc_multiple_animation_types.html index 3233e8d6b40f..744d1f26fca3 100644 --- a/devtools/client/animationinspector/test/doc_multiple_animation_types.html +++ b/devtools/client/animationinspector/test/doc_multiple_animation_types.html @@ -42,19 +42,20 @@
diff --git a/devtools/client/animationinspector/test/doc_script_animation.html b/devtools/client/animationinspector/test/doc_script_animation.html index 1ffc16b0757e..b7839622ef71 100644 --- a/devtools/client/animationinspector/test/doc_script_animation.html +++ b/devtools/client/animationinspector/test/doc_script_animation.html @@ -28,28 +28,44 @@
diff --git a/devtools/client/animationinspector/test/doc_simple_animation.html b/devtools/client/animationinspector/test/doc_simple_animation.html index d410d339a378..d703f0334782 100644 --- a/devtools/client/animationinspector/test/doc_simple_animation.html +++ b/devtools/client/animationinspector/test/doc_simple_animation.html @@ -114,15 +114,16 @@
diff --git a/devtools/client/animationinspector/test/head.js b/devtools/client/animationinspector/test/head.js index 8bbfe496452d..c3d0043f5a14 100644 --- a/devtools/client/animationinspector/test/head.js +++ b/devtools/client/animationinspector/test/head.js @@ -17,7 +17,7 @@ const COMMON_FRAME_SCRIPT_URL = "chrome://devtools/content/shared/frame-script-u const TAB_NAME = "animationinspector"; // Auto clean-up when a test ends -registerCleanupFunction(function*() { +registerCleanupFunction(function* () { yield closeAnimationInspector(); while (gBrowser.tabs.length > 1) { @@ -75,7 +75,7 @@ function* reloadTab(inspector) { and animations of its subtree are properly displayed. */ var selectNodeAndWaitForAnimations = Task.async( - function*(data, inspector, reason = "test") { + function* (data, inspector, reason = "test") { yield selectNode(data, inspector, reason); // We want to make sure the rest of the test waits for the animations to @@ -107,7 +107,7 @@ function assertAnimationsDisplayed(panel, nbAnimations, msg = "") { * @param {InspectorPanel} inspector * @return {Promise} */ -var waitForAnimationInspectorReady = Task.async(function*(inspector) { +var waitForAnimationInspectorReady = Task.async(function* (inspector) { let win = inspector.sidebar.getWindowForTab(TAB_NAME); let updated = inspector.once("inspector-updated"); @@ -127,7 +127,7 @@ var waitForAnimationInspectorReady = Task.async(function*(inspector) { * sidebar selected. * @return a promise that resolves when the inspector is ready. */ -var openAnimationInspector = Task.async(function*() { +var openAnimationInspector = Task.async(function* () { let {inspector, toolbox} = yield openInspectorSidebarTab(TAB_NAME); info("Waiting for the inspector and sidebar to be ready"); @@ -161,7 +161,7 @@ var openAnimationInspector = Task.async(function*() { * Close the toolbox. * @return a promise that resolves when the toolbox has closed. */ -var closeAnimationInspector = Task.async(function*() { +var closeAnimationInspector = Task.async(function* () { let target = TargetFactory.forTab(gBrowser.selectedTab); yield gDevTools.closeToolbox(target); }); @@ -214,8 +214,8 @@ function executeInContent(name, data = {}, objects = {}, /** * Get the current playState of an animation player on a given node. */ -var getAnimationPlayerState = Task.async(function*(selector, - animationIndex = 0) { +var getAnimationPlayerState = Task.async(function* (selector, + animationIndex = 0) { let playState = yield executeInContent("Test:GetAnimationPlayerState", {selector, animationIndex}); return playState; @@ -236,7 +236,7 @@ function isNodeVisible(node) { * @param {AnimationsPanel} panel * @return {Array} all AnimationTargetNode instances */ -var waitForAllAnimationTargets = Task.async(function*(panel) { +var waitForAllAnimationTargets = Task.async(function* (panel) { let targets = panel.animationsTimelineComponent.targetNodes; yield promise.all(targets.map(t => { if (!t.previewer.nodeFront) { @@ -265,7 +265,9 @@ function* assertScrubberMoving(panel, isMoving) { // If instead we expect the scrubber to remain at its position, just wait // for some time and make sure timeline-data-changed isn't emitted. let hasMoved = false; - timeline.once("timeline-data-changed", () => hasMoved = true); + timeline.once("timeline-data-changed", () => { + hasMoved = true; + }); yield new Promise(r => setTimeout(r, 500)); ok(!hasMoved, "The scrubber is not moving"); } diff --git a/devtools/client/animationinspector/test/unit/test_timeScale_dimensions.js b/devtools/client/animationinspector/test/unit/test_timeScale_dimensions.js new file mode 100644 index 000000000000..01389a2ef186 --- /dev/null +++ b/devtools/client/animationinspector/test/unit/test_timeScale_dimensions.js @@ -0,0 +1,54 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + https://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const Cu = Components.utils; +const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); +const {TimeScale} = require("devtools/client/animationinspector/utils"); + +const TEST_ENDDELAY_X = [{ + desc: "Testing positive-endDelay animations", + animations: [{ + previousStartTime: 0, + duration: 500, + playbackRate: 1, + iterationCount: 3, + delay: 500, + endDelay: 500 + }], + expectedEndDelayX: 80 +}, { + desc: "Testing negative-endDelay animations", + animations: [{ + previousStartTime: 0, + duration: 500, + playbackRate: 1, + iterationCount: 9, + delay: 500, + endDelay: -500 + }], + expectedEndDelayX: 90 +}]; + +function run_test() { + do_print("Test calculating endDelayX"); + + // Be independent of possible prior tests + TimeScale.reset(); + + for (let {desc, animations, expectedEndDelayX} of TEST_ENDDELAY_X) { + do_print(`Adding animations: ${desc}`); + + for (let state of animations) { + TimeScale.addAnimation(state); + + let {endDelayX} = TimeScale.getAnimationDimensions({state}); + equal(endDelayX, expectedEndDelayX); + + TimeScale.reset(); + } + } +} diff --git a/devtools/client/animationinspector/test/unit/xpcshell.ini b/devtools/client/animationinspector/test/unit/xpcshell.ini index 416fa85efd26..7bf87eac8a17 100644 --- a/devtools/client/animationinspector/test/unit/xpcshell.ini +++ b/devtools/client/animationinspector/test/unit/xpcshell.ini @@ -9,3 +9,4 @@ skip-if = toolkit == 'android' || toolkit == 'gonk' [test_formatStopwatchTime.js] [test_getCssPropertyName.js] [test_timeScale.js] +[test_timeScale_dimensions.js] diff --git a/devtools/client/animationinspector/utils.js b/devtools/client/animationinspector/utils.js index aa795f60865f..d791bbf1879c 100644 --- a/devtools/client/animationinspector/utils.js +++ b/devtools/client/animationinspector/utils.js @@ -328,7 +328,8 @@ var TimeScale = { // The width of the endDelay. let endDelayW = this.durationToDistance(Math.abs(endDelay) / rate); // The start position of the endDelay. - let endDelayX = endDelay < 0 ? x + w - endDelayW : x + w; + let endDelayX = endDelay < 0 ? x + iterationW - endDelayW + : x + iterationW; return {x, w, iterationW, delayX, delayW, negativeDelayW, endDelayX, endDelayW}; diff --git a/devtools/client/debugger/debugger-view.js b/devtools/client/debugger/debugger-view.js index 029a3d202c27..15871e954bbd 100644 --- a/devtools/client/debugger/debugger-view.js +++ b/devtools/client/debugger/debugger-view.js @@ -431,7 +431,6 @@ var DebuggerView = { this.editor.clearDebugLocation(); this.editor.clearHistory(); - this.editor.setCursor({ line: 0, ch: 0}); this.editor.removeBreakpoints(); // Only set editor's text and mode if it is a new document diff --git a/devtools/client/debugger/test/mochitest/browser.ini b/devtools/client/debugger/test/mochitest/browser.ini index ae4dd4615ac6..9de876ecbeb6 100644 --- a/devtools/client/debugger/test/mochitest/browser.ini +++ b/devtools/client/debugger/test/mochitest/browser.ini @@ -336,6 +336,9 @@ skip-if = e10s && debug [browser_dbg_parser-10.js] skip-if = e10s && debug [browser_dbg_parser-11.js] +[browser_dbg_parser-function-defaults.js] +[browser_dbg_parser-spread-expression.js] +[browser_dbg_parser-template-strings.js] skip-if = e10s && debug [browser_dbg_pause-exceptions-01.js] skip-if = e10s && debug @@ -608,4 +611,4 @@ skip-if = e10s && debug [browser_dbg_WorkerActor.attachThread.js] skip-if = e10s && debug [browser_dbg_split-console-keypress.js] -skip-if = e10s && debug +skip-if = e10s && (debug || os == "linux") # Bug 1214439 diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-disabled-reload.js b/devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-disabled-reload.js index 02cc1be44870..aff1b5582446 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-disabled-reload.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-disabled-reload.js @@ -79,7 +79,7 @@ function test() { yield verifyView({ disabled: false }); executeSoon(() => gDebugger.gThreadClient.resume()); - yield waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1); + yield waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6); yield verifyView({ disabled: false }); }); } @@ -94,7 +94,7 @@ function test() { yield verifyView({ disabled: false }); executeSoon(() => gDebugger.gThreadClient.resume()); - yield waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1); + yield waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6); yield verifyView({ disabled: false }); }); } diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_location-changes-04-breakpoint.js b/devtools/client/debugger/test/mochitest/browser_dbg_location-changes-04-breakpoint.js index e7babd05ff19..954c74106bc8 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_location-changes-04-breakpoint.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_location-changes-04-breakpoint.js @@ -152,10 +152,7 @@ function test() { is(gEditor.getBreakpoints().length, 1, "One breakpoint should be shown for the first source."); - //yield waitForTime(2000); - yield ensureCaretAt(gPanel, 1, 1, true); - - //yield waitForTime(50000); + yield ensureCaretAt(gPanel, 6, 1, true); resumeDebuggerThenCloseAndFinish(gPanel); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_parser-function-defaults.js b/devtools/client/debugger/test/mochitest/browser_dbg_parser-function-defaults.js new file mode 100644 index 000000000000..55fac4055861 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_parser-function-defaults.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Test that function default arguments are correctly processed. + */ + +"use strict"; + +function test() { + let { Parser, ParserHelpers, SyntaxTreeVisitor } = + Cu.import("resource://devtools/shared/Parser.jsm", {}); + + function verify(source, predicate, string) { + let ast = Parser.reflectionAPI.parse(source); + let node = SyntaxTreeVisitor.filter(ast, predicate).pop(); + let info = ParserHelpers.getIdentifierEvalString(node); + is(info, string, "The identifier evaluation string is correct."); + } + + // FunctionDeclaration + verify("function foo(a, b='b') {}", e => e.type == "Literal", "\"b\""); + // FunctionExpression + verify("let foo=function(a, b='b') {}", e => e.type == "Literal", "\"b\""); + // ArrowFunctionExpression + verify("let foo=(a, b='b')=> {}", e => e.type == "Literal", "\"b\""); + + finish(); +} diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_parser-spread-expression.js b/devtools/client/debugger/test/mochitest/browser_dbg_parser-spread-expression.js new file mode 100644 index 000000000000..4b7d93d2fa67 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_parser-spread-expression.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Test that spread expressions work both in arrays and function calls. + */ + +"use strict"; + +function test() { + let { Parser, SyntaxTreeVisitor } = + Cu.import("resource://devtools/shared/Parser.jsm", {}); + + const SCRIPTS = ["[...a]", "foo(...a)"]; + + for (let script of SCRIPTS) { + info(`Testing spread expression in '${script}'`); + let ast = Parser.reflectionAPI.parse(script); + let nodes = SyntaxTreeVisitor.filter(ast, + e => e.type == "SpreadExpression"); + ok(nodes && nodes.length === 1, "Found the SpreadExpression node"); + + let expr = nodes[0].expression; + ok(expr, "The SpreadExpression node has the sub-expression"); + is(expr.type, "Identifier", "The sub-expression is an Identifier"); + is(expr.name, "a", "The sub-expression identifier has a correct name"); + } + + finish(); +} diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_parser-template-strings.js b/devtools/client/debugger/test/mochitest/browser_dbg_parser-template-strings.js new file mode 100644 index 000000000000..6ee271137e1f --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_parser-template-strings.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Test that template strings are correctly processed. + */ + +"use strict"; + +function test() { + let { Parser, SyntaxTreeVisitor } = + Cu.import("resource://devtools/shared/Parser.jsm", {}); + + let ast = Parser.reflectionAPI.parse("`foo${i}bar`"); + let nodes = SyntaxTreeVisitor.filter(ast, e => e.type == "TemplateLiteral"); + ok(nodes && nodes.length === 1, "Found the TemplateLiteral node"); + + let elements = nodes[0].elements; + ok(elements, "The TemplateLiteral node has elements"); + is(elements.length, 3, "There are 3 elements in the literal"); + + ["Literal", "Identifier", "Literal"].forEach((type, i) => { + is(elements[i].type, type, `Element at index ${i} is '${type}'`); + }); + + finish(); +} diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_scripts-switching-01.js b/devtools/client/debugger/test/mochitest/browser_dbg_scripts-switching-01.js index de061e134c16..5793029e44a6 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_scripts-switching-01.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_scripts-switching-01.js @@ -24,44 +24,44 @@ function test() { let deferred = promise.defer(); is(gSources.itemCount, 2, - "Found the expected number of sources."); + "Found the expected number of sources. (1)"); is(gSources.items[0].target.querySelector(".dbg-source-item").getAttribute("tooltiptext"), EXAMPLE_URL + "code_script-switching-01.js", - "The correct tooltip text is displayed for the first source."); + "The correct tooltip text is displayed for the first source. (1)"); is(gSources.items[1].target.querySelector(".dbg-source-item").getAttribute("tooltiptext"), EXAMPLE_URL + "code_script-switching-02.js", - "The correct tooltip text is displayed for the second source."); + "The correct tooltip text is displayed for the second source. (1)"); ok(getSourceActor(gSources, EXAMPLE_URL + gLabel1), - "First source url is incorrect."); + "First source url is incorrect. (1)"); ok(getSourceActor(gSources, EXAMPLE_URL + gLabel2), - "Second source url is incorrect."); + "Second source url is incorrect. (1)"); ok(gSources.getItemForAttachment(e => e.label == gLabel1), - "First source label is incorrect."); + "First source label is incorrect. (1)"); ok(gSources.getItemForAttachment(e => e.label == gLabel2), - "Second source label is incorrect."); + "Second source label is incorrect. (1)"); ok(gSources.selectedItem, - "There should be a selected item in the sources pane."); + "There should be a selected item in the sources pane. (1)"); is(getSelectedSourceURL(gSources), EXAMPLE_URL + gLabel2, - "The selected value is the sources pane is incorrect."); + "The selected value is the sources pane is incorrect. (1)"); is(gEditor.getText().search(/firstCall/), -1, - "The first source is not displayed."); + "The first source is not displayed. (1)"); is(gEditor.getText().search(/debugger/), 166, - "The second source is displayed."); + "The second source is displayed. (1)"); ok(gDebugger.document.title.endsWith(EXAMPLE_URL + gLabel2), - "Title with second source is correct."); + "Title with second source is correct. (1)"); ok(isCaretPos(gPanel, 6), - "Editor caret location is correct."); + "Editor caret location is correct. (1)"); // The editor's debug location takes a tick to update. is(gEditor.getDebugLocation(), 5, - "Editor debugger location is correct."); + "Editor debugger location is correct. (1)"); ok(gEditor.hasLineClass(5, "debug-line"), "The debugged line is highlighted appropriately (1)."); @@ -75,22 +75,22 @@ function test() { let deferred = promise.defer(); ok(gSources.selectedItem, - "There should be a selected item in the sources pane."); + "There should be a selected item in the sources pane. (2)"); is(getSelectedSourceURL(gSources), EXAMPLE_URL + gLabel1, - "The selected value is the sources pane is incorrect."); + "The selected value is the sources pane is incorrect. (2)"); is(gEditor.getText().search(/firstCall/), 118, - "The first source is displayed."); + "The first source is displayed. (2)"); is(gEditor.getText().search(/debugger/), -1, - "The second source is not displayed."); + "The second source is not displayed. (2)"); // The editor's debug location takes a tick to update. ok(isCaretPos(gPanel, 1), - "Editor caret location is correct."); + "Editor caret location is correct. (2)"); is(gEditor.getDebugLocation(), null, - "Editor debugger location is correct."); + "Editor debugger location is correct. (2)"); ok(!gEditor.hasLineClass(5, "debug-line"), - "The debugged line highlight was removed."); + "The debugged line highlight was removed. (2)"); waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN).then(deferred.resolve); gSources.selectedIndex = 1; @@ -101,21 +101,21 @@ function test() { let deferred = promise.defer(); ok(gSources.selectedItem, - "There should be a selected item in the sources pane."); + "There should be a selected item in the sources pane. (3)"); is(getSelectedSourceURL(gSources), EXAMPLE_URL + gLabel2, - "The selected value is the sources pane is incorrect."); + "The selected value is the sources pane is incorrect. (3)"); is(gEditor.getText().search(/firstCall/), -1, - "The first source is not displayed."); + "The first source is not displayed. (3)"); is(gEditor.getText().search(/debugger/), 166, - "The second source is displayed."); + "The second source is displayed. (3)"); - ok(isCaretPos(gPanel, 1), - "Editor caret location is correct."); + ok(isCaretPos(gPanel, 6), + "Editor caret location is correct. (3)"); is(gEditor.getDebugLocation(), 5, - "Editor debugger location is correct."); + "Editor debugger location is correct. (3)"); ok(gEditor.hasLineClass(5, "debug-line"), - "The debugged line is highlighted appropriately (2)."); + "The debugged line is highlighted appropriately (3)."); // Step out twice. waitForThreadEvents(gPanel, "paused").then(() => { @@ -129,21 +129,21 @@ function test() { function testSwitchRunning() { ok(gSources.selectedItem, - "There should be a selected item in the sources pane."); + "There should be a selected item in the sources pane. (4)"); is(getSelectedSourceURL(gSources), EXAMPLE_URL + gLabel1, - "The selected value is the sources pane is incorrect."); + "The selected value is the sources pane is incorrect. (4)"); is(gEditor.getText().search(/firstCall/), 118, - "The first source is displayed."); + "The first source is displayed. (4)"); is(gEditor.getText().search(/debugger/), -1, - "The second source is not displayed."); + "The second source is not displayed. (4)"); ok(isCaretPos(gPanel, 6), - "Editor caret location is correct."); + "Editor caret location is correct. (4)"); is(gEditor.getDebugLocation(), 5, - "Editor debugger location is correct."); + "Editor debugger location is correct. (4)"); ok(gEditor.hasLineClass(5, "debug-line"), - "The debugged line is highlighted appropriately (3)."); + "The debugged line is highlighted appropriately (3). (4)"); } Task.spawn(function*() { diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_scripts-switching-02.js b/devtools/client/debugger/test/mochitest/browser_dbg_scripts-switching-02.js index 542b2e14bc53..191c110fe07a 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_scripts-switching-02.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_scripts-switching-02.js @@ -25,34 +25,34 @@ function test() { let deferred = promise.defer(); is(gSources.itemCount, 2, - "Found the expected number of sources."); + "Found the expected number of sources. (1)"); ok(getSourceActor(gSources, EXAMPLE_URL + gLabel1), - "First source url is incorrect."); + "First source url is incorrect. (1)"); ok(getSourceActor(gSources, EXAMPLE_URL + gLabel2 + gParams), - "Second source url is incorrect."); + "Second source url is incorrect. (1)"); ok(gSources.getItemForAttachment(e => e.label == gLabel1), - "First source label is incorrect."); + "First source label is incorrect. (1)"); ok(gSources.getItemForAttachment(e => e.label == gLabel2), - "Second source label is incorrect."); + "Second source label is incorrect. (1)"); ok(gSources.selectedItem, - "There should be a selected item in the sources pane."); + "There should be a selected item in the sources pane. (1)"); is(getSelectedSourceURL(gSources), EXAMPLE_URL + gLabel2 + gParams, - "The selected value is the sources pane is incorrect."); + "The selected value is the sources pane is incorrect. (1)"); is(gEditor.getText().search(/firstCall/), -1, - "The first source is not displayed."); + "The first source is not displayed. (1)"); is(gEditor.getText().search(/debugger/), 166, - "The second source is displayed."); + "The second source is displayed. (1)"); ok(isCaretPos(gPanel, 6), - "Editor caret location is correct."); + "Editor caret location is correct. (1)"); is(gEditor.getDebugLocation(), 5, - "Editor debugger location is correct."); + "Editor debugger location is correct. (1)"); ok(gEditor.hasLineClass(5, "debug-line"), - "The debugged line is highlighted appropriately."); + "The debugged line is highlighted appropriately. (1)"); waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN).then(deferred.resolve); gSources.selectedItem = e => e.attachment.label == gLabel1; @@ -64,23 +64,23 @@ function test() { let deferred = promise.defer(); ok(gSources.selectedItem, - "There should be a selected item in the sources pane."); + "There should be a selected item in the sources pane. (2)"); is(getSelectedSourceURL(gSources), EXAMPLE_URL + gLabel1, - "The selected value is the sources pane is incorrect."); + "The selected value is the sources pane is incorrect. (2)"); is(gEditor.getText().search(/firstCall/), 118, - "The first source is displayed."); + "The first source is displayed. (2)"); is(gEditor.getText().search(/debugger/), -1, - "The second source is not displayed."); + "The second source is not displayed. (2)"); // The editor's debug location takes a tick to update. ok(isCaretPos(gPanel, 1), - "Editor caret location is correct."); + "Editor caret location is correct. (2)"); is(gEditor.getDebugLocation(), null, - "Editor debugger location is correct."); + "Editor debugger location is correct. (2)"); ok(!gEditor.hasLineClass(5, "debug-line"), - "The debugged line highlight was removed."); + "The debugged line highlight was removed. (2)"); waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN).then(deferred.resolve); gSources.selectedItem = e => e.attachment.label == gLabel2; @@ -92,22 +92,22 @@ function test() { let deferred = promise.defer(); ok(gSources.selectedItem, - "There should be a selected item in the sources pane."); + "There should be a selected item in the sources pane. (3)"); is(getSelectedSourceURL(gSources), EXAMPLE_URL + gLabel2 + gParams, - "The selected value is the sources pane is incorrect."); + "The selected value is the sources pane is incorrect. (3)"); is(gEditor.getText().search(/firstCall/), -1, - "The first source is not displayed."); + "The first source is not displayed. (3)"); is(gEditor.getText().search(/debugger/), 166, - "The second source is displayed."); + "The second source is displayed. (3)"); // The editor's debug location takes a tick to update. - ok(isCaretPos(gPanel, 1), - "Editor caret location is correct."); + ok(isCaretPos(gPanel, 6), + "Editor caret location is correct. (3)"); is(gEditor.getDebugLocation(), 5, - "Editor debugger location is correct."); + "Editor debugger location is correct. (3)"); ok(gEditor.hasLineClass(5, "debug-line"), - "The debugged line is highlighted appropriately."); + "The debugged line is highlighted appropriately. (3)"); // Step out three times. waitForThreadEvents(gPanel, "paused").then(() => { @@ -123,22 +123,22 @@ function test() { let deferred = promise.defer(); ok(gSources.selectedItem, - "There should be a selected item in the sources pane."); + "There should be a selected item in the sources pane. (4)"); is(getSelectedSourceURL(gSources), EXAMPLE_URL + gLabel1, - "The selected value is the sources pane is incorrect."); + "The selected value is the sources pane is incorrect. (4)"); is(gEditor.getText().search(/firstCall/), 118, - "The first source is displayed."); + "The first source is displayed. (4)"); is(gEditor.getText().search(/debugger/), -1, - "The second source is not displayed."); + "The second source is not displayed. (4)"); // The editor's debug location takes a tick to update. ok(isCaretPos(gPanel, 6), - "Editor caret location is correct."); + "Editor caret location is correct. (4)"); is(gEditor.getDebugLocation(), 5, - "Editor debugger location is correct."); + "Editor debugger location is correct. (4)"); ok(gEditor.hasLineClass(5, "debug-line"), - "The debugged line is highlighted appropriately."); + "The debugged line is highlighted appropriately. (4)"); deferred.resolve(); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_search-global-05.js b/devtools/client/debugger/test/mochitest/browser_dbg_search-global-05.js index 45e5cd1512bc..b987c5702e64 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_search-global-05.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_search-global-05.js @@ -49,11 +49,11 @@ function doSearch() { info("Debugger editor text:\n" + gEditor.getText()); ok(isCaretPos(gPanel, 6), - "The editor shouldn't have jumped to a matching line yet."); + "The editor shouldn't have jumped to a matching line yet. (1)"); ok(getSelectedSourceURL(gSources).includes("-02.js"), - "The current source shouldn't have changed after a global search."); + "The current source shouldn't have changed after a global search. (2)"); is(gSources.visibleItems.length, 2, - "Not all the sources are shown after the global search."); + "Not all the sources are shown after the global search. (3)"); deferred.resolve(); }); @@ -75,17 +75,17 @@ function testExpandCollapse() { EventUtils.sendMouseEvent({ type: "click" }, secondHeader); is(item0.instance.expanded, false, - "The first source results should be collapsed on click.") + "The first source results should be collapsed on click. (2)") is(item1.instance.expanded, false, - "The second source results should be collapsed on click.") + "The second source results should be collapsed on click. (2)") EventUtils.sendMouseEvent({ type: "click" }, firstHeader); EventUtils.sendMouseEvent({ type: "click" }, secondHeader); is(item0.instance.expanded, true, - "The first source results should be expanded on an additional click."); + "The first source results should be expanded on an additional click. (3)"); is(item1.instance.expanded, true, - "The second source results should be expanded on an additional click."); + "The second source results should be expanded on an additional click. (3)"); } function testClickLineToJump() { @@ -100,13 +100,13 @@ function testClickLineToJump() { info("Debugger editor text:\n" + gEditor.getText()); ok(isCaretPos(gPanel, 1, 5), - "The editor didn't jump to the correct line (1)."); + "The editor didn't jump to the correct line (4)."); is(gEditor.getSelection(), "A", - "The editor didn't select the correct text (1)."); + "The editor didn't select the correct text (4)."); ok(getSelectedSourceURL(gSources).includes("-01.js"), - "The currently shown source is incorrect (1)."); + "The currently shown source is incorrect (4)."); is(gSources.visibleItems.length, 2, - "Not all the sources are shown after the global search (1)."); + "Not all the sources are shown after the global search (4)."); deferred.resolve(); }); @@ -124,18 +124,18 @@ function testClickMatchToJump() { let secondMatches = sourceResults[1].querySelectorAll(".dbg-results-line-contents-string[match=true]"); let lastMatch = Array.slice(secondMatches).pop(); - waitForSourceAndCaret(gPanel, "-02.js", 1, 1).then(() => { + waitForSourceAndCaret(gPanel, "-02.js", 13, 3).then(() => { info("Current source url:\n" + getSelectedSourceURL(gSources)); info("Debugger editor text:\n" + gEditor.getText()); ok(isCaretPos(gPanel, 13, 3), - "The editor didn't jump to the correct line (2)."); + "The editor didn't jump to the correct line (5)."); is(gEditor.getSelection(), "a", - "The editor didn't select the correct text (2)."); + "The editor didn't select the correct text (5)."); ok(getSelectedSourceURL(gSources).includes("-02.js"), - "The currently shown source is incorrect (2)."); + "The currently shown source is incorrect (5)."); is(gSources.visibleItems.length, 2, - "Not all the sources are shown after the global search (2)."); + "Not all the sources are shown after the global search (5)."); deferred.resolve(); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_search-sources-01.js b/devtools/client/debugger/test/mochitest/browser_dbg_search-sources-01.js index b45e669ce431..de064b246c8e 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_search-sources-01.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_search-sources-01.js @@ -212,7 +212,7 @@ function test() { return finished.then(() => promise.all([ ensureSourceIs(gPanel, "-01.js"), - ensureCaretAt(gPanel, 1), + ensureCaretAt(gPanel, 2, 9), verifyContents({ itemCount: 2, hidden: false }) ])); } diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_stack-06.js b/devtools/client/debugger/test/mochitest/browser_dbg_stack-06.js index a16e2298791e..f4237d500744 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_stack-06.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_stack-06.js @@ -40,7 +40,7 @@ function performTest() { is(gEditor.getText().search(/debugger/), 166, "The second source is displayed."); - waitForSourceAndCaret(gPanel, "-01.js", 1).then(waitForTick).then(() => { + waitForSourceAndCaret(gPanel, "-01.js", 5).then(waitForTick).then(() => { is(gFrames.selectedIndex, 0, "Oldest frame should be selected after click."); is(gClassicFrames.selectedIndex, 1, @@ -52,7 +52,7 @@ function performTest() { is(gEditor.getText().search(/debugger/), -1, "The second source is not displayed."); - waitForSourceAndCaret(gPanel, "-02.js", 1).then(waitForTick).then(() => { + waitForSourceAndCaret(gPanel, "-02.js", 6).then(waitForTick).then(() => { is(gFrames.selectedIndex, 1, "Newest frame should be selected again after click."); is(gClassicFrames.selectedIndex, 0, diff --git a/devtools/client/definitions.js b/devtools/client/definitions.js index 6c3f2af10780..006345b78cf5 100644 --- a/devtools/client/definitions.js +++ b/devtools/client/definitions.js @@ -141,6 +141,7 @@ Tools.webConsole = { } panel.focusInput(); + return undefined; }, isTargetSupported: function() { diff --git a/devtools/client/inspector/layout/layout.js b/devtools/client/inspector/layout/layout.js index ff6a5855eda3..494fa3943b78 100644 --- a/devtools/client/inspector/layout/layout.js +++ b/devtools/client/inspector/layout/layout.js @@ -604,6 +604,7 @@ LayoutView.prototype = { this.elementRules = styleEntries.map(e => e.rule); this.inspector.emit("layoutview-updated"); + return undefined; }).bind(this)).catch(console.error); this._lastRequest = lastRequest; diff --git a/devtools/client/inspector/layout/test/browser_layout.js b/devtools/client/inspector/layout/test/browser_layout.js index e7e797eb23f7..2daebd01271d 100644 --- a/devtools/client/inspector/layout/test/browser_layout.js +++ b/devtools/client/inspector/layout/test/browser_layout.js @@ -126,7 +126,7 @@ var res2 = [ }, ]; -add_task(function*() { +add_task(function* () { let style = "div { position: absolute; top: 42px; left: 42px; " + "height: 100.111px; width: 100px; border: 10px solid black; " + "padding: 20px; margin: 30px auto;}"; diff --git a/devtools/client/inspector/layout/test/browser_layout_editablemodel.js b/devtools/client/inspector/layout/test/browser_layout_editablemodel.js index dae2ba30573d..c143b7188fc1 100644 --- a/devtools/client/inspector/layout/test/browser_layout_editablemodel.js +++ b/devtools/client/inspector/layout/test/browser_layout_editablemodel.js @@ -19,7 +19,7 @@ const TEST_URI = "" + "
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); let {inspector, view, testActor} = yield openLayoutView(); diff --git a/devtools/client/inspector/layout/test/browser_layout_editablemodel_border.js b/devtools/client/inspector/layout/test/browser_layout_editablemodel_border.js index e775bf5183fb..4a0386502083 100644 --- a/devtools/client/inspector/layout/test/browser_layout_editablemodel_border.js +++ b/devtools/client/inspector/layout/test/browser_layout_editablemodel_border.js @@ -14,7 +14,7 @@ const TEST_URI = "" + "
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); let {inspector, view, testActor} = yield openLayoutView(); diff --git a/devtools/client/inspector/layout/test/browser_layout_editablemodel_stylerules.js b/devtools/client/inspector/layout/test/browser_layout_editablemodel_stylerules.js index a65a2a351f12..e27d91e91b95 100644 --- a/devtools/client/inspector/layout/test/browser_layout_editablemodel_stylerules.js +++ b/devtools/client/inspector/layout/test/browser_layout_editablemodel_stylerules.js @@ -15,7 +15,7 @@ const TEST_URI = "" + "
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); let {inspector, view, testActor} = yield openLayoutView(); diff --git a/devtools/client/inspector/layout/test/browser_layout_guides.js b/devtools/client/inspector/layout/test/browser_layout_guides.js index 94354e99aaaf..abad54df9294 100644 --- a/devtools/client/inspector/layout/test/browser_layout_guides.js +++ b/devtools/client/inspector/layout/test/browser_layout_guides.js @@ -17,7 +17,7 @@ const TEST_URL = "data:text/html;charset=utf-8," + encodeURIComponent(HTML); var highlightedNodeFront, highlighterOptions; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URL); let {toolbox, inspector, view} = yield openLayoutView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/layout/test/browser_layout_rotate-labels-on-sides.js b/devtools/client/inspector/layout/test/browser_layout_rotate-labels-on-sides.js index ff47fd095ddd..5ec5bbff4738 100644 --- a/devtools/client/inspector/layout/test/browser_layout_rotate-labels-on-sides.js +++ b/devtools/client/inspector/layout/test/browser_layout_rotate-labels-on-sides.js @@ -30,7 +30,7 @@ const TEST_URI = encodeURIComponent([ ].join("")); const LONG_TEXT_ROTATE_LIMIT = 3; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html," + TEST_URI); let {inspector, view} = yield openLayoutView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/layout/test/browser_layout_tooltips.js b/devtools/client/inspector/layout/test/browser_layout_tooltips.js index 3f8020af7d32..69aef28e59a4 100644 --- a/devtools/client/inspector/layout/test/browser_layout_tooltips.js +++ b/devtools/client/inspector/layout/test/browser_layout_tooltips.js @@ -70,7 +70,7 @@ const VALUES_TEST_DATA = [{ }] }]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openLayoutView(); diff --git a/devtools/client/inspector/layout/test/browser_layout_update-after-navigation.js b/devtools/client/inspector/layout/test/browser_layout_update-after-navigation.js index da99e8aecef9..3d082cddab23 100644 --- a/devtools/client/inspector/layout/test/browser_layout_update-after-navigation.js +++ b/devtools/client/inspector/layout/test/browser_layout_update-after-navigation.js @@ -10,7 +10,7 @@ const IFRAME1 = URL_ROOT + "doc_layout_iframe1.html"; const IFRAME2 = URL_ROOT + "doc_layout_iframe2.html"; -add_task(function*() { +add_task(function* () { yield addTab(IFRAME1); let {inspector, view, testActor} = yield openLayoutView(); diff --git a/devtools/client/inspector/layout/test/browser_layout_update-after-reload.js b/devtools/client/inspector/layout/test/browser_layout_update-after-reload.js index 522fa97643bc..1352445dbc85 100644 --- a/devtools/client/inspector/layout/test/browser_layout_update-after-reload.js +++ b/devtools/client/inspector/layout/test/browser_layout_update-after-reload.js @@ -6,7 +6,7 @@ // Test that the layout-view continues to work after the page is reloaded -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_layout_iframe1.html"); let {inspector, view, testActor} = yield openLayoutView(); diff --git a/devtools/client/inspector/layout/test/browser_layout_update-in-iframes.js b/devtools/client/inspector/layout/test/browser_layout_update-in-iframes.js index 38730156a99a..1847a38c2a80 100644 --- a/devtools/client/inspector/layout/test/browser_layout_update-in-iframes.js +++ b/devtools/client/inspector/layout/test/browser_layout_update-in-iframes.js @@ -7,7 +7,7 @@ // Test that the layout-view for elements within iframes also updates when they // change -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_layout_iframe1.html"); let {inspector, view, testActor} = yield openLayoutView(); diff --git a/devtools/client/inspector/markup/markup.js b/devtools/client/inspector/markup/markup.js index 451cd89f19d5..4cf8abeb763e 100644 --- a/devtools/client/inspector/markup/markup.js +++ b/devtools/client/inspector/markup/markup.js @@ -468,6 +468,8 @@ MarkupView.prototype = { // and decision to show or not the tooltip return container.isImagePreviewTarget(target, this.tooltip); } + + return undefined; }, /** @@ -534,6 +536,7 @@ MarkupView.prototype = { // Make sure the new selection receives focus so the keyboard can be used. this.maybeFocusNewSelection(); + return undefined; }).catch(e => { if (!this._destroyer) { console.error(e); @@ -707,6 +710,7 @@ MarkupView.prototype = { this.cancelDragging(); break; } + // falls through } default: handled = false; @@ -2009,7 +2013,7 @@ MarkupContainer.prototype = { /** * On mouse up, stop dragging. */ - _onMouseUp: Task.async(function*() { + _onMouseUp: Task.async(function* () { this._isPreDragging = false; if (this.isDragging) { @@ -2298,6 +2302,7 @@ MarkupElementContainer.prototype = Heritage.extend(MarkupContainer.prototype, { }); return true; } + return undefined; }, /** @@ -2327,7 +2332,7 @@ MarkupElementContainer.prototype = Heritage.extend(MarkupContainer.prototype, { Services.prefs.getIntPref("devtools.inspector.imagePreviewTooltipSize"); // Fetch the preview from the server. - this.tooltipDataPromise = Task.spawn(function*() { + this.tooltipDataPromise = Task.spawn(function* () { let preview = yield this.node.getImageData(maxDim); let data = yield preview.data.string(); diff --git a/devtools/client/inspector/markup/test/browser_markup_anonymous_01.js b/devtools/client/inspector/markup/test/browser_markup_anonymous_01.js index dd5a2093ba6e..fd32251d0eff 100644 --- a/devtools/client/inspector/markup/test/browser_markup_anonymous_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_anonymous_01.js @@ -7,7 +7,7 @@ // Test native anonymous content in the markupview. const TEST_URL = URL_ROOT + "doc_markup_anonymous.html"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); let pseudo = yield getNodeFront("#pseudo", inspector); diff --git a/devtools/client/inspector/markup/test/browser_markup_anonymous_02.js b/devtools/client/inspector/markup/test/browser_markup_anonymous_02.js index b59b422aa746..b6221c5c3201 100644 --- a/devtools/client/inspector/markup/test/browser_markup_anonymous_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_anonymous_02.js @@ -9,7 +9,7 @@ requestLongerTimeout(2); // Test XBL anonymous content in the markupview const TEST_URL = "chrome://devtools/content/scratchpad/scratchpad.xul"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); let toolbarbutton = yield getNodeFront("toolbarbutton", inspector); diff --git a/devtools/client/inspector/markup/test/browser_markup_anonymous_03.js b/devtools/client/inspector/markup/test/browser_markup_anonymous_03.js index 30ae57c3c370..010ce06e071a 100644 --- a/devtools/client/inspector/markup/test/browser_markup_anonymous_03.js +++ b/devtools/client/inspector/markup/test/browser_markup_anonymous_03.js @@ -9,7 +9,7 @@ // of elements should be working. const TEST_URL = URL_ROOT + "doc_markup_anonymous.html"; -add_task(function*() { +add_task(function* () { Services.prefs.setBoolPref("dom.webcomponents.enabled", true); let {inspector} = yield openInspectorForURL(TEST_URL); diff --git a/devtools/client/inspector/markup/test/browser_markup_anonymous_04.js b/devtools/client/inspector/markup/test/browser_markup_anonymous_04.js index e91ba216fa71..da5e4567d2dd 100644 --- a/devtools/client/inspector/markup/test/browser_markup_anonymous_04.js +++ b/devtools/client/inspector/markup/test/browser_markup_anonymous_04.js @@ -9,7 +9,7 @@ const TEST_URL = URL_ROOT + "doc_markup_anonymous.html"; const PREF = "devtools.inspector.showAllAnonymousContent"; -add_task(function*() { +add_task(function* () { Services.prefs.setBoolPref(PREF, true); let {inspector} = yield openInspectorForURL(TEST_URL); diff --git a/devtools/client/inspector/markup/test/browser_markup_copy_image_data.js b/devtools/client/inspector/markup/test/browser_markup_copy_image_data.js index eaca463117cf..4c98cff26dd9 100644 --- a/devtools/client/inspector/markup/test/browser_markup_copy_image_data.js +++ b/devtools/client/inspector/markup/test/browser_markup_copy_image_data.js @@ -7,7 +7,7 @@ // Test that image nodes have the "copy data-uri" contextual menu item enabled // and that clicking it puts the image data into the clipboard -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_markup_image_and_canvas.html"); let {inspector, testActor} = yield openInspector(); diff --git a/devtools/client/inspector/markup/test/browser_markup_css_completion_style_attribute_01.js b/devtools/client/inspector/markup/test/browser_markup_css_completion_style_attribute_01.js index 62e29fe60689..4dc049ee92a7 100644 --- a/devtools/client/inspector/markup/test/browser_markup_css_completion_style_attribute_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_css_completion_style_attribute_01.js @@ -69,7 +69,7 @@ const TEST_DATA = [ -1, -1, false] ]; -add_task(function*() { +add_task(function* () { info("Opening the inspector on the test URL"); let {inspector} = yield openInspectorForURL(TEST_URL); diff --git a/devtools/client/inspector/markup/test/browser_markup_css_completion_style_attribute_02.js b/devtools/client/inspector/markup/test/browser_markup_css_completion_style_attribute_02.js index 42c460c289c2..51a1d4796b9c 100644 --- a/devtools/client/inspector/markup/test/browser_markup_css_completion_style_attribute_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_css_completion_style_attribute_02.js @@ -96,7 +96,7 @@ const TEST_DATA_INNER = [ ["VK_RETURN", "style=\"background:url('1'); color:beige\"", -1, -1, false] ]; -add_task(function*() { +add_task(function* () { info("Opening the inspector on the test URL"); let {inspector} = yield openInspectorForURL(TEST_URL); diff --git a/devtools/client/inspector/markup/test/browser_markup_dragdrop_autoscroll.js b/devtools/client/inspector/markup/test/browser_markup_dragdrop_autoscroll.js index 8040b9e6b7b3..0be577e4e97d 100644 --- a/devtools/client/inspector/markup/test/browser_markup_dragdrop_autoscroll.js +++ b/devtools/client/inspector/markup/test/browser_markup_dragdrop_autoscroll.js @@ -9,7 +9,7 @@ const TEST_URL = URL_ROOT + "doc_markup_dragdrop_autoscroll.html"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); let markup = inspector.markup; let viewHeight = markup.doc.documentElement.clientHeight; diff --git a/devtools/client/inspector/markup/test/browser_markup_dragdrop_distance.js b/devtools/client/inspector/markup/test/browser_markup_dragdrop_distance.js index 9b230092ecb6..3c52936387b4 100644 --- a/devtools/client/inspector/markup/test/browser_markup_dragdrop_distance.js +++ b/devtools/client/inspector/markup/test/browser_markup_dragdrop_distance.js @@ -14,7 +14,7 @@ const TEST_NODE = "#test"; // Keep this in sync with DRAG_DROP_MIN_INITIAL_DISTANCE in markup-view.js const MIN_DISTANCE = 10; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); info("Drag the test node by half of the minimum distance"); diff --git a/devtools/client/inspector/markup/test/browser_markup_dragdrop_dragRootNode.js b/devtools/client/inspector/markup/test/browser_markup_dragdrop_dragRootNode.js index 17e49920834f..8bb4779d5d75 100644 --- a/devtools/client/inspector/markup/test/browser_markup_dragdrop_dragRootNode.js +++ b/devtools/client/inspector/markup/test/browser_markup_dragdrop_dragRootNode.js @@ -9,7 +9,7 @@ const TEST_URL = URL_ROOT + "doc_markup_dragdrop.html"; const TEST_DATA = ["html", "head", "body"]; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); for (let selector of TEST_DATA) { diff --git a/devtools/client/inspector/markup/test/browser_markup_dragdrop_draggable.js b/devtools/client/inspector/markup/test/browser_markup_dragdrop_draggable.js index b43efd4221b4..f878964ad8ba 100644 --- a/devtools/client/inspector/markup/test/browser_markup_dragdrop_draggable.js +++ b/devtools/client/inspector/markup/test/browser_markup_dragdrop_draggable.js @@ -22,7 +22,7 @@ const TEST_DATA = [ { node: "input", draggable: true }, { node: "div", draggable: true }, { - node: function*(inspector) { + node: function* (inspector) { let parentFront = yield getNodeFront("#before", inspector); let {nodes} = yield inspector.walker.children(parentFront); // Getting the comment node. @@ -31,7 +31,7 @@ const TEST_DATA = [ draggable: true }, { - node: function*(inspector) { + node: function* (inspector) { let parentFront = yield getNodeFront("#test", inspector); let {nodes} = yield inspector.walker.children(parentFront); // Getting the ::before pseudo element. @@ -41,7 +41,7 @@ const TEST_DATA = [ } ]; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); yield inspector.markup.expandAll(); diff --git a/devtools/client/inspector/markup/test/browser_markup_dragdrop_escapeKeyPress.js b/devtools/client/inspector/markup/test/browser_markup_dragdrop_escapeKeyPress.js index fad442ae7339..075d143521e7 100644 --- a/devtools/client/inspector/markup/test/browser_markup_dragdrop_escapeKeyPress.js +++ b/devtools/client/inspector/markup/test/browser_markup_dragdrop_escapeKeyPress.js @@ -8,7 +8,7 @@ const TEST_URL = URL_ROOT + "doc_markup_dragdrop.html"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); let {markup} = inspector; diff --git a/devtools/client/inspector/markup/test/browser_markup_dragdrop_invalidNodes.js b/devtools/client/inspector/markup/test/browser_markup_dragdrop_invalidNodes.js index f5fc9f516767..9eea6a1027fd 100644 --- a/devtools/client/inspector/markup/test/browser_markup_dragdrop_invalidNodes.js +++ b/devtools/client/inspector/markup/test/browser_markup_dragdrop_invalidNodes.js @@ -9,7 +9,7 @@ const TEST_URL = URL_ROOT + "doc_markup_dragdrop.html"; const PREF = "devtools.inspector.showAllAnonymousContent"; -add_task(function*() { +add_task(function* () { Services.prefs.setBoolPref(PREF, true); let {inspector} = yield openInspectorForURL(TEST_URL); diff --git a/devtools/client/inspector/markup/test/browser_markup_dragdrop_reorder.js b/devtools/client/inspector/markup/test/browser_markup_dragdrop_reorder.js index 894026f19cc9..f74b50147441 100644 --- a/devtools/client/inspector/markup/test/browser_markup_dragdrop_reorder.js +++ b/devtools/client/inspector/markup/test/browser_markup_dragdrop_reorder.js @@ -10,7 +10,7 @@ requestLongerTimeout(2); const TEST_URL = URL_ROOT + "doc_markup_dragdrop.html"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); let ids; diff --git a/devtools/client/inspector/markup/test/browser_markup_dragdrop_tooltip.js b/devtools/client/inspector/markup/test/browser_markup_dragdrop_tooltip.js index 94a4a204d888..13cc2e0cd344 100644 --- a/devtools/client/inspector/markup/test/browser_markup_dragdrop_tooltip.js +++ b/devtools/client/inspector/markup/test/browser_markup_dragdrop_tooltip.js @@ -7,7 +7,7 @@ const TEST_URL = "data:text/html;charset=utf8,
"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); let {markup} = inspector; diff --git a/devtools/client/inspector/markup/test/browser_markup_events-overflow.js b/devtools/client/inspector/markup/test/browser_markup_events-overflow.js index 6ef442391a14..f52877bf15ae 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events-overflow.js +++ b/devtools/client/inspector/markup/test/browser_markup_events-overflow.js @@ -30,7 +30,7 @@ const TEST_DATA = [ }, ]; -add_task(function*() { +add_task(function* () { let { inspector } = yield openInspectorForURL(TEST_URL); let markupContainer = yield getContainerForSelector("#events", inspector); diff --git a/devtools/client/inspector/markup/test/browser_markup_events.js b/devtools/client/inspector/markup/test/browser_markup_events.js index 03d484e96ad2..09420c94e15d 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events.js +++ b/devtools/client/inspector/markup/test/browser_markup_events.js @@ -192,6 +192,6 @@ const TEST_DATA = [ // eslint-disable-line }, ]; -add_task(function*() { +add_task(function* () { yield runEventPopupTests(TEST_URL, TEST_DATA); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_events_form.js b/devtools/client/inspector/markup/test/browser_markup_events_form.js index 0bba8ef6226b..d5fefb2f849b 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events_form.js +++ b/devtools/client/inspector/markup/test/browser_markup_events_form.js @@ -14,7 +14,7 @@ const TEST_ACTOR_URL = CHROME_URL_ROOT + "actor_events_form.js"; var {EventsFormFront} = require(TEST_ACTOR_URL); -add_task(function*() { +add_task(function* () { info("Opening the Toolbox"); let tab = yield addTab(TEST_PAGE_URL); let toolbox = yield openToolboxForTab(tab, "webconsole"); diff --git a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.0.js b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.0.js index e010f2f4c9dc..d9aa2aa10018 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.0.js +++ b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.0.js @@ -233,6 +233,6 @@ const TEST_DATA = [ ]; /*eslint-enable */ -add_task(function*() { +add_task(function* () { yield runEventPopupTests(TEST_URL, TEST_DATA); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.1.js b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.1.js index d95e132fb4a1..a63a970b8f2f 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.1.js +++ b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.1.js @@ -267,6 +267,6 @@ const TEST_DATA = [ ]; /*eslint-enable */ -add_task(function*() { +add_task(function* () { yield runEventPopupTests(TEST_URL, TEST_DATA); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.11.1.js b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.11.1.js index 280a6b127290..17d59a317463 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.11.1.js +++ b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.11.1.js @@ -191,6 +191,6 @@ const TEST_DATA = [ ]; /*eslint-enable */ -add_task(function*() { +add_task(function* () { yield runEventPopupTests(TEST_URL, TEST_DATA); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.2.js b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.2.js index be343f7ffe51..c26a14d6678d 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.2.js +++ b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.2.js @@ -186,6 +186,6 @@ const TEST_DATA = [ ]; /*eslint-enable */ -add_task(function*() { +add_task(function* () { yield runEventPopupTests(TEST_URL, TEST_DATA); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.3.js b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.3.js index 2be64594c6f3..e0bdab2fdf8e 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.3.js +++ b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.3.js @@ -219,6 +219,6 @@ const TEST_DATA = [ ]; /*eslint-enable */ -add_task(function*() { +add_task(function* () { yield runEventPopupTests(TEST_URL, TEST_DATA); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.4.js b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.4.js index c7e0f2c4318d..9f7d9e2419da 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.4.js +++ b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.4.js @@ -282,6 +282,6 @@ const TEST_DATA = [ ]; /*eslint-enable */ -add_task(function*() { +add_task(function* () { yield runEventPopupTests(TEST_URL, TEST_DATA); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.6.js b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.6.js index 18f761a76fef..f89bd074056a 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.6.js +++ b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.6.js @@ -383,6 +383,6 @@ const TEST_DATA = [ ]; /*eslint-enable */ -add_task(function*() { +add_task(function* () { yield runEventPopupTests(TEST_URL, TEST_DATA); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.7.js b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.7.js index 2be7e7f88bf0..39f1d54e2b46 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.7.js +++ b/devtools/client/inspector/markup/test/browser_markup_events_jquery_1.7.js @@ -229,6 +229,6 @@ const TEST_DATA = [ ]; /*eslint-enable */ -add_task(function*() { +add_task(function* () { yield runEventPopupTests(TEST_URL, TEST_DATA); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_events_jquery_2.1.1.js b/devtools/client/inspector/markup/test/browser_markup_events_jquery_2.1.1.js index 3dfef76852b8..c6a6642ea100 100644 --- a/devtools/client/inspector/markup/test/browser_markup_events_jquery_2.1.1.js +++ b/devtools/client/inspector/markup/test/browser_markup_events_jquery_2.1.1.js @@ -191,6 +191,6 @@ const TEST_DATA = [ ]; /*eslint-enable */ -add_task(function*() { +add_task(function* () { yield runEventPopupTests(TEST_URL, TEST_DATA); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_html_edit_01.js b/devtools/client/inspector/markup/test/browser_markup_html_edit_01.js index 18117b9d1fbc..9679a5f47055 100644 --- a/devtools/client/inspector/markup/test/browser_markup_html_edit_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_html_edit_01.js @@ -12,7 +12,7 @@ const TEST_DATA = [{ selector: "#one", oldHTML: '
First Div
', newHTML: '
First Div
', - validate: function*({pageNodeFront, selectedNodeFront, testActor}) { + validate: function* ({pageNodeFront, selectedNodeFront, testActor}) { let text = yield testActor.getProperty("#one", "textContent"); is(text, "First Div", "New div has expected text content"); let num = yield testActor.getNumberOfElementMatches("#one em"); @@ -33,7 +33,7 @@ const TEST_DATA = [{ oldHTML: '
addedAttribute
', newHTML: "
" + "addedAttribute
", - validate: function*({pageNodeFront, selectedNodeFront, testActor}) { + validate: function* ({pageNodeFront, selectedNodeFront, testActor}) { is(pageNodeFront, selectedNodeFront, "Original element is selected"); let html = yield testActor.getProperty("#addedAttribute", "outerHTML"); is(html, "
before sibling
' + '
siblings (updated)
' + '
after sibling
', - validate: function*({selectedNodeFront, inspector, testActor}) { + validate: function* ({selectedNodeFront, inspector, testActor}) { let beforeSiblingFront = yield getNodeFront("#siblings-before-sibling", inspector); is(beforeSiblingFront, selectedNodeFront, "Sibling has been selected"); @@ -75,7 +75,7 @@ const TEST_URL = "data:text/html," + "" + ""; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); inspector.markup._frame.focus(); yield runEditOuterHTMLTests(TEST_DATA, inspector, testActor); diff --git a/devtools/client/inspector/markup/test/browser_markup_html_edit_02.js b/devtools/client/inspector/markup/test/browser_markup_html_edit_02.js index 5226fc40686e..8f6d0fd1446f 100644 --- a/devtools/client/inspector/markup/test/browser_markup_html_edit_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_html_edit_02.js @@ -14,7 +14,7 @@ const TEST_DATA = [ selector: "#badMarkup1", oldHTML: "
badMarkup1
", newHTML: "
badMarkup1
hanging
", - validate: function*({pageNodeFront, selectedNodeFront, testActor}) { + validate: function* ({pageNodeFront, selectedNodeFront, testActor}) { is(pageNodeFront, selectedNodeFront, "Original element is selected"); let textNodeName = yield testActor.eval(` @@ -32,7 +32,7 @@ const TEST_DATA = [ oldHTML: "
badMarkup2
", newHTML: "
badMarkup2
hanging
" + "", - validate: function*({pageNodeFront, selectedNodeFront, testActor}) { + validate: function* ({pageNodeFront, selectedNodeFront, testActor}) { is(pageNodeFront, selectedNodeFront, "Original element is selected"); let textNodeName = yield testActor.eval(` @@ -50,7 +50,7 @@ const TEST_DATA = [ oldHTML: "
badMarkup3
", newHTML: "
badMarkup3 Emphasized " + "and strong
", - validate: function*({pageNodeFront, selectedNodeFront, testActor}) { + validate: function* ({pageNodeFront, selectedNodeFront, testActor}) { is(pageNodeFront, selectedNodeFront, "Original element is selected"); let emText = yield testActor.getProperty("#badMarkup3 em", "textContent"); @@ -64,7 +64,7 @@ const TEST_DATA = [ selector: "#badMarkup4", oldHTML: "
badMarkup4
", newHTML: "
badMarkup4

", - validate: function*({pageNodeFront, selectedNodeFront, testActor}) { + validate: function* ({pageNodeFront, selectedNodeFront, testActor}) { is(pageNodeFront, selectedNodeFront, "Original element is selected"); let divText = yield testActor.getProperty("#badMarkup4", "textContent"); @@ -83,7 +83,7 @@ const TEST_DATA = [ selector: "#badMarkup5", oldHTML: "

badMarkup5

", newHTML: "

badMarkup5

with a nested div

", - validate: function*({pageNodeFront, selectedNodeFront, testActor}) { + validate: function* ({pageNodeFront, selectedNodeFront, testActor}) { is(pageNodeFront, selectedNodeFront, "Original element is selected"); let num = yield testActor.getNumberOfElementMatches("#badMarkup5 div"); @@ -112,7 +112,7 @@ const TEST_URL = "data:text/html," + "" + ""; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); inspector.markup._frame.focus(); yield runEditOuterHTMLTests(TEST_DATA, inspector, testActor); diff --git a/devtools/client/inspector/markup/test/browser_markup_html_edit_03.js b/devtools/client/inspector/markup/test/browser_markup_html_edit_03.js index ed9e65470617..76b527f42e66 100644 --- a/devtools/client/inspector/markup/test/browser_markup_html_edit_03.js +++ b/devtools/client/inspector/markup/test/browser_markup_html_edit_03.js @@ -20,7 +20,7 @@ const NEW_HTML = '
Edited
'; requestLongerTimeout(2); -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); inspector.markup._frame.focus(); diff --git a/devtools/client/inspector/markup/test/browser_markup_image_tooltip.js b/devtools/client/inspector/markup/test/browser_markup_image_tooltip.js index 968ef799c404..c767815a0b7a 100644 --- a/devtools/client/inspector/markup/test/browser_markup_image_tooltip.js +++ b/devtools/client/inspector/markup/test/browser_markup_image_tooltip.js @@ -14,7 +14,7 @@ const TEST_NODES = [ {selector: ".canvas", size: "600" + " \u00D7 " + "600"} ]; -add_task(function*() { +add_task(function* () { yield addTab(URL_ROOT + "doc_markup_image_and_canvas_2.html"); let {inspector} = yield openInspector(); diff --git a/devtools/client/inspector/markup/test/browser_markup_image_tooltip_mutations.js b/devtools/client/inspector/markup/test/browser_markup_image_tooltip_mutations.js index 2e91367e7b33..5c4e34fdbaf7 100644 --- a/devtools/client/inspector/markup/test/browser_markup_image_tooltip_mutations.js +++ b/devtools/client/inspector/markup/test/browser_markup_image_tooltip_mutations.js @@ -16,7 +16,7 @@ const UPDATED_SRC = URL_ROOT + "doc_markup_tooltip.png"; const INITIAL_SRC_SIZE = "64" + " \u00D7 " + "64"; const UPDATED_SRC_SIZE = "22" + " \u00D7 " + "23"; -add_task(function*() { +add_task(function* () { let { inspector } = yield openInspectorForURL( "data:text/html,

markup view tooltip test

"); diff --git a/devtools/client/inspector/markup/test/browser_markup_keybindings_01.js b/devtools/client/inspector/markup/test/browser_markup_keybindings_01.js index 16ad0654b251..de6879e680fc 100644 --- a/devtools/client/inspector/markup/test/browser_markup_keybindings_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_01.js @@ -10,7 +10,7 @@ requestLongerTimeout(2); const TEST_URL = "data:text/html;charset=utf8,
"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); info("Focusing the tag editor of the test element"); diff --git a/devtools/client/inspector/markup/test/browser_markup_keybindings_02.js b/devtools/client/inspector/markup/test/browser_markup_keybindings_02.js index 8c81f88ccbec..0e4b8a802975 100644 --- a/devtools/client/inspector/markup/test/browser_markup_keybindings_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_02.js @@ -9,7 +9,7 @@ const TEST_URL = "data:text/html;charset=utf8,
"; -add_task(function*() { +add_task(function* () { let {inspector, toolbox} = yield openInspectorForURL(TEST_URL); info("Focusing the tag editor of the test element"); diff --git a/devtools/client/inspector/markup/test/browser_markup_keybindings_03.js b/devtools/client/inspector/markup/test/browser_markup_keybindings_03.js index c657b9e0e289..1a94c92704e9 100644 --- a/devtools/client/inspector/markup/test/browser_markup_keybindings_03.js +++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_03.js @@ -11,7 +11,7 @@ const TEST_URL = `data:text/html;charset=utf8,
Text node`; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); let {walker} = inspector; diff --git a/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js b/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js index ffa81aead6bb..3b6f8bfb3729 100644 --- a/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js +++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js @@ -12,7 +12,7 @@ requestLongerTimeout(2); const TEST_URL = "data:text/html;charset=utf8,
test element
"; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); info("Select the test node with the browser ctx menu"); diff --git a/devtools/client/inspector/markup/test/browser_markup_keybindings_delete_attributes.js b/devtools/client/inspector/markup/test/browser_markup_keybindings_delete_attributes.js index e4c875e0bfba..277735d24d3a 100644 --- a/devtools/client/inspector/markup/test/browser_markup_keybindings_delete_attributes.js +++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_delete_attributes.js @@ -7,7 +7,7 @@ // Tests that attributes can be deleted from the markup-view with the delete key // when they are focused. -const HTML = `
`; +const HTML = '
'; const TEST_URL = "data:text/html;charset=utf-8," + encodeURIComponent(HTML); // List of all the test cases. Each item is an object with the following props: @@ -24,7 +24,7 @@ const TEST_DATA = [{ attribute: "data-id" }]; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); let {walker} = inspector; diff --git a/devtools/client/inspector/markup/test/browser_markup_keybindings_scrolltonode.js b/devtools/client/inspector/markup/test/browser_markup_keybindings_scrolltonode.js index 02458b8bf25b..c8fb443b9945 100644 --- a/devtools/client/inspector/markup/test/browser_markup_keybindings_scrolltonode.js +++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_scrolltonode.js @@ -17,7 +17,7 @@ const HTML =
`; const TEST_URL = "data:text/html;charset=utf-8," + encodeURIComponent(HTML); -add_task(function*() { +add_task(function* () { let { inspector, testActor } = yield openInspectorForURL(TEST_URL); info("Make sure the markup frame has the focus"); diff --git a/devtools/client/inspector/markup/test/browser_markup_links_01.js b/devtools/client/inspector/markup/test/browser_markup_links_01.js index 3ce7091d11a5..4ef3ba4b98b8 100644 --- a/devtools/client/inspector/markup/test/browser_markup_links_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_links_01.js @@ -102,7 +102,7 @@ const TEST_DATA = [{ requestLongerTimeout(2); -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); for (let {selector, attributes} of TEST_DATA) { diff --git a/devtools/client/inspector/markup/test/browser_markup_links_02.js b/devtools/client/inspector/markup/test/browser_markup_links_02.js index 5096560994d0..83893281c367 100644 --- a/devtools/client/inspector/markup/test/browser_markup_links_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_links_02.js @@ -9,7 +9,7 @@ const TEST_URL = URL_ROOT + "doc_markup_links.html"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); info("Adding a contextmenu attribute to the body node"); diff --git a/devtools/client/inspector/markup/test/browser_markup_links_03.js b/devtools/client/inspector/markup/test/browser_markup_links_03.js index d43c868c73a2..a54ccb4980e8 100644 --- a/devtools/client/inspector/markup/test/browser_markup_links_03.js +++ b/devtools/client/inspector/markup/test/browser_markup_links_03.js @@ -8,7 +8,7 @@ const TEST_URL = URL_ROOT + "doc_markup_links.html"; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); info("Adding a contextmenu attribute to the body node via the content"); diff --git a/devtools/client/inspector/markup/test/browser_markup_links_04.js b/devtools/client/inspector/markup/test/browser_markup_links_04.js index 87fe8cb3d89a..d4f98b429e70 100644 --- a/devtools/client/inspector/markup/test/browser_markup_links_04.js +++ b/devtools/client/inspector/markup/test/browser_markup_links_04.js @@ -74,7 +74,7 @@ const TEST_DATA = [{ isLinkCopyItemVisible: false }]; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); let linkFollow = inspector.panelDoc.getElementById("node-menu-link-follow"); diff --git a/devtools/client/inspector/markup/test/browser_markup_links_05.js b/devtools/client/inspector/markup/test/browser_markup_links_05.js index a5c9bd682054..8e1f6fa8add9 100644 --- a/devtools/client/inspector/markup/test/browser_markup_links_05.js +++ b/devtools/client/inspector/markup/test/browser_markup_links_05.js @@ -9,7 +9,7 @@ const TEST_URL = URL_ROOT + "doc_markup_links.html"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); info("Select a node with a URI attribute"); diff --git a/devtools/client/inspector/markup/test/browser_markup_links_06.js b/devtools/client/inspector/markup/test/browser_markup_links_06.js index 3c440da2e084..7321d7e07e56 100644 --- a/devtools/client/inspector/markup/test/browser_markup_links_06.js +++ b/devtools/client/inspector/markup/test/browser_markup_links_06.js @@ -9,7 +9,7 @@ const TEST_URL = URL_ROOT + "doc_markup_links.html"; -add_task(function*() { +add_task(function* () { let {toolbox, inspector} = yield openInspectorForURL(TEST_URL); info("Select a node with a cssresource attribute"); diff --git a/devtools/client/inspector/markup/test/browser_markup_links_07.js b/devtools/client/inspector/markup/test/browser_markup_links_07.js index 66df058adf5b..ef88d96f87e6 100644 --- a/devtools/client/inspector/markup/test/browser_markup_links_07.js +++ b/devtools/client/inspector/markup/test/browser_markup_links_07.js @@ -9,7 +9,7 @@ const TEST_URL = URL_ROOT + "doc_markup_links.html"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); info("Select a node with a URI attribute"); diff --git a/devtools/client/inspector/markup/test/browser_markup_load_01.js b/devtools/client/inspector/markup/test/browser_markup_load_01.js index 1fb2dae53084..d623a10f2b5a 100644 --- a/devtools/client/inspector/markup/test/browser_markup_load_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_load_01.js @@ -32,7 +32,7 @@ const TEST_URL = "data:text/html," + "" + ""; -add_task(function*() { +add_task(function* () { let {inspector, testActor, tab} = yield openInspectorForURL(TEST_URL); let domContentLoaded = waitForLinkedBrowserEvent(tab, "DOMContentLoaded"); let pageLoaded = waitForLinkedBrowserEvent(tab, "load"); diff --git a/devtools/client/inspector/markup/test/browser_markup_mutation_01.js b/devtools/client/inspector/markup/test/browser_markup_mutation_01.js index ea93cd67a4fa..0948f0a93500 100644 --- a/devtools/client/inspector/markup/test/browser_markup_mutation_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_mutation_01.js @@ -17,10 +17,10 @@ const TEST_URL = URL_ROOT + "doc_markup_mutation.html"; const TEST_DATA = [ { desc: "Adding an attribute", - test: function*(testActor) { + test: function* (testActor) { yield testActor.setAttribute("#node1", "newattr", "newattrval"); }, - check: function*(inspector) { + check: function* (inspector) { let {editor} = yield getContainerForSelector("#node1", inspector); ok([...editor.attrList.querySelectorAll(".attreditor")].some(attr => { return attr.textContent.trim() === "newattr=\"newattrval\""; @@ -29,10 +29,10 @@ const TEST_DATA = [ }, { desc: "Removing an attribute", - test: function*(testActor) { + test: function* (testActor) { yield testActor.removeAttribute("#node1", "newattr"); }, - check: function*(inspector) { + check: function* (inspector) { let {editor} = yield getContainerForSelector("#node1", inspector); ok(![...editor.attrList.querySelectorAll(".attreditor")].some(attr => { return attr.textContent.trim() === "newattr=\"newattrval\""; @@ -41,10 +41,10 @@ const TEST_DATA = [ }, { desc: "Re-adding an attribute", - test: function*(testActor) { + test: function* (testActor) { yield testActor.setAttribute("#node1", "newattr", "newattrval"); }, - check: function*(inspector) { + check: function* (inspector) { let {editor} = yield getContainerForSelector("#node1", inspector); ok([...editor.attrList.querySelectorAll(".attreditor")].some(attr => { return attr.textContent.trim() === "newattr=\"newattrval\""; @@ -53,10 +53,10 @@ const TEST_DATA = [ }, { desc: "Changing an attribute", - test: function*(testActor) { + test: function* (testActor) { yield testActor.setAttribute("#node1", "newattr", "newattrchanged"); }, - check: function*(inspector) { + check: function* (inspector) { let {editor} = yield getContainerForSelector("#node1", inspector); ok([...editor.attrList.querySelectorAll(".attreditor")].some(attr => { return attr.textContent.trim() === "newattr=\"newattrchanged\""; @@ -66,13 +66,13 @@ const TEST_DATA = [ { desc: "Adding ::after element", numMutations: 2, - test: function*(testActor) { + test: function* (testActor) { yield testActor.eval(` let node1 = content.document.querySelector("#node1"); node1.classList.add("pseudo"); `); }, - check: function*(inspector) { + check: function* (inspector) { let {children} = yield getContainerForSelector("#node1", inspector); is(children.childNodes.length, 2, "Node1 now has 2 children (text child and ::after"); @@ -81,23 +81,23 @@ const TEST_DATA = [ { desc: "Removing ::after element", numMutations: 2, - test: function*(testActor) { + test: function* (testActor) { yield testActor.eval(` let node1 = content.document.querySelector("#node1"); node1.classList.remove("pseudo"); `); }, - check: function*(inspector) { + check: function* (inspector) { let container = yield getContainerForSelector("#node1", inspector); ok(container.singleTextChild, "Has single text child."); } }, { desc: "Updating the text-content", - test: function*(testActor) { + test: function* (testActor) { yield testActor.setProperty("#node1", "textContent", "newtext"); }, - check: function*(inspector) { + check: function* (inspector) { let container = yield getContainerForSelector("#node1", inspector); ok(container.singleTextChild, "Has single text child."); ok(!container.canExpand, "Can't expand container with singleTextChild."); @@ -108,14 +108,14 @@ const TEST_DATA = [ }, { desc: "Adding a second text child", - test: function*(testActor) { + test: function* (testActor) { yield testActor.eval(` let node1 = content.document.querySelector("#node1"); let newText = node1.ownerDocument.createTextNode("more"); node1.appendChild(newText); `); }, - check: function*(inspector) { + check: function* (inspector) { let container = yield getContainerForSelector("#node1", inspector); ok(!container.singleTextChild, "Does not have single text child."); ok(container.canExpand, "Can expand container with child nodes."); @@ -125,10 +125,10 @@ const TEST_DATA = [ }, { desc: "Go from 2 to 1 text child", - test: function*(testActor) { + test: function* (testActor) { yield testActor.setProperty("#node1", "textContent", "newtext"); }, - check: function*(inspector) { + check: function* (inspector) { let container = yield getContainerForSelector("#node1", inspector); ok(container.singleTextChild, "Has single text child."); ok(!container.canExpand, "Can't expand container with singleTextChild."); @@ -139,10 +139,10 @@ const TEST_DATA = [ }, { desc: "Removing an only text child", - test: function*(testActor) { + test: function* (testActor) { yield testActor.setProperty("#node1", "innerHTML", ""); }, - check: function*(inspector) { + check: function* (inspector) { let container = yield getContainerForSelector("#node1", inspector); ok(!container.singleTextChild, "Does not have single text child."); ok(!container.canExpand, "Can't expand empty container."); @@ -152,10 +152,10 @@ const TEST_DATA = [ }, { desc: "Go from 0 to 1 text child", - test: function*(testActor) { + test: function* (testActor) { yield testActor.setProperty("#node1", "textContent", "newtext"); }, - check: function*(inspector) { + check: function* (inspector) { let container = yield getContainerForSelector("#node1", inspector); ok(container.singleTextChild, "Has single text child."); ok(!container.canExpand, "Can't expand container with singleTextChild."); @@ -167,11 +167,11 @@ const TEST_DATA = [ { desc: "Updating the innerHTML", - test: function*(testActor) { + test: function* (testActor) { yield testActor.setProperty("#node2", "innerHTML", "
foo
"); }, - check: function*(inspector) { + check: function* (inspector) { let container = yield getContainerForSelector("#node2", inspector); let openTags = container.children.querySelectorAll(".open .tag"); @@ -185,7 +185,7 @@ const TEST_DATA = [ }, { desc: "Removing child nodes", - test: function*(testActor) { + test: function* (testActor) { yield testActor.eval(` let node4 = content.document.querySelector("#node4"); while (node4.firstChild) { @@ -193,21 +193,21 @@ const TEST_DATA = [ } `); }, - check: function*(inspector) { + check: function* (inspector) { let {children} = yield getContainerForSelector("#node4", inspector); is(children.innerHTML, "", "Children have been removed"); } }, { desc: "Appending a child to a different parent", - test: function*(testActor) { + test: function* (testActor) { yield testActor.eval(` let node17 = content.document.querySelector("#node17"); let node2 = content.document.querySelector("#node2"); node2.appendChild(node17); `); }, - check: function*(inspector) { + check: function* (inspector) { let {children} = yield getContainerForSelector("#node16", inspector); is(children.innerHTML, "", "Node17 has been removed from its node16 parent"); @@ -233,7 +233,7 @@ const TEST_DATA = [ // node21 // node18 // node19 - test: function*(testActor) { + test: function* (testActor) { yield testActor.eval(` let node18 = content.document.querySelector("#node18"); let node20 = content.document.querySelector("#node20"); @@ -242,7 +242,7 @@ const TEST_DATA = [ node20.appendChild(node18); `); }, - check: function*(inspector) { + check: function* (inspector) { yield inspector.markup.expandAll(); let {children} = yield getContainerForSelector("#node1", inspector); @@ -266,7 +266,7 @@ const TEST_DATA = [ } ]; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); info("Expanding all markup-view nodes"); diff --git a/devtools/client/inspector/markup/test/browser_markup_mutation_02.js b/devtools/client/inspector/markup/test/browser_markup_mutation_02.js index dbf9cafcc79e..7d097ade64cd 100644 --- a/devtools/client/inspector/markup/test/browser_markup_mutation_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_mutation_02.js @@ -21,7 +21,7 @@ const TEST_URL = URL_ROOT + "doc_markup_flashing.html"; // If missing, the rootNode (".list") will be expected to flash const TEST_DATA = [{ desc: "Adding a new node should flash the new node", - mutate: function*(testActor) { + mutate: function* (testActor) { yield testActor.eval(` let newLi = content.document.createElement("LI"); newLi.textContent = "new list item"; @@ -31,7 +31,7 @@ const TEST_DATA = [{ flashedNode: ".list li:nth-child(3)" }, { desc: "Removing a node should flash its parent", - mutate: function*(testActor) { + mutate: function* (testActor) { yield testActor.eval(` let root = content.document.querySelector(".list"); root.removeChild(root.lastElementChild); @@ -39,7 +39,7 @@ const TEST_DATA = [{ } }, { desc: "Re-appending an existing node should only flash this node", - mutate: function*(testActor) { + mutate: function* (testActor) { yield testActor.eval(` let root = content.document.querySelector(".list"); root.appendChild(root.firstElementChild); @@ -49,26 +49,26 @@ const TEST_DATA = [{ }, { desc: "Adding an attribute should flash the attribute", attribute: "test-name", - mutate: function*(testActor) { + mutate: function* (testActor) { yield testActor.setAttribute(".list", "test-name", "value-" + Date.now()); } }, { desc: "Adding an attribute with css reserved characters should flash the " + "attribute", attribute: "one:two", - mutate: function*(testActor) { + mutate: function* (testActor) { yield testActor.setAttribute(".list", "one:two", "value-" + Date.now()); } }, { desc: "Editing an attribute should flash the attribute", attribute: "class", - mutate: function*(testActor) { + mutate: function* (testActor) { yield testActor.setAttribute(".list", "class", "list value-" + Date.now()); } }, { desc: "Multiple changes to an attribute should flash the attribute", attribute: "class", - mutate: function*(testActor) { + mutate: function* (testActor) { yield testActor.eval(` let root = content.document.querySelector(".list"); root.removeAttribute("class"); @@ -81,7 +81,7 @@ const TEST_DATA = [{ } }, { desc: "Removing an attribute should flash the node", - mutate: function*(testActor) { + mutate: function* (testActor) { yield testActor.eval(` let root = content.document.querySelector(".list"); root.removeAttribute("class"); @@ -89,7 +89,7 @@ const TEST_DATA = [{ } }]; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); // Make sure mutated nodes flash for a very long time so we can more easily diff --git a/devtools/client/inspector/markup/test/browser_markup_navigation.js b/devtools/client/inspector/markup/test/browser_markup_navigation.js index 6fd3cad5685b..a64a448566b2 100644 --- a/devtools/client/inspector/markup/test/browser_markup_navigation.js +++ b/devtools/client/inspector/markup/test/browser_markup_navigation.js @@ -66,7 +66,7 @@ const TEST_DATA = [ ["down", "head"] ]; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); info("Making sure the markup-view frame is focused"); diff --git a/devtools/client/inspector/markup/test/browser_markup_node_names.js b/devtools/client/inspector/markup/test/browser_markup_node_names.js index 6a6b8e6e8cb7..a8afad5e9dc4 100644 --- a/devtools/client/inspector/markup/test/browser_markup_node_names.js +++ b/devtools/client/inspector/markup/test/browser_markup_node_names.js @@ -7,7 +7,7 @@ // Test element node name in the markupview const TEST_URL = URL_ROOT + "doc_markup_html_mixed_case.html"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); // Get and open the svg element to show its children diff --git a/devtools/client/inspector/markup/test/browser_markup_node_not_displayed_01.js b/devtools/client/inspector/markup/test/browser_markup_node_not_displayed_01.js index cc6bce5c03bc..18304490e8d0 100644 --- a/devtools/client/inspector/markup/test/browser_markup_node_not_displayed_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_node_not_displayed_01.js @@ -21,7 +21,7 @@ const TEST_DATA = [ {selector: "#visibility-hidden", isDisplayed: true} ]; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); for (let {selector, isDisplayed} of TEST_DATA) { diff --git a/devtools/client/inspector/markup/test/browser_markup_node_not_displayed_02.js b/devtools/client/inspector/markup/test/browser_markup_node_not_displayed_02.js index 5c0205853761..b0a3f07b2746 100644 --- a/devtools/client/inspector/markup/test/browser_markup_node_not_displayed_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_node_not_displayed_02.js @@ -13,7 +13,7 @@ const TEST_DATA = [ desc: "Hiding a node by creating a new stylesheet", selector: "#normal-div", before: true, - changeStyle: function*(testActor) { + changeStyle: function* (testActor) { yield testActor.eval(` let div = content.document.createElement("div"); div.id = "new-style"; @@ -27,7 +27,7 @@ const TEST_DATA = [ desc: "Showing a node by deleting an existing stylesheet", selector: "#normal-div", before: false, - changeStyle: function*(testActor) { + changeStyle: function* (testActor) { yield testActor.eval(` content.document.getElementById("new-style").remove(); `); @@ -38,7 +38,7 @@ const TEST_DATA = [ desc: "Hiding a node by changing its style property", selector: "#display-none", before: false, - changeStyle: function*(testActor) { + changeStyle: function* (testActor) { yield testActor.eval(` let node = content.document.querySelector("#display-none"); node.style.display = "block"; @@ -50,7 +50,7 @@ const TEST_DATA = [ desc: "Showing a node by removing its hidden attribute", selector: "#hidden-true", before: false, - changeStyle: function*(testActor) { + changeStyle: function* (testActor) { yield testActor.eval(` content.document.querySelector("#hidden-true") .removeAttribute("hidden"); @@ -62,7 +62,7 @@ const TEST_DATA = [ desc: "Hiding a node by adding a hidden attribute", selector: "#hidden-true", before: true, - changeStyle: function*(testActor) { + changeStyle: function* (testActor) { yield testActor.setAttribute("#hidden-true", "hidden", "true"); }, after: false @@ -71,7 +71,7 @@ const TEST_DATA = [ desc: "Showing a node by changin a stylesheet's rule", selector: "#hidden-via-stylesheet", before: false, - changeStyle: function*(testActor) { + changeStyle: function* (testActor) { yield testActor.eval(` content.document.styleSheets[0] .cssRules[0].style @@ -84,7 +84,7 @@ const TEST_DATA = [ desc: "Hiding a node by adding a new rule to a stylesheet", selector: "#hidden-via-stylesheet", before: true, - changeStyle: function*(testActor) { + changeStyle: function* (testActor) { yield testActor.eval(` content.document.styleSheets[0].insertRule( "#hidden-via-stylesheet {display: none;}", 1); @@ -96,7 +96,7 @@ const TEST_DATA = [ desc: "Hiding a node by adding a class that matches an existing rule", selector: "#normal-div", before: true, - changeStyle: function*(testActor) { + changeStyle: function* (testActor) { yield testActor.eval(` content.document.styleSheets[0].insertRule( ".a-new-class {display: none;}", 2); @@ -108,7 +108,7 @@ const TEST_DATA = [ } ]; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); for (let data of TEST_DATA) { diff --git a/devtools/client/inspector/markup/test/browser_markup_pagesize_01.js b/devtools/client/inspector/markup/test/browser_markup_pagesize_01.js index dd3a1311fe3f..a9ba9fc050f5 100644 --- a/devtools/client/inspector/markup/test/browser_markup_pagesize_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_pagesize_01.js @@ -37,7 +37,7 @@ const TEST_DATA = [{ expected: "*more*uvwxy*more*" }]; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); info("Start iterating through the test data"); diff --git a/devtools/client/inspector/markup/test/browser_markup_pagesize_02.js b/devtools/client/inspector/markup/test/browser_markup_pagesize_02.js index 3eecc38efaff..549a36b0dbee 100644 --- a/devtools/client/inspector/markup/test/browser_markup_pagesize_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_pagesize_02.js @@ -13,7 +13,7 @@ const TEST_URL = URL_ROOT + "doc_markup_pagesize_02.html"; // Make sure nodes are hidden when there are more than 5 in a row Services.prefs.setIntPref("devtools.markup.pagesize", 5); -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); info("Selecting the UL node"); diff --git a/devtools/client/inspector/markup/test/browser_markup_remove_xul_attributes.js b/devtools/client/inspector/markup/test/browser_markup_remove_xul_attributes.js index a76eae81fae4..7d6d034e3721 100644 --- a/devtools/client/inspector/markup/test/browser_markup_remove_xul_attributes.js +++ b/devtools/client/inspector/markup/test/browser_markup_remove_xul_attributes.js @@ -9,7 +9,7 @@ const TEST_URL = URL_ROOT + "doc_markup_xul.xul"; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); let panelFront = yield getNodeFront("#test", inspector); diff --git a/devtools/client/inspector/markup/test/browser_markup_search_01.js b/devtools/client/inspector/markup/test/browser_markup_search_01.js index 4a501813151d..68f0c04db625 100644 --- a/devtools/client/inspector/markup/test/browser_markup_search_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_search_01.js @@ -10,7 +10,7 @@ const TEST_URL = URL_ROOT + "doc_markup_search.html"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); let container = yield getContainerForSelector("em", inspector); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_01.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_01.js index cbd1c2c8c466..b1b4f7115bbb 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_01.js @@ -62,7 +62,7 @@ var TEST_DATA = [{ } }]; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); yield runEditAttributesTests(TEST_DATA, inspector, testActor); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_02.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_02.js index 27eb407ca919..f6f89bcb9283 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_02.js @@ -9,7 +9,7 @@ const TEST_URL = `data:text/html,
Test modifying my ID attribute
`; -add_task(function*() { +add_task(function* () { info("Opening the inspector on the test page"); let {inspector, testActor} = yield openInspectorForURL(TEST_URL); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_03.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_03.js index 3ea5026010f1..058fd80c7f7d 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_03.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_03.js @@ -9,7 +9,7 @@ const TEST_URL = `data:text/html;charset=utf-8,
`; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); yield inspector.markup.expandAll(); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_04.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_04.js index 2b0019981dda..5337f74c9d00 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_04.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_04.js @@ -48,7 +48,7 @@ const TEST_DATA = [{ key: "back_space", focusedSelector: "#second" }, { - setup: function*(inspector, testActor) { + setup: function* (inspector, testActor) { // Removing the siblings of #first in order to test with an only child. let mutated = inspector.once("markupmutation"); yield testActor.eval(` @@ -67,7 +67,7 @@ const TEST_DATA = [{ focusedSelector: "#parent" }]; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); for (let {setup, selector, key, focusedSelector} of TEST_DATA) { diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_05.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_05.js index 8001989c1a8d..54a1dab44a1d 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_05.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_05.js @@ -71,7 +71,7 @@ var TEST_DATA = [{ } }]; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); yield runAddAttributesTests(TEST_DATA, "div", inspector, testActor); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_06.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_06.js index 026ff2c06a9c..8202bd0a29ac 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_06.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_06.js @@ -79,7 +79,7 @@ var TEST_DATA = [{ } }]; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); yield runAddAttributesTests(TEST_DATA, "div", inspector, testActor); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_07.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_07.js index bff8f96fa839..8de15a76f37a 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_07.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_07.js @@ -128,7 +128,7 @@ var TEST_DATA = [{ } }]; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); yield runAddAttributesTests(TEST_DATA, "div", inspector, testActor); }); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_08.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_08.js index b8e3a93ec4ed..9c8a4f96be4d 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_08.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_08.js @@ -13,7 +13,7 @@ const LONG_ATTRIBUTE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-AB const LONG_ATTRIBUTE_COLLAPSED = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEF\u2026UVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /*eslint-enable */ -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); yield inspector.markup.expandAll(); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_09.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_09.js index bebb2c55f0c0..c34f85f36bb1 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_09.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_09.js @@ -8,7 +8,7 @@ const TEST_URL = URL_ROOT + "doc_markup_svg_attributes.html"; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); yield inspector.markup.expandAll(); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_10.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_10.js index 6994afca985e..728a71d2e7a2 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_10.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_10.js @@ -8,7 +8,7 @@ const TEST_URL = "data:text/html;charset=utf-8,
"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); yield inspector.markup.expandAll(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_11.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_11.js index 015b10243e7f..56f741851ceb 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_11.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_11.js @@ -9,7 +9,7 @@ const TEST_URL = "data:text/html;charset=utf-8,
"; -add_task(function*() { +add_task(function* () { let isEditTagNameCalled = false; let {inspector} = yield openInspectorForURL(TEST_URL); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_12.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_12.js index d8f07a9f9c53..5f746a7cd90c 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_12.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_12.js @@ -11,7 +11,7 @@ const TEST_URL = "data:text/html;charset=utf8," + "
" + "
"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); yield testAttributeEditing(inspector); diff --git a/devtools/client/inspector/markup/test/browser_markup_tag_edit_13-other.js b/devtools/client/inspector/markup/test/browser_markup_tag_edit_13-other.js index 5c27620d99d2..188e12cbc42a 100644 --- a/devtools/client/inspector/markup/test/browser_markup_tag_edit_13-other.js +++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_13-other.js @@ -9,7 +9,7 @@ const TEST_URL = `data:text/html;charset=utf8,
`; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); yield testOriginalAttributesOrder(inspector); diff --git a/devtools/client/inspector/markup/test/browser_markup_textcontent_edit_01.js b/devtools/client/inspector/markup/test/browser_markup_textcontent_edit_01.js index b75931d3f1c4..adbe4d606d50 100644 --- a/devtools/client/inspector/markup/test/browser_markup_textcontent_edit_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_textcontent_edit_01.js @@ -8,7 +8,7 @@ const TEST_URL = URL_ROOT + "doc_markup_edit.html"; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); info("Expanding all nodes"); diff --git a/devtools/client/inspector/markup/test/browser_markup_textcontent_edit_02.js b/devtools/client/inspector/markup/test/browser_markup_textcontent_edit_02.js index c58c828dfebb..c55ab59c6e17 100644 --- a/devtools/client/inspector/markup/test/browser_markup_textcontent_edit_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_textcontent_edit_02.js @@ -10,7 +10,7 @@ const TEST_URL = URL_ROOT + "doc_markup_edit.html"; const SELECTOR = ".node6"; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); info("Expanding all nodes"); diff --git a/devtools/client/inspector/markup/test/browser_markup_toggle_01.js b/devtools/client/inspector/markup/test/browser_markup_toggle_01.js index 373e37ec3548..a481f685e81b 100644 --- a/devtools/client/inspector/markup/test/browser_markup_toggle_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_toggle_01.js @@ -8,7 +8,7 @@ const TEST_URL = URL_ROOT + "doc_markup_toggle.html"; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); info("Getting the container for the html element"); diff --git a/devtools/client/inspector/markup/test/browser_markup_toggle_02.js b/devtools/client/inspector/markup/test/browser_markup_toggle_02.js index 34ea719adafd..481f0bf58bd2 100644 --- a/devtools/client/inspector/markup/test/browser_markup_toggle_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_toggle_02.js @@ -8,7 +8,7 @@ const TEST_URL = URL_ROOT + "doc_markup_toggle.html"; -add_task(function*() { +add_task(function* () { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); info("Getting the container for the UL parent element"); diff --git a/devtools/client/inspector/markup/test/browser_markup_toggle_03.js b/devtools/client/inspector/markup/test/browser_markup_toggle_03.js index e1c34c40a27d..fb3529c8e0d0 100644 --- a/devtools/client/inspector/markup/test/browser_markup_toggle_03.js +++ b/devtools/client/inspector/markup/test/browser_markup_toggle_03.js @@ -9,7 +9,7 @@ const TEST_URL = URL_ROOT + "doc_markup_toggle.html"; -add_task(function*() { +add_task(function* () { let {inspector} = yield openInspectorForURL(TEST_URL); info("Getting the container for the UL parent element"); diff --git a/devtools/client/inspector/markup/test/head.js b/devtools/client/inspector/markup/test/head.js index 6eb2ed386c17..3f7aa5820991 100644 --- a/devtools/client/inspector/markup/test/head.js +++ b/devtools/client/inspector/markup/test/head.js @@ -20,7 +20,9 @@ SimpleTest.requestCompleteLog(); // Set the testing flag on DevToolsUtils and reset it when the test ends DevToolsUtils.testing = true; -registerCleanupFunction(() => DevToolsUtils.testing = false); +registerCleanupFunction(() => { + DevToolsUtils.testing = false; +}); // Clear preferences that may be set during the course of tests. registerCleanupFunction(() => { @@ -79,7 +81,7 @@ function getContainerForNodeFront(nodeFront, {markup}) { * loaded in the toolbox * @return {MarkupContainer} */ -var getContainerForSelector = Task.async(function*(selector, inspector) { +var getContainerForSelector = Task.async(function* (selector, inspector) { info("Getting the markup-container for node " + selector); let nodeFront = yield getNodeFront(selector, inspector); let container = getContainerForNodeFront(nodeFront, inspector); @@ -112,7 +114,7 @@ function waitForChildrenUpdated({markup}) { * loaded in the toolbox * @return {Promise} Resolves when the node has been selected. */ -var clickContainer = Task.async(function*(selector, inspector) { +var clickContainer = Task.async(function* (selector, inspector) { info("Clicking on the markup-container for node " + selector); let nodeFront = yield getNodeFront(selector, inspector); @@ -155,7 +157,7 @@ function setEditableFieldValue(field, value, inspector) { * loaded in the toolbox * @return a promise that resolves when the node has mutated */ -var addNewAttributes = Task.async(function*(selector, text, inspector) { +var addNewAttributes = Task.async(function* (selector, text, inspector) { info(`Entering text "${text}" in new attribute field for node ${selector}`); let container = yield getContainerForSelector(selector, inspector); @@ -178,7 +180,7 @@ var addNewAttributes = Task.async(function*(selector, text, inspector) { * Note that node.getAttribute() returns attribute values provided by the HTML * parser. The parser only provides unescaped entities so & will return &. */ -var assertAttributes = Task.async(function*(selector, expected, testActor) { +var assertAttributes = Task.async(function* (selector, expected, testActor) { let {attributes: actual} = yield testActor.getNodeInfo(selector); is(actual.length, Object.keys(expected).length, @@ -277,7 +279,7 @@ function wait(ms) { * the menu items are disabled once the menu has been checked. */ var isEditingMenuDisabled = Task.async( -function*(nodeFront, inspector, assert = true) { +function* (nodeFront, inspector, assert = true) { let doc = inspector.panelDoc; let deleteMenuItem = doc.getElementById("node-menu-delete"); let editHTMLMenuItem = doc.getElementById("node-menu-edithtml"); @@ -315,7 +317,7 @@ function*(nodeFront, inspector, assert = true) { * the menu items are enabled once the menu has been checked. */ var isEditingMenuEnabled = Task.async( -function*(nodeFront, inspector, assert = true) { +function* (nodeFront, inspector, assert = true) { let doc = inspector.panelDoc; let deleteMenuItem = doc.getElementById("node-menu-delete"); let editHTMLMenuItem = doc.getElementById("node-menu-edithtml"); @@ -348,7 +350,7 @@ function*(nodeFront, inspector, assert = true) { * @param {DOMNode} menu A menu that implements hidePopup/openPopup * @return a promise that resolves once the menu is opened. */ -var reopenMenu = Task.async(function*(menu) { +var reopenMenu = Task.async(function* (menu) { // First close it is if it is already opened. if (menu.state == "closing" || menu.state == "open") { let popuphidden = once(menu, "popuphidden", true); @@ -422,7 +424,7 @@ function checkFocusedAttribute(attrName, editMode) { * A promise that resolves with an array of attribute names * (e.g. ["id", "class", "href"]) */ -var getAttributesFromEditor = Task.async(function*(selector, inspector) { +var getAttributesFromEditor = Task.async(function* (selector, inspector) { let nodeList = (yield getContainerForSelector(selector, inspector)) .tagLine.querySelectorAll("[data-attr]"); @@ -440,6 +442,7 @@ function* waitForMultipleChildrenUpdates(inspector) { yield waitForChildrenUpdated(inspector); return yield waitForMultipleChildrenUpdates(inspector); } + return undefined; } /** diff --git a/devtools/client/inspector/markup/test/helper_attributes_test_runner.js b/devtools/client/inspector/markup/test/helper_attributes_test_runner.js index 9f01620905ce..4a49d5ea66cb 100644 --- a/devtools/client/inspector/markup/test/helper_attributes_test_runner.js +++ b/devtools/client/inspector/markup/test/helper_attributes_test_runner.js @@ -23,7 +23,7 @@ */ function runAddAttributesTests(tests, nodeOrSelector, inspector, testActor) { info("Running " + tests.length + " add-attributes tests"); - return Task.spawn(function*() { + return Task.spawn(function* () { info("Selecting the test node"); yield selectNode("div", inspector); @@ -96,7 +96,7 @@ function* runAddAttributesTest(test, selector, inspector, testActor) { */ function runEditAttributesTests(tests, inspector, testActor) { info("Running " + tests.length + " edit-attributes tests"); - return Task.spawn(function*() { + return Task.spawn(function* () { info("Expanding all nodes in the markup-view"); yield inspector.markup.expandAll(); diff --git a/devtools/client/inspector/rules/models/element-style.js b/devtools/client/inspector/rules/models/element-style.js index fed8eee44f7a..395d548558be 100644 --- a/devtools/client/inspector/rules/models/element-style.js +++ b/devtools/client/inspector/rules/models/element-style.js @@ -130,6 +130,8 @@ ElementStyle.prototype = { r.editor.destroy(); } } + + return undefined; }).then(null, e => { // populate is often called after a setTimeout, // the connection may already be closed. diff --git a/devtools/client/inspector/rules/rules.js b/devtools/client/inspector/rules/rules.js index 1cb1e7e6a35b..0328562df3a9 100644 --- a/devtools/client/inspector/rules/rules.js +++ b/devtools/client/inspector/rules/rules.js @@ -261,7 +261,7 @@ CssRuleView.prototype = { * * @return {Promise} Resolves to the instance of the highlighter. */ - getSelectorHighlighter: Task.async(function*() { + getSelectorHighlighter: Task.async(function* () { let utils = this.inspector.toolbox.highlighterUtils; if (!utils.supportsCustomHighlighters()) { return null; @@ -319,7 +319,7 @@ CssRuleView.prototype = { }, Cu.reportError); }, - highlightSelector: Task.async(function*(selector) { + highlightSelector: Task.async(function* (selector) { let node = this.inspector.selection.nodeFront; let highlighter = yield this.getSelectorHighlighter(); @@ -334,7 +334,7 @@ CssRuleView.prototype = { }); }), - unhighlightSelector: Task.async(function*() { + unhighlightSelector: Task.async(function* () { let highlighter = yield this.getSelectorHighlighter(); if (!highlighter) { return; @@ -874,6 +874,7 @@ CssRuleView.prototype = { if (this._elementStyle === elementStyle) { return this._populate(); } + return undefined; }).then(() => { if (this._elementStyle === elementStyle) { if (!refresh) { diff --git a/devtools/client/inspector/rules/test/browser_rules_add-property-and-reselect.js b/devtools/client/inspector/rules/test/browser_rules_add-property-and-reselect.js index 39218018fdf1..90662e41a04c 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-property-and-reselect.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-property-and-reselect.js @@ -9,7 +9,7 @@ const TEST_URI = URL_ROOT + "doc_content_stylesheet.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); yield selectNode("#target", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_01.js b/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_01.js index dd0b5cb77eff..c6ceab4fe5da 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_01.js @@ -18,7 +18,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_02.js b/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_02.js index 6412ca4a7ce1..58d22d07cea2 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_02.js @@ -15,7 +15,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_03.js b/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_03.js index c74121c431f1..9cb9dc2759f7 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_03.js @@ -16,7 +16,7 @@ const TEST_URI = `
Test node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-property-commented.js b/devtools/client/inspector/rules/test/browser_rules_add-property-commented.js index 6b847f85f7d7..eacf5db5a774 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-property-commented.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-property-commented.js @@ -8,7 +8,7 @@ const TEST_URI = "
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-property-svg.js b/devtools/client/inspector/rules/test/browser_rules_add-property-svg.js index a040be2cf552..a53421db3aef 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-property-svg.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-property-svg.js @@ -9,7 +9,7 @@ var TEST_URL = "chrome://global/skin/icons/warning.svg"; var TEST_SELECTOR = "path"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URL); let {inspector, view} = yield openRuleView(); yield selectNode(TEST_SELECTOR, inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-property_01.js b/devtools/client/inspector/rules/test/browser_rules_add-property_01.js index 56ad39c8264b..1d7068d54af8 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-property_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-property_01.js @@ -18,7 +18,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-property_02.js b/devtools/client/inspector/rules/test/browser_rules_add-property_02.js index 115839d306ad..b8fdc2c26d2e 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-property_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-property_02.js @@ -19,7 +19,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-rule_01.js b/devtools/client/inspector/rules/test/browser_rules_add-rule_01.js index 0d2666ecdb0d..d8646823ca6f 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-rule_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-rule_01.js @@ -32,7 +32,7 @@ const TEST_DATA = [ { node: "h2", expected: "#asd\\@\\@\\@a\\!\\!2a" } ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view, testActor} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-rule_02.js b/devtools/client/inspector/rules/test/browser_rules_add-rule_02.js index ba2d023ddf4a..b59f317a5bb5 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-rule_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-rule_02.js @@ -17,7 +17,7 @@ const TEST_URI = ` This is a span `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-rule_03.js b/devtools/client/inspector/rules/test/browser_rules_add-rule_03.js index 12958de6f5fc..54be0adcc4ca 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-rule_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-rule_03.js @@ -17,7 +17,7 @@ const TEST_URI = ` This is a span `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-rule_04.js b/devtools/client/inspector/rules/test/browser_rules_add-rule_04.js index 09767562ff38..1441213b3543 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-rule_04.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-rule_04.js @@ -17,7 +17,7 @@ const TEST_URI = `
Test Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield testDisabledButton(inspector, view); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-rule_05.js b/devtools/client/inspector/rules/test/browser_rules_add-rule_05.js index ef8437431cda..a9acd25add6b 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-rule_05.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-rule_05.js @@ -32,7 +32,7 @@ const TEST_DATA = [ { node: "h2", expected: "#asd\\@\\@\\@a\\!\\!2a" } ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view, testActor} = yield openRuleView(); @@ -59,12 +59,11 @@ function* addNewRuleFromContextMenu(inspector, view) { ok(!view._contextmenu.menuitemAddRule.hidden, "Add rule is visible"); - info("Adding the new rule"); + info("Adding the new rule and expecting a ruleview-changed event"); + let onRuleViewChanged = view.once("ruleview-changed"); view._contextmenu.menuitemAddRule.click(); view._contextmenu._menupopup.hidePopup(); - - info("Waiting for rule view to change"); - yield view.once("ruleview-changed"); + yield onRuleViewChanged; } function* testNewRule(view, expected, index) { diff --git a/devtools/client/inspector/rules/test/browser_rules_add-rule_pseudo_class.js b/devtools/client/inspector/rules/test/browser_rules_add-rule_pseudo_class.js index 2b64aabcc76e..30847982fb2a 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-rule_pseudo_class.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-rule_pseudo_class.js @@ -19,7 +19,7 @@ const TEST_DATA = [ [":focus"] ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#element", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_colorUnit.js b/devtools/client/inspector/rules/test/browser_rules_colorUnit.js index a6aedf40a87a..3ff6495e222e 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorUnit.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorUnit.js @@ -15,7 +15,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { let TESTS = [ {name: "hex", result: "#0f0"}, {name: "rgb", result: "rgb(0, 255, 0)"} diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_01.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_01.js index 7aff3faec0b8..9d312f1b764d 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_01.js @@ -17,7 +17,7 @@ const TEST_URI = ` Testing the color picker tooltip! `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); let value = getRuleViewProperty(view, "body", "background").valueSpan; diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_02.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_02.js index cef2646c1fa6..684c8be33115 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_02.js @@ -20,7 +20,7 @@ const TEST_URI = ` Testing the color picker tooltip! `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); yield testColorChangeIsntRevertedWhenOtherTooltipIsShown(view); diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-appears-on-swatch-click.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-appears-on-swatch-click.js index 1c0eb15bb3fb..311b45d02b94 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-appears-on-swatch-click.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-appears-on-swatch-click.js @@ -18,7 +18,7 @@ const TEST_URI = ` Testing the color picker tooltip! `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js index 788d7dd1e561..6fbf87ec91fd 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js @@ -16,7 +16,7 @@ const TEST_URI = ` Testing the color picker tooltip! `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-edit-gradient.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-edit-gradient.js index 8df35dfe7819..b8c89ccdf648 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-edit-gradient.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-edit-gradient.js @@ -16,7 +16,7 @@ const TEST_URI = ` Updating a gradient declaration with the color picker tooltip `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-hides-on-tooltip.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-hides-on-tooltip.js index f4845acfb635..6facb94381aa 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-hides-on-tooltip.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-hides-on-tooltip.js @@ -18,7 +18,7 @@ const TEST_URI = ` Testing the color picker tooltip! `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-multiple-changes.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-multiple-changes.js index 3dd5dcedf20c..5546cbb7c3d8 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-multiple-changes.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-multiple-changes.js @@ -25,7 +25,7 @@ const TEST_URI = `

Testing the color picker tooltip!

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-release-outside-frame.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-release-outside-frame.js index 7d5e98de8f12..0fbe7e2d984f 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-release-outside-frame.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-release-outside-frame.js @@ -9,7 +9,7 @@ const TEST_URI = "Test page for bug 1160720"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-revert-on-ESC.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-revert-on-ESC.js index 3649bbbee9f7..66910492cf92 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-revert-on-ESC.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-revert-on-ESC.js @@ -15,7 +15,7 @@ const TEST_URI = ` `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); yield testPressingEscapeRevertsChanges(view); diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-swatch-displayed.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-swatch-displayed.js index 98296ad33565..d05ddd46eb2c 100644 --- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-swatch-displayed.js +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-swatch-displayed.js @@ -37,7 +37,7 @@ const TESTS = [ {selector: "*", propertyName: "box-shadow", nb: 2}, ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_01.js b/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_01.js index 1b11ba9346ed..c650c57603ea 100644 --- a/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_01.js @@ -55,7 +55,7 @@ var testData = [ const TEST_URI = "

Header

"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view, testActor} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_02.js b/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_02.js index 776bbf2c0f9d..bbcf461fd393 100644 --- a/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_02.js @@ -37,7 +37,7 @@ var testData = [ const TEST_URI = "

Header

"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view, testActor} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_01.js b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_01.js index 2c86241b1d0b..59feb9f4a673 100644 --- a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_01.js @@ -38,7 +38,7 @@ var testData = [ const TEST_URI = "

Header

"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view, testActor} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_02.js b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_02.js index 6eb1f24b6d3c..2b4193bd970b 100644 --- a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_02.js @@ -48,7 +48,7 @@ const TEST_URI = `

Test element

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view, testActor} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_03.js b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_03.js index 678f13d2950b..77d72e16d42a 100644 --- a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_03.js @@ -9,7 +9,7 @@ const TEST_URI = "

Header

"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_04.js b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_04.js index 76a8d6149746..5f283ae53bfa 100644 --- a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_04.js +++ b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_04.js @@ -13,7 +13,7 @@ const TEST_URI = "" + "

Header

"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let { inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_multiline.js b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_multiline.js index 4eafc9c75f4a..8b71f31a60e0 100644 --- a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_multiline.js +++ b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_multiline.js @@ -27,7 +27,7 @@ const TEST_URI =

Header

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let { inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_completion-popup-hidden-after-navigation.js b/devtools/client/inspector/rules/test/browser_rules_completion-popup-hidden-after-navigation.js index 548e827f954f..6e24983745e1 100644 --- a/devtools/client/inspector/rules/test/browser_rules_completion-popup-hidden-after-navigation.js +++ b/devtools/client/inspector/rules/test/browser_rules_completion-popup-hidden-after-navigation.js @@ -8,7 +8,7 @@ const TEST_URI = "

"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view, testActor} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_computed-lists_01.js b/devtools/client/inspector/rules/test/browser_rules_computed-lists_01.js index 6214e665d4f2..5acebd562fb2 100644 --- a/devtools/client/inspector/rules/test/browser_rules_computed-lists_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_computed-lists_01.js @@ -16,7 +16,7 @@ var TEST_URI = `

Styled Node

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_computed-lists_02.js b/devtools/client/inspector/rules/test/browser_rules_computed-lists_02.js index abf8a62ffaee..d6dc82d5fb10 100644 --- a/devtools/client/inspector/rules/test/browser_rules_computed-lists_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_computed-lists_02.js @@ -17,7 +17,7 @@ var TEST_URI = `

Styled Node

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_content_01.js b/devtools/client/inspector/rules/test/browser_rules_content_01.js index 3f26fb5a3bd2..305c680cf739 100644 --- a/devtools/client/inspector/rules/test/browser_rules_content_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_content_01.js @@ -21,7 +21,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_content_02.js b/devtools/client/inspector/rules/test/browser_rules_content_02.js index d1a7473d6f64..920c7709c1f1 100644 --- a/devtools/client/inspector/rules/test/browser_rules_content_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_content_02.js @@ -20,7 +20,7 @@ const CONTENT = ` const STRINGS = Services.strings .createBundle("chrome://devtools-shared/locale/styleinspector.properties"); -add_task(function*() { +add_task(function* () { let tab = yield addTab("data:text/html;charset=utf-8," + CONTENT); let testActor = yield getTestActorWithoutToolbox(tab); diff --git a/devtools/client/inspector/rules/test/browser_rules_copy_styles.js b/devtools/client/inspector/rules/test/browser_rules_copy_styles.js index d2a9f078901f..150c99ffd03f 100644 --- a/devtools/client/inspector/rules/test/browser_rules_copy_styles.js +++ b/devtools/client/inspector/rules/test/browser_rules_copy_styles.js @@ -15,7 +15,7 @@ XPCOMUtils.defineLazyGetter(this, "osString", function() { const TEST_URI = URL_ROOT + "doc_copystyles.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let { inspector, view } = yield openRuleView(); let contextmenu = view._contextmenu; @@ -144,7 +144,7 @@ add_task(function*() { } }, { - setup: function*() { + setup: function* () { yield disableProperty(view, 0); }, desc: "Test Copy Rule with Disabled Property", @@ -167,7 +167,7 @@ add_task(function*() { } }, { - setup: function*() { + setup: function* () { yield disableProperty(view, 4); }, desc: "Test Copy Rule with Disabled Property with Comment", diff --git a/devtools/client/inspector/rules/test/browser_rules_cssom.js b/devtools/client/inspector/rules/test/browser_rules_cssom.js index 004ba8976329..d20e851927a2 100644 --- a/devtools/client/inspector/rules/test/browser_rules_cssom.js +++ b/devtools/client/inspector/rules/test/browser_rules_cssom.js @@ -9,7 +9,7 @@ const TEST_URI = URL_ROOT + "doc_cssom.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); yield selectNode("#target", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_cubicbezier-appears-on-swatch-click.js b/devtools/client/inspector/rules/test/browser_rules_cubicbezier-appears-on-swatch-click.js index ab85e2a5a445..36113f8eb907 100644 --- a/devtools/client/inspector/rules/test/browser_rules_cubicbezier-appears-on-swatch-click.js +++ b/devtools/client/inspector/rules/test/browser_rules_cubicbezier-appears-on-swatch-click.js @@ -21,7 +21,7 @@ const TEST_URI = `
Testing the cubic-bezier tooltip!
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_cubicbezier-commit-on-ENTER.js b/devtools/client/inspector/rules/test/browser_rules_cubicbezier-commit-on-ENTER.js index 953a9d0b57d6..a5cc5c9f9d07 100644 --- a/devtools/client/inspector/rules/test/browser_rules_cubicbezier-commit-on-ENTER.js +++ b/devtools/client/inspector/rules/test/browser_rules_cubicbezier-commit-on-ENTER.js @@ -15,7 +15,7 @@ const TEST_URI = ` `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); @@ -39,7 +39,7 @@ function* testPressingEnterCommitsChanges(swatch, ruleView) { widget.coordinates = [0.1, 2, 0.9, -1]; let expected = "cubic-bezier(0.1, 2, 0.9, -1)"; - yield waitForSuccess(function*() { + yield waitForSuccess(function* () { let func = yield getComputedStyleProperty("body", null, "transition-timing-function"); return func === expected; diff --git a/devtools/client/inspector/rules/test/browser_rules_cubicbezier-revert-on-ESC.js b/devtools/client/inspector/rules/test/browser_rules_cubicbezier-revert-on-ESC.js index 5b8d23794dc2..48726265d102 100644 --- a/devtools/client/inspector/rules/test/browser_rules_cubicbezier-revert-on-ESC.js +++ b/devtools/client/inspector/rules/test/browser_rules_cubicbezier-revert-on-ESC.js @@ -15,7 +15,7 @@ const TEST_URI = ` `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); yield testPressingEscapeRevertsChanges(view); diff --git a/devtools/client/inspector/rules/test/browser_rules_custom.js b/devtools/client/inspector/rules/test/browser_rules_custom.js index ba048d9086a4..7c941af6f4fa 100644 --- a/devtools/client/inspector/rules/test/browser_rules_custom.js +++ b/devtools/client/inspector/rules/test/browser_rules_custom.js @@ -8,7 +8,7 @@ const TEST_URI = URL_ROOT + "doc_custom.html"; // Tests the display of custom declarations in the rule-view. -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_cycle-angle.js b/devtools/client/inspector/rules/test/browser_rules_cycle-angle.js index b6f60a163228..fa135f937ebf 100644 --- a/devtools/client/inspector/rules/test/browser_rules_cycle-angle.js +++ b/devtools/client/inspector/rules/test/browser_rules_cycle-angle.js @@ -18,7 +18,7 @@ const TEST_URI = `
Test
cycling angle units in the rule view! `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); let container = getRuleViewProperty( diff --git a/devtools/client/inspector/rules/test/browser_rules_cycle-color.js b/devtools/client/inspector/rules/test/browser_rules_cycle-color.js index d4a522f335d9..09bd7ed4ac5b 100644 --- a/devtools/client/inspector/rules/test/browser_rules_cycle-color.js +++ b/devtools/client/inspector/rules/test/browser_rules_cycle-color.js @@ -18,7 +18,7 @@ const TEST_URI = ` Test cycling color types in the rule view! `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); let container = getRuleViewProperty(view, "body", "color").valueSpan; diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property-cancel.js b/devtools/client/inspector/rules/test/browser_rules_edit-property-cancel.js index 3910ea3c650f..af1a6fbc07e0 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property-cancel.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-cancel.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property-click.js b/devtools/client/inspector/rules/test/browser_rules_edit-property-click.js index 341a343d7c70..08a5ee786b3c 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property-click.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-click.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property-commit.js b/devtools/client/inspector/rules/test/browser_rules_edit-property-commit.js index c20f8b38983f..d868e8cbe4f3 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property-commit.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-commit.js @@ -49,7 +49,7 @@ const testData = [ } ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property-computed.js b/devtools/client/inspector/rules/test/browser_rules_edit-property-computed.js index d395b78c0b64..e178a8dde92c 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property-computed.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-computed.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property-increments.js b/devtools/client/inspector/rules/test/browser_rules_edit-property-increments.js index 7c6d98a7d245..7da388ac034f 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property-increments.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-increments.js @@ -22,7 +22,7 @@ const TEST_URI = `
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property-order.js b/devtools/client/inspector/rules/test/browser_rules_edit-property-order.js index a6d43513c904..b4a86c194164 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property-order.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-order.js @@ -8,7 +8,7 @@ const TEST_URI = "
Styled Node
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_01.js b/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_01.js index 23dfee520c49..0aed2f5c8e8f 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_01.js @@ -18,7 +18,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_02.js b/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_02.js index e695f47824fe..5690e7c2d3e8 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_02.js @@ -18,7 +18,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_03.js b/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_03.js index e1074eca7eb0..21a1063c2be9 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-remove_03.js @@ -18,7 +18,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property_01.js b/devtools/client/inspector/rules/test/browser_rules_edit-property_01.js index bfd661de7af7..6f4c49e20afa 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_01.js @@ -31,7 +31,7 @@ var TEST_DATA = [ { name: "border", value: "solid 1px foo", isValid: false }, ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property_02.js b/devtools/client/inspector/rules/test/browser_rules_edit-property_02.js index 731453979f23..b45221cfd8eb 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_02.js @@ -19,7 +19,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property_03.js b/devtools/client/inspector/rules/test/browser_rules_edit-property_03.js index f9d276542cd7..a5771b41e215 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_03.js @@ -22,7 +22,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property_04.js b/devtools/client/inspector/rules/test/browser_rules_edit-property_04.js index a909a410ad0b..7460db4cd3c2 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property_04.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_04.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property_05.js b/devtools/client/inspector/rules/test/browser_rules_edit-property_05.js index fe8462139698..3d37c81d58a6 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property_05.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_05.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property_06.js b/devtools/client/inspector/rules/test/browser_rules_edit-property_06.js index 8bc94a16068c..95211f1d0b56 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property_06.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_06.js @@ -18,7 +18,7 @@ const TEST_URI = ` `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("body", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property_07.js b/devtools/client/inspector/rules/test/browser_rules_edit-property_07.js index 16f0ac32885c..40314819f589 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property_07.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_07.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property_08.js b/devtools/client/inspector/rules/test/browser_rules_edit-property_08.js index d250a7d514b5..1becd40d9c27 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property_08.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_08.js @@ -15,7 +15,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property_09.js b/devtools/client/inspector/rules/test/browser_rules_edit-property_09.js index aa10bd1143a8..51f714021c99 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property_09.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_09.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector-click-on-scrollbar.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector-click-on-scrollbar.js index c98b801a483a..2e0ed693771a 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector-click-on-scrollbar.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector-click-on-scrollbar.js @@ -34,7 +34,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { info("Toolbox height should be small enough to force scrollbars to appear"); yield new Promise(done => { let options = {"set": [ diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector-click.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector-click.js index 774e5d33ce36..9f0f2f2325ab 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector-click.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector-click.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode(".testclass", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector-commit.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector-commit.js index 7055d7f2999e..f7058371fda5 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector-commit.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector-commit.js @@ -55,7 +55,7 @@ const TEST_DATA = [ } ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let { inspector, view } = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_01.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_01.js index d1aef87dc3bd..af228094bde0 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_01.js @@ -16,7 +16,7 @@ const TEST_URI = ` This is a span `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_02.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_02.js index 600d475b5f10..503f91efaf9e 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_02.js @@ -24,7 +24,7 @@ const TEST_URI = ` const PSEUDO_PREF = "devtools.inspector.show_pseudo_elements"; -add_task(function*() { +add_task(function* () { // Expand the pseudo-elements section by default. Services.prefs.setBoolPref(PSEUDO_PREF, true); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_03.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_03.js index 57f85c30b7e2..c6834f6ee659 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_03.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode(".testclass", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_04.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_04.js index 01f2933c03cf..59f7ba9a47af 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_04.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_04.js @@ -16,7 +16,7 @@ const TEST_URI = `

Test the selector highlighter

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("p", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_05.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_05.js index a5d426973768..1a048dcd5d9b 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_05.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_05.js @@ -18,7 +18,7 @@ const TEST_URI = ` This is a span `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_06.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_06.js index 8fc6f82abcab..7d782a309f35 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_06.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_06.js @@ -18,7 +18,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode(".testclass", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_07.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_07.js index 05b9d0720933..81c7aad7205d 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_07.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_07.js @@ -22,7 +22,7 @@ const TEST_URI = ` This is a span `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_01.js b/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_01.js index fe9dc1f2bc9f..c9c7cd3d24ab 100644 --- a/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_01.js @@ -22,7 +22,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_02.js b/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_02.js index 66b03e0ae258..13ad221f0203 100644 --- a/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_02.js @@ -22,7 +22,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_eyedropper.js b/devtools/client/inspector/rules/test/browser_rules_eyedropper.js index 50d41ca6bde0..c3c35b9e76eb 100644 --- a/devtools/client/inspector/rules/test/browser_rules_eyedropper.js +++ b/devtools/client/inspector/rules/test/browser_rules_eyedropper.js @@ -46,7 +46,7 @@ const EXPECTED_COLOR = "rgb(255, 255, 85)"; // Test opening the eyedropper from the color picker. Pressing escape // to close it, and clicking the page to select a color. -add_task(function*() { +add_task(function* () { // clear telemetry so we can get accurate counts clearTelemetry(); diff --git a/devtools/client/inspector/rules/test/browser_rules_filtereditor-appears-on-swatch-click.js b/devtools/client/inspector/rules/test/browser_rules_filtereditor-appears-on-swatch-click.js index 9b56f82a5625..d15a84221640 100644 --- a/devtools/client/inspector/rules/test/browser_rules_filtereditor-appears-on-swatch-click.js +++ b/devtools/client/inspector/rules/test/browser_rules_filtereditor-appears-on-swatch-click.js @@ -7,7 +7,7 @@ const TEST_URL = URL_ROOT + "doc_filter.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URL); let {view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_filtereditor-commit-on-ENTER.js b/devtools/client/inspector/rules/test/browser_rules_filtereditor-commit-on-ENTER.js index 49df3b0b1ff4..ef2e4bf4574e 100644 --- a/devtools/client/inspector/rules/test/browser_rules_filtereditor-commit-on-ENTER.js +++ b/devtools/client/inspector/rules/test/browser_rules_filtereditor-commit-on-ENTER.js @@ -7,7 +7,7 @@ const TEST_URL = URL_ROOT + "doc_filter.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URL); let {view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_filtereditor-revert-on-ESC.js b/devtools/client/inspector/rules/test/browser_rules_filtereditor-revert-on-ESC.js index 5045aceff2f2..0d1d6b59da3f 100644 --- a/devtools/client/inspector/rules/test/browser_rules_filtereditor-revert-on-ESC.js +++ b/devtools/client/inspector/rules/test/browser_rules_filtereditor-revert-on-ESC.js @@ -8,7 +8,7 @@ const TEST_URL = URL_ROOT + "doc_filter.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URL); let {view} = yield openRuleView(); yield testPressingEscapeRevertsChanges(view); diff --git a/devtools/client/inspector/rules/test/browser_rules_guessIndentation.js b/devtools/client/inspector/rules/test/browser_rules_guessIndentation.js index b65cbbf2418d..ba2a1d7fb45c 100644 --- a/devtools/client/inspector/rules/test/browser_rules_guessIndentation.js +++ b/devtools/client/inspector/rules/test/browser_rules_guessIndentation.js @@ -30,7 +30,7 @@ div { } `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_inherited-properties_01.js b/devtools/client/inspector/rules/test/browser_rules_inherited-properties_01.js index f4af8543c974..d1f6d7f45b54 100644 --- a/devtools/client/inspector/rules/test/browser_rules_inherited-properties_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_inherited-properties_01.js @@ -17,7 +17,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#test1", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_inherited-properties_02.js b/devtools/client/inspector/rules/test/browser_rules_inherited-properties_02.js index fcf803c1bfdc..db9662eeedaa 100644 --- a/devtools/client/inspector/rules/test/browser_rules_inherited-properties_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_inherited-properties_02.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#test1", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_inherited-properties_03.js b/devtools/client/inspector/rules/test/browser_rules_inherited-properties_03.js index e274749cbe84..c6ad9b73dc14 100644 --- a/devtools/client/inspector/rules/test/browser_rules_inherited-properties_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_inherited-properties_03.js @@ -14,7 +14,7 @@ const TEST_URI = ` `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#test1", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_inline-source-map.js b/devtools/client/inspector/rules/test/browser_rules_inline-source-map.js index ae941a6d4d95..05109d8c6b4b 100644 --- a/devtools/client/inspector/rules/test/browser_rules_inline-source-map.js +++ b/devtools/client/inspector/rules/test/browser_rules_inline-source-map.js @@ -11,7 +11,7 @@ const TESTCASE_URI = URL_ROOT + "doc_inline_sourcemap.html"; const PREF = "devtools.styleeditor.source-maps-enabled"; -add_task(function*() { +add_task(function* () { Services.prefs.setBoolPref(PREF, true); yield addTab(TESTCASE_URI); diff --git a/devtools/client/inspector/rules/test/browser_rules_invalid-source-map.js b/devtools/client/inspector/rules/test/browser_rules_invalid-source-map.js index 1a796556ccde..391ce811cd8b 100644 --- a/devtools/client/inspector/rules/test/browser_rules_invalid-source-map.js +++ b/devtools/client/inspector/rules/test/browser_rules_invalid-source-map.js @@ -11,7 +11,7 @@ const TESTCASE_URI = URL_ROOT + "doc_invalid_sourcemap.html"; const PREF = "devtools.styleeditor.source-maps-enabled"; const CSS_LOC = "doc_invalid_sourcemap.css:1"; -add_task(function*() { +add_task(function* () { Services.prefs.setBoolPref(PREF, true); yield addTab(TESTCASE_URI); diff --git a/devtools/client/inspector/rules/test/browser_rules_keybindings.js b/devtools/client/inspector/rules/test/browser_rules_keybindings.js index 3f2dbcd335a6..6f075e50b170 100644 --- a/devtools/client/inspector/rules/test/browser_rules_keybindings.js +++ b/devtools/client/inspector/rules/test/browser_rules_keybindings.js @@ -7,7 +7,7 @@ // Test that focus doesn't leave the style editor when adding a property // (bug 719916) -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8,

Some header text

"); let {inspector, view} = yield openRuleView(); yield selectNode("h1", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_keyframeLineNumbers.js b/devtools/client/inspector/rules/test/browser_rules_keyframeLineNumbers.js index 80eaf1c0eb0d..ebbde08aca6e 100644 --- a/devtools/client/inspector/rules/test/browser_rules_keyframeLineNumbers.js +++ b/devtools/client/inspector/rules/test/browser_rules_keyframeLineNumbers.js @@ -9,7 +9,7 @@ const TESTCASE_URI = URL_ROOT + "doc_keyframeLineNumbers.html"; -add_task(function*() { +add_task(function* () { yield addTab(TESTCASE_URI); let { inspector, view } = yield openRuleView(); yield selectNode("#outer", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_keyframes-rule_01.js b/devtools/client/inspector/rules/test/browser_rules_keyframes-rule_01.js index 308a8ee58139..8d4b436c54e4 100644 --- a/devtools/client/inspector/rules/test/browser_rules_keyframes-rule_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_keyframes-rule_01.js @@ -9,7 +9,7 @@ const TEST_URI = URL_ROOT + "doc_keyframeanimation.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); yield testPacman(inspector, view); diff --git a/devtools/client/inspector/rules/test/browser_rules_keyframes-rule_02.js b/devtools/client/inspector/rules/test/browser_rules_keyframes-rule_02.js index 7dce4cd2dd86..cb5bb0a6a6cd 100644 --- a/devtools/client/inspector/rules/test/browser_rules_keyframes-rule_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_keyframes-rule_02.js @@ -9,7 +9,7 @@ const TEST_URI = URL_ROOT + "doc_keyframeanimation.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); yield testPacman(inspector, view); diff --git a/devtools/client/inspector/rules/test/browser_rules_lineNumbers.js b/devtools/client/inspector/rules/test/browser_rules_lineNumbers.js index 43de0d893562..3b09209f53b4 100644 --- a/devtools/client/inspector/rules/test/browser_rules_lineNumbers.js +++ b/devtools/client/inspector/rules/test/browser_rules_lineNumbers.js @@ -9,7 +9,7 @@ const TESTCASE_URI = URL_ROOT + "doc_ruleLineNumbers.html"; -add_task(function*() { +add_task(function* () { yield addTab(TESTCASE_URI); let { inspector, view } = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_livepreview.js b/devtools/client/inspector/rules/test/browser_rules_livepreview.js index b09dc80bd408..778d285b83c6 100644 --- a/devtools/client/inspector/rules/test/browser_rules_livepreview.js +++ b/devtools/client/inspector/rules/test/browser_rules_livepreview.js @@ -31,7 +31,7 @@ const TEST_DATA = [ {escape: true, value: "inline", expected: "block"} ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_01.js b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_01.js index 0d710d604b19..ab10fadfe9d9 100644 --- a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_01.js @@ -19,7 +19,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_02.js b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_02.js index 108ea61daf4f..c71fc7211e90 100644 --- a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_02.js @@ -19,7 +19,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_03.js b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_03.js index 9e39f8540637..b99bab8b49cd 100644 --- a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_03.js @@ -19,7 +19,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_04.js b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_04.js index 3372baa11b09..fbce1ebf43b8 100644 --- a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_04.js +++ b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_04.js @@ -19,7 +19,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_05.js b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_05.js index 8fc1d221fec9..11ecd72ff424 100644 --- a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_05.js +++ b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_05.js @@ -16,7 +16,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_06.js b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_06.js index a8f6f4c7be32..c2e71fe49d95 100644 --- a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_06.js +++ b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_06.js @@ -17,7 +17,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_07.js b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_07.js index 3f1a92bccbd3..9480ddd4738e 100644 --- a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_07.js +++ b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_07.js @@ -34,7 +34,7 @@ const TEST_URI = ` `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_mathml-element.js b/devtools/client/inspector/rules/test/browser_rules_mathml-element.js index 081a10ba289b..f8a1e857210e 100644 --- a/devtools/client/inspector/rules/test/browser_rules_mathml-element.js +++ b/devtools/client/inspector/rules/test/browser_rules_mathml-element.js @@ -24,7 +24,7 @@ const TEST_URI = ` `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_media-queries.js b/devtools/client/inspector/rules/test/browser_rules_media-queries.js index 77a4670a7009..a016deca024e 100644 --- a/devtools/client/inspector/rules/test/browser_rules_media-queries.js +++ b/devtools/client/inspector/rules/test/browser_rules_media-queries.js @@ -9,7 +9,7 @@ const TEST_URI = URL_ROOT + "doc_media_queries.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_multiple-properties-duplicates.js b/devtools/client/inspector/rules/test/browser_rules_multiple-properties-duplicates.js index 49312a692ca0..c820dd73f998 100644 --- a/devtools/client/inspector/rules/test/browser_rules_multiple-properties-duplicates.js +++ b/devtools/client/inspector/rules/test/browser_rules_multiple-properties-duplicates.js @@ -9,7 +9,7 @@ const TEST_URI = "
Test Element
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_multiple-properties-priority.js b/devtools/client/inspector/rules/test/browser_rules_multiple-properties-priority.js index f14bf9a11de5..f7d98b768a7c 100644 --- a/devtools/client/inspector/rules/test/browser_rules_multiple-properties-priority.js +++ b/devtools/client/inspector/rules/test/browser_rules_multiple-properties-priority.js @@ -9,7 +9,7 @@ const TEST_URI = "
Test Element
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_multiple-properties-unfinished_01.js b/devtools/client/inspector/rules/test/browser_rules_multiple-properties-unfinished_01.js index 4f33847fbf3a..95d74d55bc86 100644 --- a/devtools/client/inspector/rules/test/browser_rules_multiple-properties-unfinished_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_multiple-properties-unfinished_01.js @@ -9,7 +9,7 @@ const TEST_URI = "
Test Element
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_multiple-properties-unfinished_02.js b/devtools/client/inspector/rules/test/browser_rules_multiple-properties-unfinished_02.js index 2297402d258c..8d5e09616baf 100644 --- a/devtools/client/inspector/rules/test/browser_rules_multiple-properties-unfinished_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_multiple-properties-unfinished_02.js @@ -9,7 +9,7 @@ const TEST_URI = "
Test Element
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_multiple_properties_01.js b/devtools/client/inspector/rules/test/browser_rules_multiple_properties_01.js index 4a66c393d749..2801df65258f 100644 --- a/devtools/client/inspector/rules/test/browser_rules_multiple_properties_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_multiple_properties_01.js @@ -9,7 +9,7 @@ const TEST_URI = "
Test Element
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_multiple_properties_02.js b/devtools/client/inspector/rules/test/browser_rules_multiple_properties_02.js index e39afb9a033d..1b289d726b4a 100644 --- a/devtools/client/inspector/rules/test/browser_rules_multiple_properties_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_multiple_properties_02.js @@ -9,7 +9,7 @@ const TEST_URI = "
Test Element
"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_original-source-link.js b/devtools/client/inspector/rules/test/browser_rules_original-source-link.js index 7085f8b748ad..06caeb659d8d 100644 --- a/devtools/client/inspector/rules/test/browser_rules_original-source-link.js +++ b/devtools/client/inspector/rules/test/browser_rules_original-source-link.js @@ -12,7 +12,7 @@ const PREF = "devtools.styleeditor.source-maps-enabled"; const SCSS_LOC = "doc_sourcemaps.scss:4"; const CSS_LOC = "doc_sourcemaps.css:1"; -add_task(function*() { +add_task(function* () { info("Setting the " + PREF + " pref to true"); Services.prefs.setBoolPref(PREF, true); @@ -78,7 +78,7 @@ function editorSelected(editor) { function verifyLinkText(text, view) { info("Verifying that the rule-view stylesheet link is " + text); let label = getRuleViewLinkByIndex(view, 1).querySelector("label"); - return waitForSuccess(function*() { + return waitForSuccess(function* () { return label.getAttribute("value") == text; }, "Link text changed to display correct location: " + text); } diff --git a/devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js b/devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js index 364acfbbbc48..6647ebb958dc 100644 --- a/devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js @@ -9,7 +9,7 @@ const TEST_URI = URL_ROOT + "doc_pseudoelement.html"; const PSEUDO_PREF = "devtools.inspector.show_pseudo_elements"; -add_task(function*() { +add_task(function* () { Services.prefs.setBoolPref(PSEUDO_PREF, true); yield addTab(TEST_URI); diff --git a/devtools/client/inspector/rules/test/browser_rules_pseudo-element_02.js b/devtools/client/inspector/rules/test/browser_rules_pseudo-element_02.js index 1446de84fd14..4723228193e8 100644 --- a/devtools/client/inspector/rules/test/browser_rules_pseudo-element_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_pseudo-element_02.js @@ -8,7 +8,7 @@ const TEST_URI = URL_ROOT + "doc_pseudoelement.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_pseudo_lock_options.js b/devtools/client/inspector/rules/test/browser_rules_pseudo_lock_options.js index 9b36ae0d2739..d795ba5f35b9 100644 --- a/devtools/client/inspector/rules/test/browser_rules_pseudo_lock_options.js +++ b/devtools/client/inspector/rules/test/browser_rules_pseudo_lock_options.js @@ -24,7 +24,7 @@ const TEST_URI = `
test div
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_refresh-no-flicker.js b/devtools/client/inspector/rules/test/browser_rules_refresh-no-flicker.js index e513737ba58b..25ea3d97295b 100644 --- a/devtools/client/inspector/rules/test/browser_rules_refresh-no-flicker.js +++ b/devtools/client/inspector/rules/test/browser_rules_refresh-no-flicker.js @@ -10,7 +10,7 @@ const TESTCASE_URI = "data:text/html;charset=utf-8," + "
" + "Test div!
"; -add_task(function*() { +add_task(function* () { yield addTab(TESTCASE_URI); info("Opening the rule view and selecting the test node"); diff --git a/devtools/client/inspector/rules/test/browser_rules_refresh-on-attribute-change_01.js b/devtools/client/inspector/rules/test/browser_rules_refresh-on-attribute-change_01.js index cb472fd1d039..381a6bda2f38 100644 --- a/devtools/client/inspector/rules/test/browser_rules_refresh-on-attribute-change_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_refresh-on-attribute-change_01.js @@ -20,7 +20,7 @@ const TEST_URI = ` `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view, testActor} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_refresh-on-attribute-change_02.js b/devtools/client/inspector/rules/test/browser_rules_refresh-on-attribute-change_02.js index ccd24f38ea7b..ec48d39bf6a5 100644 --- a/devtools/client/inspector/rules/test/browser_rules_refresh-on-attribute-change_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_refresh-on-attribute-change_02.js @@ -13,7 +13,7 @@ const TEST_URI = ` `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view, testActor} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_refresh-on-style-change.js b/devtools/client/inspector/rules/test/browser_rules_refresh-on-style-change.js index a30d7f66b869..81ff9d4d5a8d 100644 --- a/devtools/client/inspector/rules/test/browser_rules_refresh-on-style-change.js +++ b/devtools/client/inspector/rules/test/browser_rules_refresh-on-style-change.js @@ -9,7 +9,7 @@ const TEST_URI = "
Test div!
"; -add_task(function*() { +add_task(function* () { Services.prefs.setCharPref("devtools.defaultColorUnit", "name"); yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_01.js b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_01.js index 0e6795215f78..f4c47bba024c 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_01.js @@ -82,7 +82,7 @@ const TEST_DATA = [ } ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_02.js b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_02.js index 5be9421e0e59..911f09ff36e0 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_02.js @@ -21,7 +21,7 @@ const TEST_URI = `

Styled Node

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_03.js b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_03.js index b7a459858379..1d8063419b09 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_03.js @@ -20,7 +20,7 @@ const TEST_URI = `
Styled Node `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode(".testclass", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_04.js b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_04.js index 99a1fd1a2a10..05b8b01eb9ae 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_04.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_04.js @@ -19,7 +19,7 @@ const TEST_URI = `

Styled Node

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_expander.js b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_expander.js index f1be5d0c6563..c8b1e0869467 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_expander.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_expander.js @@ -21,7 +21,7 @@ const TEST_URI = `

Styled Node

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter-overridden-property.js b/devtools/client/inspector/rules/test/browser_rules_search-filter-overridden-property.js index 7b8e2983c936..3e634b76e756 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter-overridden-property.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter-overridden-property.js @@ -19,7 +19,7 @@ const TEST_URI = `

Styled Node

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_01.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_01.js index 226a5738f3f6..4dd1c951de07 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_01.js @@ -43,7 +43,7 @@ const TEST_DATA = [ }, ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_02.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_02.js index 1a566cc6018c..c23e7be62eda 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_02.js @@ -10,7 +10,7 @@ const SEARCH = "20%"; const TEST_URI = URL_ROOT + "doc_keyframeanimation.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); yield selectNode("#boxy", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_03.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_03.js index 93ab20ed6163..89280f0eb05d 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_03.js @@ -17,7 +17,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_04.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_04.js index 4b91d486df5c..5804d74ac0a8 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_04.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_04.js @@ -21,7 +21,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_05.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_05.js index f7ee860696ae..9388dd47ee54 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_05.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_05.js @@ -9,7 +9,7 @@ const SEARCH = "doc_urls_clickable.css"; const TEST_URI = URL_ROOT + "doc_urls_clickable.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); yield selectNode(".relative1", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_06.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_06.js index 3c0e09aad459..67b02ab7321b 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_06.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_06.js @@ -10,7 +10,7 @@ const SEARCH = "doc_urls_clickable.css: url"; const TEST_URI = URL_ROOT + "doc_urls_clickable.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); yield selectNode(".relative1", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_07.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_07.js index e09430c64664..16b047d8d391 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_07.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_07.js @@ -19,7 +19,7 @@ const TEST_URI = `

Styled Node

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_08.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_08.js index a99b3e16a6ce..1a3c0de59d07 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_08.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_08.js @@ -19,7 +19,7 @@ const TEST_URI = `

Styled Node

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_09.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_09.js index 701eee60efe1..7737beffa7b5 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_09.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_09.js @@ -19,7 +19,7 @@ const TEST_URI = `

Styled Node

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_10.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_10.js index b5a90188856c..ac336591db75 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_10.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_10.js @@ -35,7 +35,7 @@ const TEST_DATA = [ } ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_context-menu.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_context-menu.js index e362a6467c93..2ce7bf4eb040 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_context-menu.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_context-menu.js @@ -9,7 +9,7 @@ const TEST_INPUT = "h1"; const TEST_URI = "

test filter context menu

"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view} = yield openRuleView(); yield selectNode("h1", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_escape-keypress.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_escape-keypress.js index 87164077e37e..21848dce891a 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_escape-keypress.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_escape-keypress.js @@ -21,7 +21,7 @@ const TEST_URI = `
Styled Node
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_select-and-copy-styles.js b/devtools/client/inspector/rules/test/browser_rules_select-and-copy-styles.js index fa513de279d5..44baa4da7f3b 100644 --- a/devtools/client/inspector/rules/test/browser_rules_select-and-copy-styles.js +++ b/devtools/client/inspector/rules/test/browser_rules_select-and-copy-styles.js @@ -38,7 +38,7 @@ const TEST_URI = `
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_01.js b/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_01.js index 872d7755a500..4c8853e02e13 100644 --- a/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_01.js @@ -16,7 +16,7 @@ const TEST_URI = ` Test the selector highlighter `; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_02.js b/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_02.js index fba9e48f50af..5dd1e2b8c4d5 100644 --- a/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_02.js @@ -22,7 +22,7 @@ const TEST_URI = `

Testing the selector highlighter

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_03.js b/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_03.js index d8454a5e7734..77aebf4b1ce4 100644 --- a/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_selector-highlighter_03.js @@ -19,7 +19,7 @@ const TEST_URI = `
Node 2
`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_selector_highlight.js b/devtools/client/inspector/rules/test/browser_rules_selector_highlight.js index d1e0d08e4f4b..91422d57a7e8 100644 --- a/devtools/client/inspector/rules/test/browser_rules_selector_highlight.js +++ b/devtools/client/inspector/rules/test/browser_rules_selector_highlight.js @@ -109,7 +109,7 @@ const TEST_DATA = [ }, ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/inspector/rules/test/browser_rules_strict-search-filter-computed-list_01.js b/devtools/client/inspector/rules/test/browser_rules_strict-search-filter-computed-list_01.js index 7db15ccea5e9..dea9fff32174 100644 --- a/devtools/client/inspector/rules/test/browser_rules_strict-search-filter-computed-list_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_strict-search-filter-computed-list_01.js @@ -108,7 +108,7 @@ const TEST_DATA = [ }, ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_01.js b/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_01.js index 3b88f962ee9d..50948e1742e7 100644 --- a/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_01.js @@ -73,7 +73,7 @@ const TEST_DATA = [ } ]; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_02.js b/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_02.js index 79636597641b..0c76f0518355 100644 --- a/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_02.js @@ -10,7 +10,7 @@ const SEARCH = "`doc_urls_clickable.css:1`"; const TEST_URI = URL_ROOT + "doc_urls_clickable.html"; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); yield selectNode(".relative1", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_03.js b/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_03.js index b13e9b59e641..0326b0e9ca9e 100644 --- a/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_strict-search-filter_03.js @@ -21,7 +21,7 @@ const TEST_URI = `

Styled Node

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_style-editor-link.js b/devtools/client/inspector/rules/test/browser_rules_style-editor-link.js index ae926504a68a..6a7fef1ceccf 100644 --- a/devtools/client/inspector/rules/test/browser_rules_style-editor-link.js +++ b/devtools/client/inspector/rules/test/browser_rules_style-editor-link.js @@ -52,7 +52,7 @@ const DOCUMENT_URL = "data:text/html;charset=utf-8," + encodeURIComponent(` `); -add_task(function*() { +add_task(function* () { yield addTab(DOCUMENT_URL); let {toolbox, inspector, view, testActor} = yield openRuleView(); yield selectNode("div", inspector); diff --git a/devtools/client/inspector/rules/test/browser_rules_urls-clickable.js b/devtools/client/inspector/rules/test/browser_rules_urls-clickable.js index c59e89fccacd..fb1211e3c80b 100644 --- a/devtools/client/inspector/rules/test/browser_rules_urls-clickable.js +++ b/devtools/client/inspector/rules/test/browser_rules_urls-clickable.js @@ -12,7 +12,7 @@ const BASE_64_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAA" + "FCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAA" + "BJRU5ErkJggg=="; -add_task(function*() { +add_task(function* () { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); yield selectNodes(inspector, view); diff --git a/devtools/client/inspector/rules/test/browser_rules_user-agent-styles-uneditable.js b/devtools/client/inspector/rules/test/browser_rules_user-agent-styles-uneditable.js index c5e91bdfb880..e1bafff9b2c6 100644 --- a/devtools/client/inspector/rules/test/browser_rules_user-agent-styles-uneditable.js +++ b/devtools/client/inspector/rules/test/browser_rules_user-agent-styles-uneditable.js @@ -17,7 +17,7 @@ const TEST_URI = ` var PREF_UA_STYLES = "devtools.inspector.showUserAgentStyles"; -add_task(function*() { +add_task(function* () { info("Starting the test with the pref set to true before toolbox is opened"); Services.prefs.setBoolPref(PREF_UA_STYLES, true); diff --git a/devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js b/devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js index ee6c1c8aa89c..eccbf4fe1ba8 100644 --- a/devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js +++ b/devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js @@ -57,7 +57,7 @@ const TEST_DATA = [ } ]; -add_task(function*() { +add_task(function* () { requestLongerTimeout(2); info("Starting the test with the pref set to true before toolbox is opened"); diff --git a/devtools/client/inspector/rules/test/browser_rules_user-property-reset.js b/devtools/client/inspector/rules/test/browser_rules_user-property-reset.js index 45def46ca170..dcfb1dd28f75 100644 --- a/devtools/client/inspector/rules/test/browser_rules_user-property-reset.js +++ b/devtools/client/inspector/rules/test/browser_rules_user-property-reset.js @@ -12,7 +12,7 @@ const TEST_URI = `

element 2

`; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view, testActor} = yield openRuleView(); @@ -75,6 +75,7 @@ function* getContainerStyleAttrValue(id, {walker, markup}) { } attrIndex++; } + return undefined; } function* assertRuleAndMarkupViewWidth(id, value, ruleView, inspector) { diff --git a/devtools/client/inspector/rules/test/head.js b/devtools/client/inspector/rules/test/head.js index 85df69876061..4c26f2fec1a3 100644 --- a/devtools/client/inspector/rules/test/head.js +++ b/devtools/client/inspector/rules/test/head.js @@ -225,7 +225,7 @@ function* waitForComputedStyleProperty(selector, pseudo, name, expected) { * * @return a promise that resolves to the inplace-editor element when ready */ -var focusEditableField = Task.async(function*(ruleView, editable, xOffset = 1, +var focusEditableField = Task.async(function* (ruleView, editable, xOffset = 1, yOffset = 1, options = {}) { let onFocus = once(editable.parentNode, "focus", true); info("Clicking on editable field to turn to edit mode"); @@ -290,7 +290,7 @@ function* hideTooltipAndWaitForRuleViewChanged(tooltip, view) { * * @return a promise that resolves to the tab object */ -var waitForTab = Task.async(function*() { +var waitForTab = Task.async(function* () { info("Waiting for a tab to open"); yield once(gBrowser.tabContainer, "TabOpen"); let tab = gBrowser.selectedTab; @@ -313,7 +313,7 @@ var waitForTab = Task.async(function*() { * @return a promise that resolves when the function returned true or rejects * if the timeout is reached */ -var waitForSuccess = Task.async(function*(validatorFn, desc = "untitled") { +var waitForSuccess = Task.async(function* (validatorFn, desc = "untitled") { let i = 0; while (true) { info("Checking: " + desc); @@ -339,7 +339,7 @@ var waitForSuccess = Task.async(function*(validatorFn, desc = "untitled") { * The NodeActor that will used to retrieve the dataURL for the * font family tooltip contents. */ -var getFontFamilyDataURL = Task.async(function*(font, nodeFront) { +var getFontFamilyDataURL = Task.async(function* (font, nodeFront) { let fillStyle = (Services.prefs.getCharPref("devtools.theme") === "light") ? "black" : "white"; @@ -484,7 +484,7 @@ function getRuleViewSelectorHighlighterIcon(view, selectorText) { * - {String} value The expected style value * The style will be checked like so: getComputedStyle(element)[name] === value */ -var simulateColorPickerChange = Task.async(function*(ruleView, colorPicker, +var simulateColorPickerChange = Task.async(function* (ruleView, colorPicker, newRgba, expectedChange) { let onRuleViewChanged = ruleView.once("ruleview-changed"); info("Getting the spectrum colorpicker object"); @@ -525,7 +525,7 @@ var simulateColorPickerChange = Task.async(function*(ruleView, colorPicker, * - {String} value The expected style value * The style will be checked like so: getComputedStyle(element)[name] === value */ -var openColorPickerAndSelectColor = Task.async(function*(view, ruleIndex, +var openColorPickerAndSelectColor = Task.async(function* (view, ruleIndex, propIndex, newRgba, expectedChange) { let ruleEditor = getRuleViewRuleEditor(view, ruleIndex); let propEditor = ruleEditor.rule.textProps[propIndex].editor; @@ -563,7 +563,7 @@ var openColorPickerAndSelectColor = Task.async(function*(view, ruleIndex, * - {String} value The expected style value * The style will be checked like so: getComputedStyle(element)[name] === value */ -var openCubicBezierAndChangeCoords = Task.async(function*(view, ruleIndex, +var openCubicBezierAndChangeCoords = Task.async(function* (view, ruleIndex, propIndex, coords, expectedChange) { let ruleEditor = getRuleViewRuleEditor(view, ruleIndex); let propEditor = ruleEditor.rule.textProps[propIndex].editor; @@ -659,9 +659,9 @@ function getRuleViewRuleEditor(view, childrenIndex, nodeIndex) { * property to be blurred. Set to false if you don't want this. * @return {TextProperty} The instance of the TextProperty that was added */ -var addProperty = Task.async(function*(view, ruleIndex, name, value, - commitValueWith = "VK_RETURN", - blurNewProperty = true) { +var addProperty = Task.async(function* (view, ruleIndex, name, value, + commitValueWith = "VK_RETURN", + blurNewProperty = true) { info("Adding new property " + name + ":" + value + " to rule " + ruleIndex); let ruleEditor = getRuleViewRuleEditor(view, ruleIndex); @@ -717,8 +717,8 @@ var addProperty = Task.async(function*(view, ruleIndex, name, value, * focused. This parameter is true by default, and that causes the new * property to be blurred. Set to false if you don't want this. */ -var setProperty = Task.async(function*(view, textProp, value, - blurNewProperty = true) { +var setProperty = Task.async(function* (view, textProp, value, + blurNewProperty = true) { yield focusEditableField(view, textProp.editor.valueSpan); let onPreview = view.once("ruleview-changed"); @@ -750,8 +750,8 @@ var setProperty = Task.async(function*(view, textProp, value, * focused. This parameter is true by default, and that causes the new * property to be blurred. Set to false if you don't want this. */ -var removeProperty = Task.async(function*(view, textProp, - blurNewProperty = true) { +var removeProperty = Task.async(function* (view, textProp, + blurNewProperty = true) { yield focusEditableField(view, textProp.editor.nameSpan); let onModifications = view.once("ruleview-changed"); @@ -773,7 +773,7 @@ var removeProperty = Task.async(function*(view, textProp, * @param {TextProperty} textProp * The instance of the TextProperty to be enabled/disabled */ -var togglePropStatus = Task.async(function*(view, textProp) { +var togglePropStatus = Task.async(function* (view, textProp) { let onRuleViewRefreshed = view.once("ruleview-changed"); textProp.editor.enable.click(); yield onRuleViewRefreshed; @@ -787,7 +787,7 @@ var togglePropStatus = Task.async(function*(view, textProp) { * @return a promise that resolves to the newly created editor when ready and * focused */ -var focusNewRuleViewProperty = Task.async(function*(ruleEditor) { +var focusNewRuleViewProperty = Task.async(function* (ruleEditor) { info("Clicking on a close ruleEditor brace to start editing a new property"); ruleEditor.closeBrace.scrollIntoView(); let editor = yield focusEditableField(ruleEditor.ruleView, @@ -812,7 +812,7 @@ var focusNewRuleViewProperty = Task.async(function*(ruleEditor) { * @return a promise that resolves when the new property name has been entered * and once the value field is focused */ -var createNewRuleViewProperty = Task.async(function*(ruleEditor, inputValue) { +var createNewRuleViewProperty = Task.async(function* (ruleEditor, inputValue) { info("Creating a new property editor"); let editor = yield focusNewRuleViewProperty(ruleEditor); @@ -836,7 +836,7 @@ var createNewRuleViewProperty = Task.async(function*(ruleEditor, inputValue) { * @return a promise that resolves when the rule-view is filtered for the * search term */ -var setSearchFilter = Task.async(function*(view, searchValue) { +var setSearchFilter = Task.async(function* (view, searchValue) { info("Setting filter text to \"" + searchValue + "\""); let win = view.styleWindow; let searchField = view.searchField; diff --git a/devtools/client/inspector/rules/views/text-property-editor.js b/devtools/client/inspector/rules/views/text-property-editor.js index fdd62f511934..149000553d87 100644 --- a/devtools/client/inspector/rules/views/text-property-editor.js +++ b/devtools/client/inspector/rules/views/text-property-editor.js @@ -251,6 +251,7 @@ TextPropertyEditor.prototype = { if (domRule) { return domRule.href || domRule.nodeHref; } + return undefined; }, /** diff --git a/devtools/client/inspector/shared/dom-node-preview.js b/devtools/client/inspector/shared/dom-node-preview.js index d2025f81893a..b1e338d910b1 100644 --- a/devtools/client/inspector/shared/dom-node-preview.js +++ b/devtools/client/inspector/shared/dom-node-preview.js @@ -328,7 +328,7 @@ var HighlighterLock = { highlighter: null, isShown: false, - highlight: Task.async(function*(animationTargetNode) { + highlight: Task.async(function* (animationTargetNode) { if (!this.highlighter) { let util = animationTargetNode.inspector.toolbox.highlighterUtils; this.highlighter = yield util.getHighlighterByType("BoxModelHighlighter"); @@ -339,7 +339,7 @@ var HighlighterLock = { this.emit("highlighted", animationTargetNode); }), - unhighlight: Task.async(function*() { + unhighlight: Task.async(function* () { if (!this.highlighter || !this.isShown) { return; } diff --git a/devtools/client/inspector/shared/style-inspector-menu.js b/devtools/client/inspector/shared/style-inspector-menu.js index 4e0667b96b20..b52fb0697039 100644 --- a/devtools/client/inspector/shared/style-inspector-menu.js +++ b/devtools/client/inspector/shared/style-inspector-menu.js @@ -400,7 +400,7 @@ StyleInspectorMenu.prototype = { * Retrieve the image data for the selected image url and copy it to the * clipboard */ - _onCopyImageDataUrl: Task.async(function*() { + _onCopyImageDataUrl: Task.async(function* () { if (!this._clickedNodeInfo) { return; } diff --git a/devtools/client/inspector/shared/style-inspector-overlays.js b/devtools/client/inspector/shared/style-inspector-overlays.js index 253d29e307e9..b2865e3bea1b 100644 --- a/devtools/client/inspector/shared/style-inspector-overlays.js +++ b/devtools/client/inspector/shared/style-inspector-overlays.js @@ -406,6 +406,8 @@ TooltipsOverlay.prototype = { return this.previewTooltip.setFontFamilyContent(nodeInfo.value.value, inspector.selection.nodeFront); } + + return undefined; }, _onNewSelection: function() { diff --git a/devtools/client/jsonview/converter-child.js b/devtools/client/jsonview/converter-child.js index d3b8fd5b096d..b3f66387be29 100644 --- a/devtools/client/jsonview/converter-child.js +++ b/devtools/client/jsonview/converter-child.js @@ -132,6 +132,7 @@ let Converter = Class({ return jsonViewStrings.GetStringFromName(key); } catch (err) { Cu.reportError(err); + return undefined; } } }; diff --git a/devtools/client/locales/en-US/aboutdebugging.properties b/devtools/client/locales/en-US/aboutdebugging.properties index e919a9ab9360..3c2e40d5751b 100644 --- a/devtools/client/locales/en-US/aboutdebugging.properties +++ b/devtools/client/locales/en-US/aboutdebugging.properties @@ -6,6 +6,9 @@ debug = Debug push = Push start = Start +scope = Scope +unregister = unregister + addons = Add-ons addonDebugging.label = Enable add-on debugging addonDebugging.tooltip = Turning this on will allow you to debug add-ons and various other parts of the browser chrome diff --git a/devtools/client/memory/components/tree-map/drag-zoom.js b/devtools/client/memory/components/tree-map/drag-zoom.js index a2728c886e29..4cd44502aa6a 100644 --- a/devtools/client/memory/components/tree-map/drag-zoom.js +++ b/devtools/client/memory/components/tree-map/drag-zoom.js @@ -241,41 +241,27 @@ function setScrollHandlers(container, dragZoom, emitChanged, update) { let deltaZoom = dragZoom.zoom - prevZoom; // Calculate the updated width and height - let prevWidth = container.offsetWidth * (1 + prevZoom); - let prevHeight = container.offsetHeight * (1 + prevZoom); + let prevZoomedWidth = container.offsetWidth * (1 + prevZoom); + let prevZoomedHeight = container.offsetHeight * (1 + prevZoom); dragZoom.zoomedWidth = container.offsetWidth * (1 + dragZoom.zoom); - dragZoom.height = container.offsetHeight * (1 + dragZoom.zoom); - let deltaWidth = dragZoom.zoomedWidth - prevWidth; - let deltaHeight = dragZoom.height - prevHeight; + dragZoom.zoomedHeight = container.offsetHeight * (1 + dragZoom.zoom); + let deltaWidth = dragZoom.zoomedWidth - prevZoomedWidth; + let deltaHeight = dragZoom.zoomedHeight - prevZoomedHeight; - // The ratio of where the center of the zoom is in regards to the total + let mouseOffsetX = dragZoom.mouseX - container.offsetWidth / 2 + let mouseOffsetY = dragZoom.mouseY - container.offsetHeight / 2 + + // The ratio of where the center of the mouse is in regards to the total // zoomed width/height - let ratioZoomX = (dragZoom.zoomedWidth / 2 - dragZoom.translateX) + let ratioZoomX = (dragZoom.zoomedWidth / 2 + mouseOffsetX - dragZoom.translateX) / dragZoom.zoomedWidth; - let ratioZoomY = (dragZoom.height / 2 - dragZoom.translateY) - / dragZoom.height; + let ratioZoomY = (dragZoom.zoomedHeight / 2 + mouseOffsetY - dragZoom.translateY) + / dragZoom.zoomedHeight; // Distribute the change in width and height based on the above ratio dragZoom.translateX -= lerp(-deltaWidth / 2, deltaWidth / 2, ratioZoomX); dragZoom.translateY -= lerp(-deltaHeight / 2, deltaHeight / 2, ratioZoomY); - // The ratio of mouse position to total zoomeed width/height, ranged [-1, 1] - let mouseRatioX, mouseRatioY; - if (deltaZoom > 0) { - // Zoom in towards the mouse - mouseRatioX = 2 * (dragZoom.mouseX - container.offsetWidth / 2) - / dragZoom.zoomedWidth; - mouseRatioY = 2 * (dragZoom.mouseY - container.offsetHeight / 2) - / dragZoom.height; - } else { - // Zoom out centering the screen - mouseRatioX = 0; - mouseRatioY = 0; - } - // Adjust the translate to zoom towards the mouse - dragZoom.translateX -= deltaWidth * mouseRatioX; - dragZoom.translateY -= deltaHeight * mouseRatioY; - // Keep the canvas in range of the container keepInView(container, dragZoom); emitChanged(); @@ -314,7 +300,7 @@ function getScrollDelta(event, window) { function keepInView(container, dragZoom) { let { devicePixelRatio } = container.ownerDocument.defaultView; let overdrawX = (dragZoom.zoomedWidth - container.offsetWidth) / 2; - let overdrawY = (dragZoom.height - container.offsetHeight) / 2; + let overdrawY = (dragZoom.zoomedHeight - container.offsetHeight) / 2; dragZoom.translateX = Math.max(-overdrawX, Math.min(overdrawX, dragZoom.translateX)); @@ -325,6 +311,6 @@ function keepInView(container, dragZoom) { (dragZoom.zoomedWidth - container.offsetWidth) / 2 - dragZoom.translateX ); dragZoom.offsetY = devicePixelRatio * ( - (dragZoom.height - container.offsetHeight) / 2 - dragZoom.translateY + (dragZoom.zoomedHeight - container.offsetHeight) / 2 - dragZoom.translateY ); } diff --git a/devtools/client/memory/components/tree-map/draw.js b/devtools/client/memory/components/tree-map/draw.js index 408d0b98e1e4..84cd386ebbdf 100644 --- a/devtools/client/memory/components/tree-map/draw.js +++ b/devtools/client/memory/components/tree-map/draw.js @@ -37,7 +37,7 @@ const TEXT_LIGHT_COLOR = "rgba(0,0,0,0.5)"; const LINE_WIDTH = 1; const FONT_SIZE = 10; const FONT_LINE_HEIGHT = 2; -const PADDING = [5, 5, 5, 5]; +const PADDING = [5 + FONT_SIZE, 5, 5, 5]; const COUNT_LABEL = L10N.getStr("tree-map.node-count"); /** @@ -83,10 +83,15 @@ const configureD3Treemap = exports.configureD3Treemap = function(canvas) { let window = canvas.ownerDocument.defaultView; let ratio = window.devicePixelRatio; let treemap = window.d3.layout.treemap() - .size([canvas.width, canvas.height]) + .size([ + // The d3 layout includes the padding around everything, add some + // extra padding to the size to compensate for thi + canvas.width + (PADDING[1] + PADDING[3]) * ratio, + canvas.height + (PADDING[0] + PADDING[2]) * ratio + ]) .sticky(true) .padding([ - (PADDING[0] + FONT_SIZE) * ratio, + PADDING[0] * ratio, PADDING[1] * ratio, PADDING[2] * ratio, PADDING[3] * ratio, @@ -156,11 +161,11 @@ const drawTruncatedName = exports.drawTruncatedName = function(ctx, x, y, * @param {CanvasRenderingContext2D} ctx * @param {Object} node * @param {Number} borderWidth - * @param {Number} ratio * @param {Object} dragZoom + * @param {Array} padding */ const drawText = exports.drawText = function(ctx, node, borderWidth, ratio, - dragZoom) { + dragZoom, padding) { let { dx, dy, name, totalBytes, totalCount } = node; let scale = dragZoom.zoom + 1; dx *= scale; @@ -170,8 +175,8 @@ const drawText = exports.drawText = function(ctx, node, borderWidth, ratio, // common case of lots of small leaf nodes if (FONT_SIZE * FONT_LINE_HEIGHT < dy) { let margin = borderWidth(node) * 1.5 + ratio * TEXT_MARGIN; - let x = margin + node.x * scale - dragZoom.offsetX; - let y = margin + node.y * scale - dragZoom.offsetY; + let x = margin + (node.x - padding[0]) * scale - dragZoom.offsetX; + let y = margin + (node.y - padding[1]) * scale - dragZoom.offsetY; let innerWidth = dx - margin * 2; let nameSize = ctx.measureText(name).width; @@ -213,16 +218,18 @@ const drawText = exports.drawText = function(ctx, node, borderWidth, ratio, * @param {Number} borderWidth * @param {Number} ratio * @param {Object} dragZoom + * @param {Array} padding */ -const drawBox = exports.drawBox = function(ctx, node, borderWidth, dragZoom) { +const drawBox = exports.drawBox = function(ctx, node, borderWidth, dragZoom, + padding) { let border = borderWidth(node); let fillHSL = colorCoarseType(node); let strokeHSL = [fillHSL[0], fillHSL[1], fillHSL[2] * 0.5]; let scale = 1 + dragZoom.zoom; // Offset the draw so that box strokes don't overlap - let x = scale * node.x - dragZoom.offsetX + border / 2; - let y = scale * node.y - dragZoom.offsetY + border / 2; + let x = scale * (node.x - padding[0]) - dragZoom.offsetX + border / 2; + let y = scale * (node.y - padding[1]) - dragZoom.offsetY + border / 2; let dx = scale * node.dx - border; let dy = scale * node.dy - border; @@ -247,6 +254,9 @@ const drawTreemap = exports.drawTreemap = function({canvas, ctx}, nodes, let window = canvas.ownerDocument.defaultView; let ratio = window.devicePixelRatio; let canvasArea = canvas.width * canvas.height; + // Subtract the outer padding from the tree map layout. + let padding = [PADDING[3] * ratio, PADDING[0] * ratio]; + ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.font = `${FONT_SIZE * ratio}px sans-serif`; ctx.textBaseline = "top"; @@ -262,8 +272,8 @@ const drawTreemap = exports.drawTreemap = function({canvas, ctx}, nodes, continue; } - drawBox(ctx, node, borderWidth, dragZoom); - drawText(ctx, node, borderWidth, ratio, dragZoom); + drawBox(ctx, node, borderWidth, dragZoom, padding); + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); } }; diff --git a/devtools/client/memory/components/tree-map/start.js b/devtools/client/memory/components/tree-map/start.js index 23bdcb02f8c1..9cebe2a9db02 100644 --- a/devtools/client/memory/components/tree-map/start.js +++ b/devtools/client/memory/components/tree-map/start.js @@ -17,7 +17,7 @@ const CanvasUtils = require("./canvas-utils"); * @param {Number} debounceRate */ module.exports = function startVisualization(parentEl, report, - debounceRate = 100) { + debounceRate = 60) { let window = parentEl.ownerDocument.defaultView; let canvases = new CanvasUtils(parentEl, debounceRate); let dragZoom = new DragZoom(canvases.container, debounceRate, diff --git a/devtools/client/memory/test/unit/test_tree-map-01.js b/devtools/client/memory/test/unit/test_tree-map-01.js index d1f2d80b8f95..be311e81b978 100644 --- a/devtools/client/memory/test/unit/test_tree-map-01.js +++ b/devtools/client/memory/test/unit/test_tree-map-01.js @@ -21,37 +21,37 @@ add_task(function *() { type: "other", depth: 2 }; + let padding = [10, 10]; let borderWidth = () => 1; let dragZoom = { offsetX: 0, offsetY: 0, zoom: 0 }; - - drawBox(ctx, node, borderWidth, dragZoom); + drawBox(ctx, node, borderWidth, dragZoom, padding); ok(true, JSON.stringify([ctx, fillRectValues, strokeRectValues])); equal(ctx.fillStyle, "hsl(210,60%,70%)", "The fillStyle is set"); equal(ctx.strokeStyle, "hsl(210,60%,35%)", "The strokeStyle is set"); equal(ctx.lineWidth, 1, "The lineWidth is set"); - deepEqual(fillRectValues, [20.5,30.5,49,69], "Draws a filled rectangle"); - deepEqual(strokeRectValues, [20.5,30.5,49,69], "Draws a stroked rectangle"); + deepEqual(fillRectValues, [10.5,20.5,49,69], "Draws a filled rectangle"); + deepEqual(strokeRectValues, [10.5,20.5,49,69], "Draws a stroked rectangle"); dragZoom.zoom = 0.5; - drawBox(ctx, node, borderWidth, dragZoom); + drawBox(ctx, node, borderWidth, dragZoom, padding); ok(true, JSON.stringify([ctx, fillRectValues, strokeRectValues])); - deepEqual(fillRectValues, [30.5,45.5,74,104], + deepEqual(fillRectValues, [15.5,30.5,74,104], "Draws a zoomed filled rectangle"); - deepEqual(strokeRectValues, [30.5,45.5,74,104], + deepEqual(strokeRectValues, [15.5,30.5,74,104], "Draws a zoomed stroked rectangle"); dragZoom.offsetX = 110; dragZoom.offsetY = 130; - drawBox(ctx, node, borderWidth, dragZoom); - deepEqual(fillRectValues, [-79.5,-84.5,74,104], + drawBox(ctx, node, borderWidth, dragZoom, padding); + deepEqual(fillRectValues, [-94.5,-99.5,74,104], "Draws a zoomed and offset filled rectangle"); - deepEqual(strokeRectValues, [-79.5,-84.5,74,104], + deepEqual(strokeRectValues, [-94.5,-99.5,74,104], "Draws a zoomed and offset stroked rectangle"); }); diff --git a/devtools/client/memory/test/unit/test_tree-map-02.js b/devtools/client/memory/test/unit/test_tree-map-02.js index 7eab015ab036..af68caf6fa88 100644 --- a/devtools/client/memory/test/unit/test_tree-map-02.js +++ b/devtools/client/memory/test/unit/test_tree-map-02.js @@ -35,43 +35,44 @@ add_task(function*() { zoom: 0 }; let fillTextValues = []; + let padding = [10, 10]; - drawText(ctx, node, borderWidth, ratio, dragZoom); - deepEqual(fillTextValues[0], ["Example Node", 21.5, 31.5], + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); + deepEqual(fillTextValues[0], ["Example Node", 11.5,21.5], "Fills in the full node name"); - deepEqual(fillTextValues[1], ["1KiB 100 count", 151.5, 31.5], + deepEqual(fillTextValues[1], ["1KiB 100 count", 141.5,21.5], "Includes the full byte and count information"); fillTextValues = []; node.dx = 250; - drawText(ctx, node, borderWidth, ratio, dragZoom); + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); - deepEqual(fillTextValues[0], ["Example Node", 21.5, 31.5], + deepEqual(fillTextValues[0], ["Example Node", 11.5,21.5], "Fills in the full node name"); deepEqual(fillTextValues[1], undefined, "Drops off the byte and count information if not enough room"); fillTextValues = []; node.dx = 100; - drawText(ctx, node, borderWidth, ratio, dragZoom); + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); - deepEqual(fillTextValues[0], ["Exampl...", 21.5, 31.5], + deepEqual(fillTextValues[0], ["Exampl...", 11.5,21.5], "Cuts the name with ellipsis"); deepEqual(fillTextValues[1], undefined, "Drops off the byte and count information if not enough room"); fillTextValues = []; node.dx = 40; - drawText(ctx, node, borderWidth, ratio, dragZoom); + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); - deepEqual(fillTextValues[0], ["...", 21.5, 31.5], + deepEqual(fillTextValues[0], ["...", 11.5,21.5], "Shows only ellipsis when smaller"); deepEqual(fillTextValues[1], undefined, "Drops off the byte and count information if not enough room"); fillTextValues = []; node.dx = 20; - drawText(ctx, node, borderWidth, ratio, dragZoom); + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); deepEqual(fillTextValues[0], undefined, "Draw nothing when not enough room"); diff --git a/devtools/client/netmonitor/har/har-automation.js b/devtools/client/netmonitor/har/har-automation.js index 40f925c17038..d26b4d880a50 100644 --- a/devtools/client/netmonitor/har/har-automation.js +++ b/devtools/client/netmonitor/har/har-automation.js @@ -215,7 +215,8 @@ var HarAutomation = Class({ * @return array * A promise that is resolved with the extracted form data. */ - _getFormDataSections: Task.async(function*(headers, uploadHeaders, postData) { + _getFormDataSections: Task.async(function* (headers, uploadHeaders, + postData) { let formDataSections = []; let { headers: requestHeaders } = headers; diff --git a/devtools/client/netmonitor/har/har-collector.js b/devtools/client/netmonitor/har/har-collector.js index 638659add324..696be5b980bd 100644 --- a/devtools/client/netmonitor/har/har-collector.js +++ b/devtools/client/netmonitor/har/har-collector.js @@ -456,6 +456,7 @@ function waitForAll(promises) { if (promises.length) { return waitForAll(promises); } + return undefined; }); } diff --git a/devtools/client/netmonitor/har/har-exporter.js b/devtools/client/netmonitor/har/har-exporter.js index 5af50773a55d..f45c109ab92c 100644 --- a/devtools/client/netmonitor/har/har-exporter.js +++ b/devtools/client/netmonitor/har/har-exporter.js @@ -175,6 +175,7 @@ const HarExporter = { return JSON.stringify(har, null, " "); } catch (err) { Cu.reportError(err); + return undefined; } }, }; diff --git a/devtools/client/netmonitor/netmonitor-controller.js b/devtools/client/netmonitor/netmonitor-controller.js index 5ada144f86ca..e6bd0778fd22 100644 --- a/devtools/client/netmonitor/netmonitor-controller.js +++ b/devtools/client/netmonitor/netmonitor-controller.js @@ -163,7 +163,7 @@ var NetMonitorController = { * @return object * A promise that is resolved when the monitor finishes startup. */ - startupNetMonitor: Task.async(function*() { + startupNetMonitor: Task.async(function* () { if (this._startup) { return this._startup.promise; } @@ -173,6 +173,7 @@ var NetMonitorController = { yield this.connect(); } this._startup.resolve(); + return undefined; }), /** @@ -181,7 +182,7 @@ var NetMonitorController = { * @return object * A promise that is resolved when the monitor finishes shutdown. */ - shutdownNetMonitor: Task.async(function*() { + shutdownNetMonitor: Task.async(function* () { if (this._shutdown) { return this._shutdown.promise; } @@ -193,6 +194,7 @@ var NetMonitorController = { yield this.disconnect(); } this._shutdown.resolve(); + return undefined; }), /** @@ -204,7 +206,7 @@ var NetMonitorController = { * @return object * A promise that is resolved when the monitor finishes connecting. */ - connect: Task.async(function*() { + connect: Task.async(function* () { if (this._connection) { return this._connection.promise; } @@ -224,6 +226,7 @@ var NetMonitorController = { this._target.form); return this.timelineFront.start({ withDocLoadingEvents: true }); } + return undefined; }; this.webConsoleClient = this._target.activeConsole; @@ -236,12 +239,13 @@ var NetMonitorController = { this._connection.resolve(); this._connected = true; + return undefined; }), /** * Disconnects the debugger client and removes event handlers as necessary. */ - disconnect: Task.async(function*() { + disconnect: Task.async(function* () { if (this._disconnection) { return this._disconnection.promise; } @@ -266,6 +270,7 @@ var NetMonitorController = { this._disconnection.resolve(); this._connected = false; + return undefined; }), /** @@ -329,7 +334,9 @@ var NetMonitorController = { } if (type == ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED) { this._currentActivity = ACTIVITY_TYPE.ENABLE_CACHE; - this._target.once("will-navigate", () => this._currentActivity = type); + this._target.once("will-navigate", () => { + this._currentActivity = type; + }); return reconfigureTabAndWaitForNavigation({ cacheDisabled: false, performReload: true @@ -337,7 +344,9 @@ var NetMonitorController = { } if (type == ACTIVITY_TYPE.RELOAD.WITH_CACHE_DISABLED) { this._currentActivity = ACTIVITY_TYPE.DISABLE_CACHE; - this._target.once("will-navigate", () => this._currentActivity = type); + this._target.once("will-navigate", () => { + this._currentActivity = type; + }); return reconfigureTabAndWaitForNavigation({ cacheDisabled: true, performReload: true diff --git a/devtools/client/netmonitor/netmonitor-view.js b/devtools/client/netmonitor/netmonitor-view.js index 8b95cd14d0fb..769e752415f1 100644 --- a/devtools/client/netmonitor/netmonitor-view.js +++ b/devtools/client/netmonitor/netmonitor-view.js @@ -183,7 +183,7 @@ var NetMonitorView = { /** * Destroys the UI for all the displayed panes. */ - _destroyPanes: Task.async(function*() { + _destroyPanes: Task.async(function* () { dumpn("Destroying the NetMonitorView panes"); Prefs.networkDetailsWidth = this._detailsPane.getAttribute("width"); @@ -280,7 +280,7 @@ var NetMonitorView = { let requestsView = this.RequestsMenu; let statisticsView = this.PerformanceStatistics; - Task.spawn(function*() { + Task.spawn(function* () { statisticsView.displayPlaceholderCharts(); yield controller.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED); @@ -647,6 +647,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { } this._flushRequestsTask.arm(); + return undefined; }, /** @@ -690,7 +691,8 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { * @return array * A promise that is resolved with the extracted form data. */ - _getFormDataSections: Task.async(function*(headers, uploadHeaders, postData) { + _getFormDataSections: Task.async(function* (headers, uploadHeaders, + postData) { let formDataSections = []; let { headers: requestHeaders } = headers; @@ -726,7 +728,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { * Copy the request form data parameters (or raw payload) from * the currently selected item. */ - copyPostData: Task.async(function*() { + copyPostData: Task.async(function* () { let selected = this.selectedItem.attachment; let view = this; @@ -766,7 +768,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { copyAsCurl: function() { let selected = this.selectedItem.attachment; - Task.spawn(function*() { + Task.spawn(function* () { // Create a sanitized object for the Curl command generator. let data = { url: selected.url, @@ -1282,7 +1284,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { } // Find the 'upgrade' header. - var upgradeHeader = requestHeaders.headers.find(header => { + let upgradeHeader = requestHeaders.headers.find(header => { return (header.name == "Upgrade"); }); @@ -1487,6 +1489,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { } this._flushRequestsTask.arm(); + return undefined; }, /** @@ -1581,7 +1584,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { let currentItem = requestItem; let currentStore = { headers: [], headersSize: 0 }; - Task.spawn(function*() { + Task.spawn(function* () { let postData = yield gNetwork.getString(val.postData.text); let payloadHeaders = CurlUtils.getHeadersFromMultipartText( postData); @@ -1775,7 +1778,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { * @return object * A promise that is resolved once the information is displayed. */ - updateMenuView: Task.async(function*(item, key, value) { + updateMenuView: Task.async(function* (item, key, value) { let target = item.target || item; switch (key) { @@ -2242,6 +2245,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { return anchor; }); } + return undefined; }, /** @@ -2313,7 +2317,9 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { .mimeType.includes("image/"); let separators = $all(".request-menu-context-separator"); - Array.forEach(separators, separator => separator.hidden = !selectedItem); + Array.forEach(separators, separator => { + separator.hidden = !selectedItem; + }); let copyAsHar = $("#request-menu-context-copy-all-as-har"); copyAsHar.hidden = !NetMonitorView.RequestsMenu.items.length; @@ -2508,7 +2514,7 @@ SidebarView.prototype = { * @return object * Returns a promise that resolves upon population of the subview. */ - populate: Task.async(function*(data) { + populate: Task.async(function* (data) { let isCustom = data.isCustom; let view = isCustom ? NetMonitorView.CustomRequest : @@ -2558,7 +2564,7 @@ CustomRequestView.prototype = { * @return object * Returns a promise that resolves upon population the view. */ - populate: Task.async(function*(data) { + populate: Task.async(function* (data) { $("#custom-url-value").value = data.url; $("#custom-method-value").value = data.method; this.updateCustomQuery(data.url); @@ -2811,7 +2817,7 @@ NetworkDetailsView.prototype = { return; } - Task.spawn(function*() { + Task.spawn(function* () { viewState.updating[tab] = true; switch (tab) { // "Headers" @@ -2951,7 +2957,7 @@ NetworkDetailsView.prototype = { * @return object * A promise that resolves when request headers are set. */ - _setRequestHeaders: Task.async(function*(headers, uploadHeaders) { + _setRequestHeaders: Task.async(function* (headers, uploadHeaders) { if (headers && headers.headers.length) { yield this._addHeaders(this._requestHeaders, headers); } @@ -2968,7 +2974,7 @@ NetworkDetailsView.prototype = { * @return object * A promise that resolves when response headers are set. */ - _setResponseHeaders: Task.async(function*(response) { + _setResponseHeaders: Task.async(function* (response) { if (response && response.headers.length) { response.headers.sort((a, b) => a.name > b.name); yield this._addHeaders(this._responseHeaders, response); @@ -2985,7 +2991,7 @@ NetworkDetailsView.prototype = { * @return object * A promise that resolves when headers are added. */ - _addHeaders: Task.async(function*(name, response) { + _addHeaders: Task.async(function* (name, response) { let kb = response.headersSize / 1024; let size = L10N.numberWithDecimals(kb, HEADERS_SIZE_DECIMALS); let text = L10N.getFormatStr("networkMenu.sizeKB", size); @@ -3008,7 +3014,7 @@ NetworkDetailsView.prototype = { * @return object * A promise that is resolved when the request cookies are set. */ - _setRequestCookies: Task.async(function*(response) { + _setRequestCookies: Task.async(function* (response) { if (response && response.cookies.length) { response.cookies.sort((a, b) => a.name > b.name); yield this._addCookies(this._requestCookies, response); @@ -3023,7 +3029,7 @@ NetworkDetailsView.prototype = { * @return object * A promise that is resolved when the response cookies are set. */ - _setResponseCookies: Task.async(function*(response) { + _setResponseCookies: Task.async(function* (response) { if (response && response.cookies.length) { yield this._addCookies(this._responseCookies, response); } @@ -3039,7 +3045,7 @@ NetworkDetailsView.prototype = { * @return object * Returns a promise that resolves upon the adding of cookies. */ - _addCookies: Task.async(function*(name, response) { + _addCookies: Task.async(function* (name, response) { let cookiesScope = this._cookies.addScope(name); cookiesScope.expanded = true; @@ -3093,7 +3099,7 @@ NetworkDetailsView.prototype = { * @return object * A promise that is resolved when the request post params are set. */ - _setRequestPostParams: Task.async(function*(headers, uploadHeaders, + _setRequestPostParams: Task.async(function* (headers, uploadHeaders, postData) { if (!headers || !uploadHeaders || !postData) { return; @@ -3177,7 +3183,7 @@ NetworkDetailsView.prototype = { * @return object * A promise that is resolved when the response body is set. */ - _setResponseBody: Task.async(function*(url, response) { + _setResponseBody: Task.async(function* (url, response) { if (!response) { return; } @@ -3372,7 +3378,7 @@ NetworkDetailsView.prototype = { * @return object * A promise that is resolved when the html preview is rendered. */ - _setHtmlPreview: Task.async(function*(response) { + _setHtmlPreview: Task.async(function* (response) { if (!response) { return promise.resolve(); } @@ -3385,6 +3391,7 @@ NetworkDetailsView.prototype = { iframe.contentDocument.documentElement.innerHTML = responseBody; window.emit(EVENTS.RESPONSE_HTML_PREVIEW_DISPLAYED); + return undefined; }), /** diff --git a/devtools/client/netmonitor/panel.js b/devtools/client/netmonitor/panel.js index 0ac53f8f6873..189879f2e17c 100644 --- a/devtools/client/netmonitor/panel.js +++ b/devtools/client/netmonitor/panel.js @@ -28,7 +28,7 @@ NetMonitorPanel.prototype = { * @return object * A promise that is resolved when the NetMonitor completes opening. */ - open: Task.async(function*() { + open: Task.async(function* () { if (this._opening) { return this._opening; } @@ -54,7 +54,7 @@ NetMonitorPanel.prototype = { return this._toolbox.target; }, - destroy: Task.async(function*() { + destroy: Task.async(function* () { if (this._destroying) { return this._destroying; } diff --git a/devtools/client/responsive.html/components/browser.js b/devtools/client/responsive.html/components/browser.js index e66ca7ebd812..07f0bea52ad1 100644 --- a/devtools/client/responsive.html/components/browser.js +++ b/devtools/client/responsive.html/components/browser.js @@ -37,7 +37,7 @@ module.exports = createClass({ * Once the browser element has mounted, load the frame script and enable * various features, like floating scrollbars. */ - componentDidMount: Task.async(function*() { + componentDidMount: Task.async(function* () { let { onContentResize } = this; let browser = this.refs.browserContainer.querySelector("iframe.browser"); let mm = browser.frameLoader.messageManager; diff --git a/devtools/client/responsive.html/images/close.svg b/devtools/client/responsive.html/images/close.svg index ab8e140c8c0e..e495b3924e71 100644 --- a/devtools/client/responsive.html/images/close.svg +++ b/devtools/client/responsive.html/images/close.svg @@ -1,6 +1,11 @@ - - - + + + + + diff --git a/devtools/client/responsive.html/images/rotate-viewport.svg b/devtools/client/responsive.html/images/rotate-viewport.svg index 2a5a2a7757a4..4afc3518b4ec 100644 --- a/devtools/client/responsive.html/images/rotate-viewport.svg +++ b/devtools/client/responsive.html/images/rotate-viewport.svg @@ -1,6 +1,16 @@ - - - + + + + + + + diff --git a/devtools/client/responsive.html/images/screenshot.svg b/devtools/client/responsive.html/images/screenshot.svg index e176f6c7a3de..6338f912ba68 100644 --- a/devtools/client/responsive.html/images/screenshot.svg +++ b/devtools/client/responsive.html/images/screenshot.svg @@ -1,7 +1,13 @@ - - - - + + + + + + diff --git a/devtools/client/responsive.html/manager.js b/devtools/client/responsive.html/manager.js index 2314cb4909fc..e693cd46c65e 100644 --- a/devtools/client/responsive.html/manager.js +++ b/devtools/client/responsive.html/manager.js @@ -51,7 +51,7 @@ const ResponsiveUIManager = exports.ResponsiveUIManager = { * Resolved to the ResponsiveUI instance for this tab when opening is * complete. */ - openIfNeeded: Task.async(function*(window, tab) { + openIfNeeded: Task.async(function* (window, tab) { if (!this.isActiveForTab(tab)) { let ui = new ResponsiveUI(window, tab); this.activeTabs.set(tab, ui); @@ -71,7 +71,7 @@ const ResponsiveUIManager = exports.ResponsiveUIManager = { * @return Promise * Resolved (with no value) when closing is complete. */ - closeIfNeeded: Task.async(function*(window, tab) { + closeIfNeeded: Task.async(function* (window, tab) { if (this.isActiveForTab(tab)) { yield this.activeTabs.get(tab).destroy(); this.activeTabs.delete(tab); @@ -191,7 +191,7 @@ ResponsiveUI.prototype = { * state. Platform discussions are in progress to make this happen. See * bug 1238160 about
highlighter test
"; -add_task(function*() { +add_task(function* () { let { ui } = yield openStyleEditorForURL(TEST_URL); let editor = ui.editors[0]; diff --git a/devtools/client/styleeditor/test/browser_styleeditor_inline_friendly_names.js b/devtools/client/styleeditor/test/browser_styleeditor_inline_friendly_names.js index ba7c49177105..d1aac2d021ff 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_inline_friendly_names.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_inline_friendly_names.js @@ -10,7 +10,7 @@ const FIRST_TEST_PAGE = TEST_BASE_HTTP + "inline-1.html"; const SECOND_TEST_PAGE = TEST_BASE_HTTP + "inline-2.html"; const SAVE_PATH = "test.css"; -add_task(function*() { +add_task(function* () { let { ui } = yield openStyleEditorForURL(FIRST_TEST_PAGE); testIndentifierGeneration(ui); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar.js b/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar.js index f95543919fa9..d4ac752d25c8 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar.js @@ -17,7 +17,7 @@ const NEW_RULE = "\n@media (max-width: 600px) { div { color: blue; } }"; waitForExplicitFinish(); -add_task(function*() { +add_task(function* () { let { ui } = yield openStyleEditorForURL(TESTCASE_URI); is(ui.editors.length, 2, "correct number of editors"); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar_links.js b/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar_links.js index 32f422840c3b..1c8c3004f1b9 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar_links.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar_links.js @@ -12,7 +12,7 @@ const {ResponsiveUIManager} = Cu.import(mgr, {}); const TESTCASE_URI = TEST_BASE_HTTPS + "media-rules.html"; const responsiveModeToggleClass = ".media-responsive-mode-toggle"; -add_task(function*() { +add_task(function* () { let {ui} = yield openStyleEditorForURL(TESTCASE_URI); let editor = ui.editors[1]; @@ -106,7 +106,7 @@ function waitForResizeTo(manager, type, value) { function* getSizing() { let browser = gBrowser.selectedBrowser; - let sizing = yield ContentTask.spawn(browser, {}, function*() { + let sizing = yield ContentTask.spawn(browser, {}, function* () { return { width: content.innerWidth, height: content.innerHeight diff --git a/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar_sourcemaps.js b/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar_sourcemaps.js index febddf4e767e..9a8f8d7ab601 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar_sourcemaps.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_media_sidebar_sourcemaps.js @@ -14,7 +14,7 @@ const LINE_NOS = [5, 8]; waitForExplicitFinish(); -add_task(function*() { +add_task(function* () { Services.prefs.setBoolPref(MAP_PREF, true); let { ui } = yield openStyleEditorForURL(TESTCASE_URI); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_new.js b/devtools/client/styleeditor/test/browser_styleeditor_new.js index 15136e34e8ea..f7cff8b7ddd7 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_new.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_new.js @@ -9,7 +9,7 @@ const TESTCASE_URI = TEST_BASE_HTTP + "simple.html"; const TESTCASE_CSS_SOURCE = "body{background-color:red;"; -add_task(function*() { +add_task(function* () { let { panel, ui } = yield openStyleEditorForURL(TESTCASE_URI); let editor = yield createNew(ui, panel.panelWindow); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_opentab.js b/devtools/client/styleeditor/test/browser_styleeditor_opentab.js index 92d42892b56a..a55864b88e67 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_opentab.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_opentab.js @@ -8,7 +8,7 @@ // context menu item for stylesheets (bug 992947). const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html"; -add_task(function*() { +add_task(function* () { let { ui } = yield openStyleEditorForURL(TESTCASE_URI); yield rightClickStyleSheet(ui, ui.editors[0]); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_large.js b/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_large.js index f1559fd982db..cddba68777d8 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_large.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_large.js @@ -11,7 +11,7 @@ const TESTCASE_URI = TEST_BASE_HTTPS + "sourcemaps-large.html"; -add_task(function*() { +add_task(function* () { let { ui } = yield openStyleEditorForURL(TESTCASE_URI); yield openEditor(ui.editors[0]); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_watching.js b/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_watching.js index f83b84c33bca..16ecae14a90e 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_watching.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_watching.js @@ -21,7 +21,7 @@ const Ci = Components.interfaces; const {FileUtils} = Components.utils.import("resource://gre/modules/FileUtils.jsm", {}); const {NetUtil} = Components.utils.import("resource://gre/modules/NetUtil.jsm", {}); -add_task(function*() { +add_task(function* () { yield new Promise(resolve => { SpecialPowers.pushPrefEnv({"set": [ [TRANSITIONS_PREF, false] diff --git a/devtools/client/styleeditor/test/browser_styleeditor_sourcemaps.js b/devtools/client/styleeditor/test/browser_styleeditor_sourcemaps.js index 68918d56776c..fefca764867e 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_sourcemaps.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_sourcemaps.js @@ -77,7 +77,7 @@ const origNames = ["sourcemaps.scss", "contained.scss", "test-stylus.styl"]; waitForExplicitFinish(); -add_task(function*() { +add_task(function* () { let {ui} = yield openStyleEditorForURL(TESTCASE_URI); is(ui.editors.length, 4, diff --git a/devtools/client/styleeditor/test/browser_styleeditor_sync.js b/devtools/client/styleeditor/test/browser_styleeditor_sync.js index 39f4b634dfec..beb50004e75d 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_sync.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_sync.js @@ -29,7 +29,7 @@ function* closeAndReopenToolbox() { return newui; } -add_task(function*() { +add_task(function* () { yield addTab(TESTCASE_URI); let { inspector, view } = yield openRuleView(); yield selectNode("#testid", inspector); @@ -67,7 +67,7 @@ add_task(function*() { // For the time being, the actor does not update the style's owning // node's textContent. See bug 1205380. let textContent = yield ContentTask.spawn(gBrowser.selectedBrowser, null, - function*() { + function* () { return content.document.querySelector("style").textContent; }); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_syncAddRule.js b/devtools/client/styleeditor/test/browser_styleeditor_syncAddRule.js index 1244e943ba97..c124a70a80a9 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_syncAddRule.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_syncAddRule.js @@ -14,7 +14,7 @@ const expectedText = ` #testid { }`; -add_task(function*() { +add_task(function* () { yield addTab(TESTCASE_URI); let { inspector, view } = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_syncAlreadyOpen.js b/devtools/client/styleeditor/test/browser_styleeditor_syncAlreadyOpen.js index c13b4dc7acfc..f78c199f7c12 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_syncAlreadyOpen.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_syncAlreadyOpen.js @@ -22,7 +22,7 @@ const expectedText = ` } `; -add_task(function*() { +add_task(function* () { yield addTab(TESTCASE_URI); let { inspector, view } = yield openRuleView(); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_syncEditSelector.js b/devtools/client/styleeditor/test/browser_styleeditor_syncEditSelector.js index fce029d9c781..4f1c9a402f5b 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_syncEditSelector.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_syncEditSelector.js @@ -22,7 +22,7 @@ const expectedText = ` } `; -add_task(function*() { +add_task(function* () { yield addTab(TESTCASE_URI); let { inspector, view } = yield openRuleView(); yield selectNode("#testid", inspector); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_syncIntoRuleView.js b/devtools/client/styleeditor/test/browser_styleeditor_syncIntoRuleView.js index a6afbae44d0b..17cc54049caa 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_syncIntoRuleView.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_syncIntoRuleView.js @@ -18,7 +18,7 @@ const TEST_URI = ` const TESTCASE_CSS_SOURCE = "#testid { color: chartreuse; }"; -add_task(function*() { +add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_transition_rule.js b/devtools/client/styleeditor/test/browser_styleeditor_transition_rule.js index e1f4e3d7caf8..82db07f46bd4 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_transition_rule.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_transition_rule.js @@ -8,7 +8,7 @@ const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html"; const NEW_RULE = "body { background-color: purple; }"; -add_task(function*() { +add_task(function* () { let { ui } = yield openStyleEditorForURL(TESTCASE_URI); is(ui.editors.length, 2, "correct number of editors"); @@ -25,7 +25,7 @@ add_task(function*() { yield styleChanges; let rules = yield ContentTask.spawn(gBrowser.selectedBrowser, 0, - function*(index) { + function* (index) { let sheet = content.document.styleSheets[index]; return [...sheet.cssRules].map(rule => rule.cssText); }); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_xul.js b/devtools/client/styleeditor/test/browser_styleeditor_xul.js index 07c3e38fc9a8..931ad92e7422 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_xul.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_xul.js @@ -10,7 +10,7 @@ waitForExplicitFinish(); const TEST_URL = TEST_BASE + "doc_xulpage.xul"; -add_task(function*() { +add_task(function* () { let tab = yield addTab(TEST_URL); let target = TargetFactory.forTab(tab); diff --git a/devtools/client/styleeditor/test/head.js b/devtools/client/styleeditor/test/head.js index c229cbebdd1d..0ba5545076f5 100644 --- a/devtools/client/styleeditor/test/head.js +++ b/devtools/client/styleeditor/test/head.js @@ -49,7 +49,7 @@ function addTab(url, win) { * @param {String} url The url to be loaded in the current tab. * @return a promise that resolves when the page has fully loaded. */ -var navigateTo = Task.async(function*(url) { +var navigateTo = Task.async(function* (url) { info(`Navigating to ${url}`); let browser = gBrowser.selectedBrowser; @@ -64,13 +64,13 @@ var navigateTo = Task.async(function*(url) { yield navigating.promise; }); -var navigateToAndWaitForStyleSheets = Task.async(function*(url, ui) { +var navigateToAndWaitForStyleSheets = Task.async(function* (url, ui) { let onReset = ui.once("stylesheets-reset"); yield navigateTo(url); yield onReset; }); -var reloadPageAndWaitForStyleSheets = Task.async(function*(ui) { +var reloadPageAndWaitForStyleSheets = Task.async(function* (ui) { info("Reloading the page."); let onReset = ui.once("stylesheets-reset"); @@ -79,7 +79,7 @@ var reloadPageAndWaitForStyleSheets = Task.async(function*(ui) { yield onReset; }); -registerCleanupFunction(function*() { +registerCleanupFunction(function* () { while (gBrowser.tabs.length > 1) { let target = TargetFactory.forTab(gBrowser.selectedTab); yield gDevTools.closeToolbox(target); @@ -91,7 +91,7 @@ registerCleanupFunction(function*() { /** * Open the style editor for the current tab. */ -var openStyleEditor = Task.async(function*(tab) { +var openStyleEditor = Task.async(function* (tab) { if (!tab) { tab = gBrowser.selectedTab; } @@ -107,7 +107,7 @@ var openStyleEditor = Task.async(function*(tab) { * Creates a new tab in specified window navigates it to the given URL and * opens style editor in it. */ -var openStyleEditorForURL = Task.async(function*(url, win) { +var openStyleEditorForURL = Task.async(function* (url, win) { let tab = yield addTab(url, win); let result = yield openStyleEditor(tab); result.tab = tab; diff --git a/devtools/client/themes/canvasdebugger.css b/devtools/client/themes/canvasdebugger.css index 0949cb36d8f4..d98999006304 100644 --- a/devtools/client/themes/canvasdebugger.css +++ b/devtools/client/themes/canvasdebugger.css @@ -8,11 +8,21 @@ --checkerboard-pattern: linear-gradient(45deg, rgba(128,128,128,0.2) 25%, transparent 25%, transparent 75%, rgba(128,128,128,0.2) 75%, rgba(128,128,128,0.2)), linear-gradient(45deg, rgba(128,128,128,0.2) 25%, transparent 25%, transparent 75%, rgba(128,128,128,0.2) 75%, rgba(128,128,128,0.2)); } + +:root.theme-dark { + --draw-call-background: rgba(112,191,83,0.15); + --interesting-call-background: rgba(223,128,255,0.15); +} + +:root.theme-light { + --draw-call-background: rgba(44,187,15,0.1); + --interesting-call-background: rgba(184,46,229,0.1); +} + /* Reload and waiting notices */ .notice-container { margin-top: -50vh; - background-color: var(--theme-toolbar-background); color: var(--theme-body-color-alt); } @@ -33,9 +43,8 @@ /* Snapshots pane */ -#snapshots-pane > tabs, -#snapshots-pane .devtools-toolbar { - -moz-border-end: 1px solid var(--theme-splitter-color); +#snapshots-pane { + border-inline-end: 1px solid var(--theme-splitter-color); } #record-snapshot { @@ -61,7 +70,7 @@ } .snapshot-item-details { - -moz-padding-start: 6px; + padding-inline-start: 6px; } .snapshot-item-calls { @@ -134,7 +143,7 @@ } #calls-slider { - -moz-padding-end: 24px; + padding-inline-end: 24px; } #calls-slider .scale-slider { @@ -154,44 +163,24 @@ background: transparent; } -#calls-list .side-menu-widget-item { - padding: 0; -} - /* Calls list items */ -.theme-dark #calls-list .side-menu-widget-item { - border-color: #111; +#calls-list .side-menu-widget-item { + padding: 0; + border-color: var(--theme-splitter-color); border-bottom-color: transparent; } -.theme-light #calls-list .side-menu-widget-item { - border-color: #eee; - border-bottom-color: transparent; +.call-item-view:hover { + background-color: rgba(128,128,128,0.05); } -.theme-dark .call-item-view:hover { - background-color: rgba(255,255,255,.025); +.call-item-view[draw-call] { + background-color: var(--draw-call-background); } -.theme-light .call-item-view:hover { - background-color: rgba(0,0,0,.025); -} - -.theme-dark .call-item-view[draw-call] { - background-color: rgba(112,191,83,0.15); -} - -.theme-light .call-item-view[draw-call] { - background-color: rgba(44,187,15,0.1); -} - -.theme-dark .call-item-view[interesting-call] { - background-color: rgba(223,128,255,0.15); -} - -.theme-light .call-item-view[interesting-call] { - background-color: rgba(184,46,229,0.1); +.call-item-view[interesting-call] { + background-color: var(--interesting-call-background); } .call-item-gutter { @@ -200,8 +189,10 @@ padding-inline-end: 4px; padding-top: 2px; padding-bottom: 2px; - -moz-border-end: 1px solid; - -moz-margin-end: 6px; + border-inline-end: 1px solid var(--theme-splitter-color); + margin-inline-end: 6px; + background-color: var(--theme-sidebar-background); + color: var(--theme-content-color3); } .selected .call-item-gutter { @@ -217,12 +208,6 @@ } } -.call-item-gutter { - background-color: var(--theme-sidebar-background); - color: var(--theme-content-color3); - border-color: var(--theme-splitter-color); -} - .call-item-index { text-align: end; } @@ -236,11 +221,12 @@ } .call-item-location { - -moz-padding-start: 2px; - -moz-padding-end: 6px; + padding-inline-start: 2px; + padding-inline-end: 6px; text-align: end; cursor: pointer; color: var(--theme-highlight-bluegrey); + border-color: var(--theme-splitter-color); } .call-item-location:hover { @@ -252,16 +238,8 @@ text-decoration: underline; } -.theme-dark .call-item-location { - border-color: #111; -} - -.theme-light .call-item-location { - border-color: #eee; -} - .call-item-stack { - -moz-padding-start: calc(var(--gutter-width) + var(--gutter-padding-start)); + padding-inline-start: calc(var(--gutter-width) + var(--gutter-padding-start)); padding-bottom: 10px; } @@ -279,8 +257,8 @@ } .call-item-stack-fn-location { - -moz-padding-start: 2px; - -moz-padding-end: 6px; + padding-inline-start: 2px; + padding-inline-end: 6px; text-align: end; cursor: pointer; text-decoration: underline; diff --git a/devtools/client/themes/memory.css b/devtools/client/themes/memory.css index de02d37f9d8b..083d32639329 100644 --- a/devtools/client/themes/memory.css +++ b/devtools/client/themes/memory.css @@ -503,8 +503,6 @@ html, body, #app, #memory-tool { height: 100%; position: relative; overflow: hidden; - margin-top: -1em; - padding-bottom: 1em; } /** diff --git a/devtools/client/themes/performance.css b/devtools/client/themes/performance.css index f15d4f6cbf59..3aa9bf2cf072 100644 --- a/devtools/client/themes/performance.css +++ b/devtools/client/themes/performance.css @@ -105,9 +105,12 @@ /* Sidebar & recording items */ +#recordings-pane { + border-inline-end: 1px solid var(--theme-splitter-color); +} + #recordings-list { max-width: 300px; - border-inline-end: 1px solid var(--theme-splitter-color); } .recording-item { @@ -166,11 +169,7 @@ display: none; } -#performance-view[e10s="disabled"] .realtime-disabled-on-e10s-message { - display: initial; - opacity: 0.5; - -} +#performance-view[e10s="disabled"] .realtime-disabled-on-e10s-message, #performance-view[e10s="unsupported"] .realtime-disabled-message { display: initial; opacity: 0.5; diff --git a/devtools/client/themes/shadereditor.css b/devtools/client/themes/shadereditor.css index 4f774699180f..8b169a2667a0 100644 --- a/devtools/client/themes/shadereditor.css +++ b/devtools/client/themes/shadereditor.css @@ -6,7 +6,6 @@ .notice-container { margin-top: -50vh; - background-color: var(--theme-toolbar-background); color: var(--theme-body-color-alt); } @@ -24,10 +23,6 @@ min-width: 150px; } -#shaders-pane + .devtools-side-splitter { - border-color: transparent; -} - .program-item { padding: 2px 0px; } diff --git a/devtools/client/themes/webaudioeditor.css b/devtools/client/themes/webaudioeditor.css index f028b3297e7a..3fa60529c115 100644 --- a/devtools/client/themes/webaudioeditor.css +++ b/devtools/client/themes/webaudioeditor.css @@ -5,7 +5,6 @@ /* Reload and waiting notices */ .notice-container { margin-top: -50vh; - background-color: var(--theme-toolbar-background); color: var(--theme-body-color-alt); } @@ -62,15 +61,7 @@ g.edgeLabel tspan { .nodes rect { stroke-width: 1px; cursor: pointer; -} - -.nodes rect { stroke: var(--theme-tab-toolbar-background); -} -.theme-light rect { - fill: var(--theme-tab-toolbar-background); -} -.theme-dark rect { fill: var(--theme-toolbar-background); } diff --git a/devtools/client/themes/webconsole.css b/devtools/client/themes/webconsole.css index 2dcfdb9e16ec..9ea1780e9015 100644 --- a/devtools/client/themes/webconsole.css +++ b/devtools/client/themes/webconsole.css @@ -128,14 +128,12 @@ a { #output-wrapper { direction: ltr; overflow: auto; -} - -#output-container { - /* This width is set to a hardcoded px in webconsole.js since it's way - faster than using 100% with -moz-box-flex (see Bug 1237368) */ -moz-user-select: text; } +/* The width on #output-container is set to a hardcoded px in webconsole.js + since it's way faster than using 100% with -moz-box-flex (see Bug 1237368) */ + #output-container.hideTimestamps > .message { -moz-padding-start: 0; -moz-margin-start: 7px; diff --git a/devtools/server/actors/worker.js b/devtools/server/actors/worker.js index 6a47a0992343..3bba99498c94 100644 --- a/devtools/server/actors/worker.js +++ b/devtools/server/actors/worker.js @@ -342,6 +342,23 @@ let ServiceWorkerRegistrationActor = protocol.ActorClass({ response: RetVal("json") }), + unregister: method(function() { + let { principal, scope } = this._registration; + let unregisterCallback = { + unregisterSucceeded: function() {}, + unregisterFailed: function() { + console.error("Failed to unregister the service worker for " + scope); + }, + QueryInterface: XPCOMUtils.generateQI( + [Ci.nsIServiceWorkerUnregisterCallback]) + }; + swm.propagateUnregister(principal, unregisterCallback, scope); + + return { type: "unregistered" }; + }, { + request: {}, + response: RetVal("json") + }), }); function ServiceWorkerRegistrationActorList(conn) { diff --git a/devtools/shared/Parser.jsm b/devtools/shared/Parser.jsm index b4131f110c18..34bebd95308a 100644 --- a/devtools/shared/Parser.jsm +++ b/devtools/shared/Parser.jsm @@ -5,10 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const Ci = Components.interfaces; const Cu = Components.utils; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Console.jsm"); const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); const DevToolsUtils = require("devtools/shared/DevToolsUtils"); @@ -30,16 +30,16 @@ Parser.prototype = { /** * Gets a collection of parser methods for a specified source. * - * @param string aSource + * @param string source * The source text content. - * @param string aUrl [optional] + * @param string url [optional] * The source url. The AST nodes will be cached, so you can use this * identifier to avoid parsing the whole source again. */ - get: function(aSource, aUrl = "") { + get: function(source, url = "") { // Try to use the cached AST nodes, to avoid useless parsing operations. - if (this._cache.has(aUrl)) { - return this._cache.get(aUrl); + if (this._cache.has(url)) { + return this._cache.get(url); } // The source may not necessarily be JS, in which case we need to extract @@ -51,9 +51,9 @@ Parser.prototype = { let scriptMatches = []; let scriptMatch; - if (aSource.match(/^\s*") { - this._trees = aSyntaxTrees; - this._url = aUrl; +function SyntaxTreesPool(syntaxTrees, url = "") { + this._trees = syntaxTrees; + this._url = url; this._cache = new Map(); } @@ -145,14 +144,15 @@ SyntaxTreesPool.prototype = { * @see SyntaxTree.prototype.getIdentifierAt */ getIdentifierAt: function({ line, column, scriptIndex, ignoreLiterals }) { - return this._call("getIdentifierAt", scriptIndex, line, column, ignoreLiterals)[0]; + return this._call("getIdentifierAt", + scriptIndex, line, column, ignoreLiterals)[0]; }, /** * @see SyntaxTree.prototype.getNamedFunctionDefinitions */ - getNamedFunctionDefinitions: function(aSubstring) { - return this._call("getNamedFunctionDefinitions", -1, aSubstring); + getNamedFunctionDefinitions: function(substring) { + return this._call("getNamedFunctionDefinitions", -1, substring); }, /** @@ -175,17 +175,17 @@ SyntaxTreesPool.prototype = { * Finds the start and length of the script containing the specified offset * relative to its parent source. * - * @param number aOffset + * @param number atOffset * The offset relative to the parent source. * @return object * The offset and length relative to the enclosing script. */ - getScriptInfo: function(aOffset) { + getScriptInfo: function(atOffset) { let info = { start: -1, length: -1, index: -1 }; for (let { offset, length } of this._trees) { info.index++; - if (offset <= aOffset && offset + length >= aOffset) { + if (offset <= atOffset && offset + length >= atOffset) { info.start = offset; info.length = length; return info; @@ -199,31 +199,31 @@ SyntaxTreesPool.prototype = { /** * Handles a request for a specific or all known syntax trees. * - * @param string aFunction + * @param string functionName * The function name to call on the SyntaxTree instances. - * @param number aSyntaxTreeIndex + * @param number syntaxTreeIndex * The syntax tree for which to handle the request. If the tree at * the specified index isn't found, the accumulated results for all * syntax trees are returned. - * @param any aParams + * @param any params * Any kind params to pass to the request function. * @return array * The results given by all known syntax trees. */ - _call: function(aFunction, aSyntaxTreeIndex, ...aParams) { + _call: function(functionName, syntaxTreeIndex, ...params) { let results = []; - let requestId = [aFunction, aSyntaxTreeIndex, aParams].toSource(); + let requestId = [functionName, syntaxTreeIndex, params].toSource(); if (this._cache.has(requestId)) { return this._cache.get(requestId); } - let requestedTree = this._trees[aSyntaxTreeIndex]; + let requestedTree = this._trees[syntaxTreeIndex]; let targettedTrees = requestedTree ? [requestedTree] : this._trees; for (let syntaxTree of targettedTrees) { try { - let parseResults = syntaxTree[aFunction].apply(syntaxTree, aParams); + let parseResults = syntaxTree[functionName].apply(syntaxTree, params); if (parseResults) { parseResults.sourceUrl = syntaxTree.url; parseResults.scriptLength = syntaxTree.length; @@ -234,7 +234,8 @@ SyntaxTreesPool.prototype = { // Can't guarantee that the tree traversal logic is forever perfect :) // Language features may be added, in which case the recursive methods // need to be updated. If an exception is thrown here, file a bug. - DevToolsUtils.reportException("Syntax tree visitor for " + this._url, e); + DevToolsUtils.reportException( + `Syntax tree visitor for ${this._url}`, e); } } this._cache.set(requestId, results); @@ -248,50 +249,50 @@ SyntaxTreesPool.prototype = { /** * A collection of AST nodes generated by the reflection API. * - * @param object aNodes + * @param object nodes * The AST nodes. - * @param string aUrl + * @param string url * The source url. - * @param number aLength + * @param number length * The total number of chars of the parsed script in the parent source. - * @param number aOffset [optional] + * @param number offset [optional] * The char offset of the parsed script in the parent source. */ -function SyntaxTree(aNodes, aUrl, aLength, aOffset = 0) { - this.AST = aNodes; - this.url = aUrl; - this.length = aLength; - this.offset = aOffset; -}; +function SyntaxTree(nodes, url, length, offset = 0) { + this.AST = nodes; + this.url = url; + this.length = length; + this.offset = offset; +} SyntaxTree.prototype = { /** * Gets the identifier at the specified location. * - * @param number aLine + * @param number line * The line in the source. - * @param number aColumn + * @param number column * The column in the source. - * @param boolean aIgnoreLiterals + * @param boolean ignoreLiterals * Specifies if alone literals should be ignored. * @return object * An object containing identifier information as { name, location, * evalString } properties, or null if nothing is found. */ - getIdentifierAt: function(aLine, aColumn, aIgnoreLiterals) { + getIdentifierAt: function(line, column, ignoreLiterals) { let info = null; SyntaxTreeVisitor.walk(this.AST, { /** * Callback invoked for each identifier node. - * @param Node aNode + * @param Node node */ - onIdentifier: function(aNode) { - if (ParserHelpers.nodeContainsPoint(aNode, aLine, aColumn)) { + onIdentifier: function(node) { + if (ParserHelpers.nodeContainsPoint(node, line, column)) { info = { - name: aNode.name, - location: ParserHelpers.getNodeLocation(aNode), - evalString: ParserHelpers.getIdentifierEvalString(aNode) + name: node.name, + location: ParserHelpers.getNodeLocation(node), + evalString: ParserHelpers.getIdentifierEvalString(node) }; // Abruptly halt walking the syntax tree. @@ -301,20 +302,20 @@ SyntaxTree.prototype = { /** * Callback invoked for each literal node. - * @param Node aNode + * @param Node node */ - onLiteral: function(aNode) { - if (!aIgnoreLiterals) { - this.onIdentifier(aNode); + onLiteral: function(node) { + if (!ignoreLiterals) { + this.onIdentifier(node); } }, /** * Callback invoked for each 'this' node. - * @param Node aNode + * @param Node node */ - onThisExpression: function(aNode) { - this.onIdentifier(aNode); + onThisExpression: function(node) { + this.onIdentifier(node); } }); @@ -325,54 +326,57 @@ SyntaxTree.prototype = { * Searches for all function definitions (declarations and expressions) * whose names (or inferred names) contain a string. * - * @param string aSubstring + * @param string substring * The string to be contained in the function name (or inferred name). * Can be an empty string to match all functions. * @return array * All the matching function declarations and expressions, as * { functionName, functionLocation ... } object hashes. */ - getNamedFunctionDefinitions: function(aSubstring) { - let lowerCaseToken = aSubstring.toLowerCase(); + getNamedFunctionDefinitions: function(substring) { + let lowerCaseToken = substring.toLowerCase(); let store = []; + function includesToken(name) { + return name && name.toLowerCase().includes(lowerCaseToken); + } + SyntaxTreeVisitor.walk(this.AST, { /** * Callback invoked for each function declaration node. - * @param Node aNode + * @param Node node */ - onFunctionDeclaration: function(aNode) { - let functionName = aNode.id.name; - if (functionName.toLowerCase().includes(lowerCaseToken)) { + onFunctionDeclaration: function(node) { + let functionName = node.id.name; + if (includesToken(functionName)) { store.push({ functionName: functionName, - functionLocation: ParserHelpers.getNodeLocation(aNode) + functionLocation: ParserHelpers.getNodeLocation(node) }); } }, /** * Callback invoked for each function expression node. - * @param Node aNode + * @param Node node */ - onFunctionExpression: function(aNode) { + onFunctionExpression: function(node) { // Function expressions don't necessarily have a name. - let functionName = aNode.id ? aNode.id.name : ""; - let functionLocation = ParserHelpers.getNodeLocation(aNode); + let functionName = node.id ? node.id.name : ""; + let functionLocation = ParserHelpers.getNodeLocation(node); // Infer the function's name from an enclosing syntax tree node. - let inferredInfo = ParserHelpers.inferFunctionExpressionInfo(aNode); + let inferredInfo = ParserHelpers.inferFunctionExpressionInfo(node); let inferredName = inferredInfo.name; let inferredChain = inferredInfo.chain; let inferredLocation = inferredInfo.loc; // Current node may be part of a larger assignment expression stack. - if (aNode._parent.type == "AssignmentExpression") { - this.onFunctionExpression(aNode._parent); + if (node._parent.type == "AssignmentExpression") { + this.onFunctionExpression(node._parent); } - if ((functionName && functionName.toLowerCase().includes(lowerCaseToken)) || - (inferredName && inferredName.toLowerCase().includes(lowerCaseToken))) { + if (includesToken(functionName) || includesToken(inferredName)) { store.push({ functionName: functionName, functionLocation: functionLocation, @@ -385,21 +389,21 @@ SyntaxTree.prototype = { /** * Callback invoked for each arrow expression node. - * @param Node aNode + * @param Node node */ - onArrowFunctionExpression: function(aNode) { + onArrowFunctionExpression: function(node) { // Infer the function's name from an enclosing syntax tree node. - let inferredInfo = ParserHelpers.inferFunctionExpressionInfo(aNode); + let inferredInfo = ParserHelpers.inferFunctionExpressionInfo(node); let inferredName = inferredInfo.name; let inferredChain = inferredInfo.chain; let inferredLocation = inferredInfo.loc; // Current node may be part of a larger assignment expression stack. - if (aNode._parent.type == "AssignmentExpression") { - this.onFunctionExpression(aNode._parent); + if (node._parent.type == "AssignmentExpression") { + this.onFunctionExpression(node._parent); } - if (inferredName && inferredName.toLowerCase().includes(lowerCaseToken)) { + if (includesToken(inferredName)) { store.push({ inferredName: inferredName, inferredChain: inferredChain, @@ -427,19 +431,19 @@ var ParserHelpers = { * location property directly attached, or the location information * is incorrect, in which cases it's accessible via the parent. * - * @param Node aNode + * @param Node node * The node who's location needs to be retrieved. * @return object * An object containing { line, column } information. */ - getNodeLocation: function(aNode) { - if (aNode.type != "Identifier") { - return aNode.loc; + getNodeLocation: function(node) { + if (node.type != "Identifier") { + return node.loc; } // Work around the fact that some identifier nodes don't have the // correct location attached. - let { loc: parentLocation, type: parentType } = aNode._parent; - let { loc: nodeLocation } = aNode; + let { loc: parentLocation, type: parentType } = node._parent; + let { loc: nodeLocation } = node; if (!nodeLocation) { if (parentType == "FunctionDeclaration" || parentType == "FunctionExpression") { @@ -447,7 +451,7 @@ var ParserHelpers = { // The location is unavailable for the identifier node "foo". let loc = Cu.cloneInto(parentLocation, {}); loc.end.line = loc.start.line; - loc.end.column = loc.start.column + aNode.name.length; + loc.end.column = loc.start.column + node.name.length; return loc; } if (parentType == "MemberExpression") { @@ -455,7 +459,7 @@ var ParserHelpers = { // The location is unavailable for the identifier node "bar". let loc = Cu.cloneInto(parentLocation, {}); loc.start.line = loc.end.line; - loc.start.column = loc.end.column - aNode.name.length; + loc.start.column = loc.end.column - node.name.length; return loc; } if (parentType == "LabeledStatement") { @@ -463,7 +467,7 @@ var ParserHelpers = { // The location is unavailable for the identifier node "label". let loc = Cu.cloneInto(parentLocation, {}); loc.end.line = loc.start.line; - loc.end.column = loc.start.column + aNode.name.length; + loc.end.column = loc.start.column + node.name.length; return loc; } if (parentType == "ContinueStatement" || parentType == "BreakStatement") { @@ -471,69 +475,67 @@ var ParserHelpers = { // The location is unavailable for the identifier node "label". let loc = Cu.cloneInto(parentLocation, {}); loc.start.line = loc.end.line; - loc.start.column = loc.end.column - aNode.name.length; - return loc; - } - } else { - if (parentType == "VariableDeclarator") { - // e.g. "let foo = 42" - // The location incorrectly spans across the whole variable declaration, - // not just the identifier node "foo". - let loc = Cu.cloneInto(nodeLocation, {}); - loc.end.line = loc.start.line; - loc.end.column = loc.start.column + aNode.name.length; + loc.start.column = loc.end.column - node.name.length; return loc; } + } else if (parentType == "VariableDeclarator") { + // e.g. "let foo = 42" + // The location incorrectly spans across the whole variable declaration, + // not just the identifier node "foo". + let loc = Cu.cloneInto(nodeLocation, {}); + loc.end.line = loc.start.line; + loc.end.column = loc.start.column + node.name.length; + return loc; } - return aNode.loc; + return node.loc; }, /** * Checks if a node's bounds contains a specified line. * - * @param Node aNode + * @param Node node * The node's bounds used as reference. - * @param number aLine + * @param number line * The line number to check. * @return boolean * True if the line and column is contained in the node's bounds. */ - nodeContainsLine: function(aNode, aLine) { - let { start: s, end: e } = this.getNodeLocation(aNode); - return s.line <= aLine && e.line >= aLine; + nodeContainsLine: function(node, line) { + let { start: s, end: e } = this.getNodeLocation(node); + return s.line <= line && e.line >= line; }, /** * Checks if a node's bounds contains a specified line and column. * - * @param Node aNode + * @param Node node * The node's bounds used as reference. - * @param number aLine + * @param number line * The line number to check. - * @param number aColumn + * @param number column * The column number to check. * @return boolean * True if the line and column is contained in the node's bounds. */ - nodeContainsPoint: function(aNode, aLine, aColumn) { - let { start: s, end: e } = this.getNodeLocation(aNode); - return s.line == aLine && e.line == aLine && - s.column <= aColumn && e.column >= aColumn; + nodeContainsPoint: function(node, line, column) { + let { start: s, end: e } = this.getNodeLocation(node); + return s.line == line && e.line == line && + s.column <= column && e.column >= column; }, /** * Try to infer a function expression's name & other details based on the * enclosing VariableDeclarator, AssignmentExpression or ObjectExpression. * - * @param Node aNode + * @param Node node * The function expression node to get the name for. * @return object * The inferred function name, or empty string can't infer the name, * along with the chain (a generic "context", like a prototype chain) * and location if available. */ - inferFunctionExpressionInfo: function(aNode) { - let parent = aNode._parent; + inferFunctionExpressionInfo: function(node) { + let parent = node._parent; // A function expression may be defined in a variable declarator, // e.g. var foo = function(){}, in which case it is possible to infer @@ -563,7 +565,7 @@ var ParserHelpers = { // e.g. { foo: function(){} }, then it is possible to infer the name // from the corresponding property. if (parent.type == "ObjectExpression") { - let propertyKey = this._getObjectExpressionPropertyKeyForValue(aNode); + let propertyKey = this._getObjectExpressionPropertyKeyForValue(node); let propertyChain = this._getObjectExpressionPropertyChain(parent); let propertyLeaf = propertyKey.name; return { @@ -588,21 +590,22 @@ var ParserHelpers = { * Used for inferring function expression information and retrieving * an identifier evaluation string. * - * For example, if aNode represents the "bar" identifier in a hypothetical - * "{ foo: bar }" object expression, the returned node is the "foo" identifier. + * For example, if "node" represents the "bar" identifier in a hypothetical + * "{ foo: bar }" object expression, the returned node is the "foo" + * identifier. * - * @param Node aNode + * @param Node node * The value node in an object expression. * @return object * The key identifier node in the object expression. */ - _getObjectExpressionPropertyKeyForValue: function(aNode) { - let parent = aNode._parent; + _getObjectExpressionPropertyKeyForValue: function(node) { + let parent = node._parent; if (parent.type != "ObjectExpression") { return null; } for (let property of parent.properties) { - if (property.value == aNode) { + if (property.value == node) { return property.key; } } @@ -615,42 +618,42 @@ var ParserHelpers = { * Used for inferring function expression information and retrieving * an identifier evaluation string. * - * For example, if aNode represents the "baz: {}" object expression in a + * For example, if node represents the "baz: {}" object expression in a * hypothetical "foo = { bar: { baz: {} } }" assignment expression, the * returned chain is ["foo", "bar", "baz"]. * - * @param Node aNode + * @param Node node * The object expression node to begin the scan from. * @param array aStore [optional] * The chain to store the nodes into. * @return array * The chain to the parent variable declarator, as strings. */ - _getObjectExpressionPropertyChain: function(aNode, aStore = []) { - switch (aNode.type) { + _getObjectExpressionPropertyChain: function(node, aStore = []) { + switch (node.type) { case "ObjectExpression": - this._getObjectExpressionPropertyChain(aNode._parent, aStore); - let propertyKey = this._getObjectExpressionPropertyKeyForValue(aNode); + this._getObjectExpressionPropertyChain(node._parent, aStore); + let propertyKey = this._getObjectExpressionPropertyKeyForValue(node); if (propertyKey) { aStore.push(propertyKey.name); } break; // Handle "var foo = { ... }" variable declarators. case "VariableDeclarator": - aStore.push(aNode.id.name); + aStore.push(node.id.name); break; // Handle "foo.bar = { ... }" assignment expressions, since they're // commonly used when defining an object's prototype methods; e.g: // "Foo.prototype = { ... }". case "AssignmentExpression": - this._getMemberExpressionPropertyChain(aNode.left, aStore); + this._getMemberExpressionPropertyChain(node.left, aStore); break; // Additionally handle stuff like "foo = bar.baz({ ... })", because it's // commonly used in prototype-based inheritance in many libraries; e.g: // "Foo = Bar.extend({ ... })". case "NewExpression": case "CallExpression": - this._getObjectExpressionPropertyChain(aNode._parent, aStore); + this._getObjectExpressionPropertyChain(node._parent, aStore); break; } return aStore; @@ -662,70 +665,71 @@ var ParserHelpers = { * Used for inferring function expression information and retrieving * an identifier evaluation string. * - * For example, if aNode represents a hypothetical "foo.bar.baz" + * For example, if node represents a hypothetical "foo.bar.baz" * member expression, the returned chain ["foo", "bar", "baz"]. * * More complex expressions like foo.bar().baz are intentionally not handled. * - * @param Node aNode + * @param Node node * The member expression node to begin the scan from. - * @param array aStore [optional] + * @param array store [optional] * The chain to store the nodes into. * @return array * The full member chain, as strings. */ - _getMemberExpressionPropertyChain: function(aNode, aStore = []) { - switch (aNode.type) { + _getMemberExpressionPropertyChain: function(node, store = []) { + switch (node.type) { case "MemberExpression": - this._getMemberExpressionPropertyChain(aNode.object, aStore); - this._getMemberExpressionPropertyChain(aNode.property, aStore); + this._getMemberExpressionPropertyChain(node.object, store); + this._getMemberExpressionPropertyChain(node.property, store); break; case "ThisExpression": - aStore.push("this"); + store.push("this"); break; case "Identifier": - aStore.push(aNode.name); + store.push(node.name); break; } - return aStore; + return store; }, /** * Returns an evaluation string which can be used to obtain the * current value for the respective identifier. * - * @param Node aNode + * @param Node node * The leaf node (e.g. Identifier, Literal) to begin the scan from. * @return string * The corresponding evaluation string, or empty string if * the specified leaf node can't be used. */ - getIdentifierEvalString: function(aNode) { - switch (aNode._parent.type) { + getIdentifierEvalString: function(node) { + switch (node._parent.type) { case "ObjectExpression": // If the identifier is the actual property value, it can be used // directly as an evaluation string. Otherwise, construct the property // access chain, since the value might have changed. - if (!this._getObjectExpressionPropertyKeyForValue(aNode)) { - let propertyChain = this._getObjectExpressionPropertyChain(aNode._parent); - let propertyLeaf = aNode.name; + if (!this._getObjectExpressionPropertyKeyForValue(node)) { + let propertyChain = + this._getObjectExpressionPropertyChain(node._parent); + let propertyLeaf = node.name; return [...propertyChain, propertyLeaf].join("."); } break; case "MemberExpression": // Make sure this is a property identifier, not the parent object. - if (aNode._parent.property == aNode) { - return this._getMemberExpressionPropertyChain(aNode._parent).join("."); + if (node._parent.property == node) { + return this._getMemberExpressionPropertyChain(node._parent).join("."); } break; } - switch (aNode.type) { + switch (node.type) { case "ThisExpression": return "this"; case "Identifier": - return aNode.name; + return node.name; case "Literal": - return uneval(aNode.value); + return uneval(node.value); default: return ""; } @@ -746,30 +750,36 @@ var SyntaxTreeVisitor = { /** * Walks a syntax tree. * - * @param object aTree + * @param object tree * The AST nodes generated by the reflection API - * @param object aCallbacks + * @param object callbacks * A map of all the callbacks to invoke when passing through certain * types of noes (e.g: onFunctionDeclaration, onBlockStatement etc.). */ - walk: function(aTree, aCallbacks) { + walk: function(tree, callbacks) { this.break = false; - this[aTree.type](aTree, aCallbacks); + this[tree.type](tree, callbacks); }, /** * Filters all the nodes in this syntax tree based on a predicate. * - * @param object aTree + * @param object tree * The AST nodes generated by the reflection API - * @param function aPredicate + * @param function predicate * The predicate ran on each node. * @return array * An array of nodes validating the predicate. */ - filter: function(aTree, aPredicate) { + filter: function(tree, predicate) { let store = []; - this.walk(aTree, { onNode: e => { if (aPredicate(e)) store.push(e); } }); + this.walk(tree, { + onNode: e => { + if (predicate(e)) { + store.push(e); + } + } + }); return store; }, @@ -787,12 +797,12 @@ var SyntaxTreeVisitor = { * body: [ Statement ]; * } */ - Program: function(aNode, aCallbacks) { - if (aCallbacks.onProgram) { - aCallbacks.onProgram(aNode); + Program: function(node, callbacks) { + if (callbacks.onProgram) { + callbacks.onProgram(node); } - for (let statement of aNode.body) { - this[statement.type](statement, aNode, aCallbacks); + for (let statement of node.body) { + this[statement.type](statement, node, callbacks); } }, @@ -801,19 +811,19 @@ var SyntaxTreeVisitor = { * * interface Statement <: Node { } */ - Statement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + Statement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onStatement) { - aCallbacks.onStatement(aNode); + if (callbacks.onStatement) { + callbacks.onStatement(node); } }, @@ -824,19 +834,19 @@ var SyntaxTreeVisitor = { * type: "EmptyStatement"; * } */ - EmptyStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + EmptyStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onEmptyStatement) { - aCallbacks.onEmptyStatement(aNode); + if (callbacks.onEmptyStatement) { + callbacks.onEmptyStatement(node); } }, @@ -848,48 +858,49 @@ var SyntaxTreeVisitor = { * body: [ Statement ]; * } */ - BlockStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + BlockStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onBlockStatement) { - aCallbacks.onBlockStatement(aNode); + if (callbacks.onBlockStatement) { + callbacks.onBlockStatement(node); } - for (let statement of aNode.body) { - this[statement.type](statement, aNode, aCallbacks); + for (let statement of node.body) { + this[statement.type](statement, node, callbacks); } }, /** - * An expression statement, i.e., a statement consisting of a single expression. + * An expression statement, i.e., a statement consisting of a single + * expression. * * interface ExpressionStatement <: Statement { * type: "ExpressionStatement"; * expression: Expression; * } */ - ExpressionStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ExpressionStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onExpressionStatement) { - aCallbacks.onExpressionStatement(aNode); + if (callbacks.onExpressionStatement) { + callbacks.onExpressionStatement(node); } - this[aNode.expression.type](aNode.expression, aNode, aCallbacks); + this[node.expression.type](node.expression, node, callbacks); }, /** @@ -902,24 +913,24 @@ var SyntaxTreeVisitor = { * alternate: Statement | null; * } */ - IfStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + IfStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onIfStatement) { - aCallbacks.onIfStatement(aNode); + if (callbacks.onIfStatement) { + callbacks.onIfStatement(node); } - this[aNode.test.type](aNode.test, aNode, aCallbacks); - this[aNode.consequent.type](aNode.consequent, aNode, aCallbacks); - if (aNode.alternate) { - this[aNode.alternate.type](aNode.alternate, aNode, aCallbacks); + this[node.test.type](node.test, node, callbacks); + this[node.consequent.type](node.consequent, node, callbacks); + if (node.alternate) { + this[node.alternate.type](node.alternate, node, callbacks); } }, @@ -932,22 +943,22 @@ var SyntaxTreeVisitor = { * body: Statement; * } */ - LabeledStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + LabeledStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onLabeledStatement) { - aCallbacks.onLabeledStatement(aNode); + if (callbacks.onLabeledStatement) { + callbacks.onLabeledStatement(node); } - this[aNode.label.type](aNode.label, aNode, aCallbacks); - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.label.type](node.label, node, callbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -958,22 +969,22 @@ var SyntaxTreeVisitor = { * label: Identifier | null; * } */ - BreakStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + BreakStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onBreakStatement) { - aCallbacks.onBreakStatement(aNode); + if (callbacks.onBreakStatement) { + callbacks.onBreakStatement(node); } - if (aNode.label) { - this[aNode.label.type](aNode.label, aNode, aCallbacks); + if (node.label) { + this[node.label.type](node.label, node, callbacks); } }, @@ -985,22 +996,22 @@ var SyntaxTreeVisitor = { * label: Identifier | null; * } */ - ContinueStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ContinueStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onContinueStatement) { - aCallbacks.onContinueStatement(aNode); + if (callbacks.onContinueStatement) { + callbacks.onContinueStatement(node); } - if (aNode.label) { - this[aNode.label.type](aNode.label, aNode, aCallbacks); + if (node.label) { + this[node.label.type](node.label, node, callbacks); } }, @@ -1013,22 +1024,22 @@ var SyntaxTreeVisitor = { * body: Statement; * } */ - WithStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + WithStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onWithStatement) { - aCallbacks.onWithStatement(aNode); + if (callbacks.onWithStatement) { + callbacks.onWithStatement(node); } - this[aNode.object.type](aNode.object, aNode, aCallbacks); - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.object.type](node.object, node, callbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -1043,23 +1054,23 @@ var SyntaxTreeVisitor = { * lexical: boolean; * } */ - SwitchStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + SwitchStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onSwitchStatement) { - aCallbacks.onSwitchStatement(aNode); + if (callbacks.onSwitchStatement) { + callbacks.onSwitchStatement(node); } - this[aNode.discriminant.type](aNode.discriminant, aNode, aCallbacks); - for (let _case of aNode.cases) { - this[_case.type](_case, aNode, aCallbacks); + this[node.discriminant.type](node.discriminant, node, callbacks); + for (let _case of node.cases) { + this[_case.type](_case, node, callbacks); } }, @@ -1071,22 +1082,22 @@ var SyntaxTreeVisitor = { * argument: Expression | null; * } */ - ReturnStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ReturnStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onReturnStatement) { - aCallbacks.onReturnStatement(aNode); + if (callbacks.onReturnStatement) { + callbacks.onReturnStatement(node); } - if (aNode.argument) { - this[aNode.argument.type](aNode.argument, aNode, aCallbacks); + if (node.argument) { + this[node.argument.type](node.argument, node, callbacks); } }, @@ -1098,21 +1109,21 @@ var SyntaxTreeVisitor = { * argument: Expression; * } */ - ThrowStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ThrowStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onThrowStatement) { - aCallbacks.onThrowStatement(aNode); + if (callbacks.onThrowStatement) { + callbacks.onThrowStatement(node); } - this[aNode.argument.type](aNode.argument, aNode, aCallbacks); + this[node.argument.type](node.argument, node, callbacks); }, /** @@ -1126,29 +1137,29 @@ var SyntaxTreeVisitor = { * finalizer: BlockStatement | null; * } */ - TryStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + TryStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onTryStatement) { - aCallbacks.onTryStatement(aNode); + if (callbacks.onTryStatement) { + callbacks.onTryStatement(node); } - this[aNode.block.type](aNode.block, aNode, aCallbacks); - if (aNode.handler) { - this[aNode.handler.type](aNode.handler, aNode, aCallbacks); + this[node.block.type](node.block, node, callbacks); + if (node.handler) { + this[node.handler.type](node.handler, node, callbacks); } - for (let guardedHandler of aNode.guardedHandlers) { - this[guardedHandler.type](guardedHandler, aNode, aCallbacks); + for (let guardedHandler of node.guardedHandlers) { + this[guardedHandler.type](guardedHandler, node, callbacks); } - if (aNode.finalizer) { - this[aNode.finalizer.type](aNode.finalizer, aNode, aCallbacks); + if (node.finalizer) { + this[node.finalizer.type](node.finalizer, node, callbacks); } }, @@ -1161,22 +1172,22 @@ var SyntaxTreeVisitor = { * body: Statement; * } */ - WhileStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + WhileStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onWhileStatement) { - aCallbacks.onWhileStatement(aNode); + if (callbacks.onWhileStatement) { + callbacks.onWhileStatement(node); } - this[aNode.test.type](aNode.test, aNode, aCallbacks); - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.test.type](node.test, node, callbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -1188,22 +1199,22 @@ var SyntaxTreeVisitor = { * test: Expression; * } */ - DoWhileStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + DoWhileStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onDoWhileStatement) { - aCallbacks.onDoWhileStatement(aNode); + if (callbacks.onDoWhileStatement) { + callbacks.onDoWhileStatement(node); } - this[aNode.body.type](aNode.body, aNode, aCallbacks); - this[aNode.test.type](aNode.test, aNode, aCallbacks); + this[node.body.type](node.body, node, callbacks); + this[node.test.type](node.test, node, callbacks); }, /** @@ -1217,30 +1228,30 @@ var SyntaxTreeVisitor = { * body: Statement; * } */ - ForStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ForStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onForStatement) { - aCallbacks.onForStatement(aNode); + if (callbacks.onForStatement) { + callbacks.onForStatement(node); } - if (aNode.init) { - this[aNode.init.type](aNode.init, aNode, aCallbacks); + if (node.init) { + this[node.init.type](node.init, node, callbacks); } - if (aNode.test) { - this[aNode.test.type](aNode.test, aNode, aCallbacks); + if (node.test) { + this[node.test.type](node.test, node, callbacks); } - if (aNode.update) { - this[aNode.update.type](aNode.update, aNode, aCallbacks); + if (node.update) { + this[node.update.type](node.update, node, callbacks); } - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -1254,23 +1265,23 @@ var SyntaxTreeVisitor = { * each: boolean; * } */ - ForInStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ForInStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onForInStatement) { - aCallbacks.onForInStatement(aNode); + if (callbacks.onForInStatement) { + callbacks.onForInStatement(node); } - this[aNode.left.type](aNode.left, aNode, aCallbacks); - this[aNode.right.type](aNode.right, aNode, aCallbacks); - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.left.type](node.left, node, callbacks); + this[node.right.type](node.right, node, callbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -1283,23 +1294,23 @@ var SyntaxTreeVisitor = { * body: Statement; * } */ - ForOfStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ForOfStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onForOfStatement) { - aCallbacks.onForOfStatement(aNode); + if (callbacks.onForOfStatement) { + callbacks.onForOfStatement(node); } - this[aNode.left.type](aNode.left, aNode, aCallbacks); - this[aNode.right.type](aNode.right, aNode, aCallbacks); - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.left.type](node.left, node, callbacks); + this[node.right.type](node.right, node, callbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -1311,27 +1322,27 @@ var SyntaxTreeVisitor = { * body: Statement; * } */ - LetStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + LetStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onLetStatement) { - aCallbacks.onLetStatement(aNode); + if (callbacks.onLetStatement) { + callbacks.onLetStatement(node); } - for (let { id, init } of aNode.head) { - this[id.type](id, aNode, aCallbacks); + for (let { id, init } of node.head) { + this[id.type](id, node, callbacks); if (init) { - this[init.type](init, aNode, aCallbacks); + this[init.type](init, node, callbacks); } } - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -1341,19 +1352,19 @@ var SyntaxTreeVisitor = { * type: "DebuggerStatement"; * } */ - DebuggerStatement: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + DebuggerStatement: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onDebuggerStatement) { - aCallbacks.onDebuggerStatement(aNode); + if (callbacks.onDebuggerStatement) { + callbacks.onDebuggerStatement(node); } }, @@ -1364,19 +1375,19 @@ var SyntaxTreeVisitor = { * * interface Declaration <: Statement { } */ - Declaration: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + Declaration: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onDeclaration) { - aCallbacks.onDeclaration(aNode); + if (callbacks.onDeclaration) { + callbacks.onDeclaration(node); } }, @@ -1394,31 +1405,33 @@ var SyntaxTreeVisitor = { * expression: boolean; * } */ - FunctionDeclaration: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + FunctionDeclaration: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onFunctionDeclaration) { - aCallbacks.onFunctionDeclaration(aNode); + if (callbacks.onFunctionDeclaration) { + callbacks.onFunctionDeclaration(node); } - this[aNode.id.type](aNode.id, aNode, aCallbacks); - for (let param of aNode.params) { - this[param.type](param, aNode, aCallbacks); + this[node.id.type](node.id, node, callbacks); + for (let param of node.params) { + this[param.type](param, node, callbacks); } - for (let _default of aNode.defaults) { - this[_default.type](_default, aNode, aCallbacks); + for (let _default of node.defaults) { + if (_default) { + this[_default.type](_default, node, callbacks); + } } - if (aNode.rest) { - this[aNode.rest.type](aNode.rest, aNode, aCallbacks); + if (node.rest) { + this[node.rest.type](node.rest, node, callbacks); } - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -1430,22 +1443,22 @@ var SyntaxTreeVisitor = { * kind: "var" | "let" | "const"; * } */ - VariableDeclaration: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + VariableDeclaration: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onVariableDeclaration) { - aCallbacks.onVariableDeclaration(aNode); + if (callbacks.onVariableDeclaration) { + callbacks.onVariableDeclaration(node); } - for (let declaration of aNode.declarations) { - this[declaration.type](declaration, aNode, aCallbacks); + for (let declaration of node.declarations) { + this[declaration.type](declaration, node, callbacks); } }, @@ -1458,23 +1471,23 @@ var SyntaxTreeVisitor = { * init: Expression | null; * } */ - VariableDeclarator: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + VariableDeclarator: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onVariableDeclarator) { - aCallbacks.onVariableDeclarator(aNode); + if (callbacks.onVariableDeclarator) { + callbacks.onVariableDeclarator(node); } - this[aNode.id.type](aNode.id, aNode, aCallbacks); - if (aNode.init) { - this[aNode.init.type](aNode.init, aNode, aCallbacks); + this[node.id.type](node.id, node, callbacks); + if (node.init) { + this[node.init.type](node.init, node, callbacks); } }, @@ -1484,19 +1497,19 @@ var SyntaxTreeVisitor = { * * interface Expression <: Node, Pattern { } */ - Expression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + Expression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onExpression) { - aCallbacks.onExpression(aNode); + if (callbacks.onExpression) { + callbacks.onExpression(node); } }, @@ -1507,19 +1520,19 @@ var SyntaxTreeVisitor = { * type: "ThisExpression"; * } */ - ThisExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ThisExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onThisExpression) { - aCallbacks.onThisExpression(aNode); + if (callbacks.onThisExpression) { + callbacks.onThisExpression(node); } }, @@ -1531,29 +1544,52 @@ var SyntaxTreeVisitor = { * elements: [ Expression | null ]; * } */ - ArrayExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ArrayExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onArrayExpression) { - aCallbacks.onArrayExpression(aNode); + if (callbacks.onArrayExpression) { + callbacks.onArrayExpression(node); } - for (let element of aNode.elements) { - // TODO: remove the typeof check when support for SpreadExpression is - // added (bug 890913). - if (element && typeof this[element.type] == "function") { - this[element.type](element, aNode, aCallbacks); + for (let element of node.elements) { + if (element) { + this[element.type](element, node, callbacks); } } }, + /** + * A spread expression. + * + * interface SpreadExpression <: Expression { + * type: "SpreadExpression"; + * expression: Expression; + * } + */ + SpreadExpression: function(node, parent, callbacks) { + node._parent = parent; + + if (this.break) { + return; + } + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { + return; + } + } + if (callbacks.onSpreadExpression) { + callbacks.onSpreadExpression(node); + } + this[node.expression.type](node.expression, node, callbacks); + }, + /** * An object expression. A literal property in an object expression can have * either a string or number as its value. Ordinary property initializers @@ -1567,23 +1603,23 @@ var SyntaxTreeVisitor = { * kind: "init" | "get" | "set" } ]; * } */ - ObjectExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ObjectExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onObjectExpression) { - aCallbacks.onObjectExpression(aNode); + if (callbacks.onObjectExpression) { + callbacks.onObjectExpression(node); } - for (let { key, value } of aNode.properties) { - this[key.type](key, aNode, aCallbacks); - this[value.type](value, aNode, aCallbacks); + for (let { key, value } of node.properties) { + this[key.type](key, node, callbacks); + this[value.type](value, node, callbacks); } }, @@ -1601,33 +1637,35 @@ var SyntaxTreeVisitor = { * expression: boolean; * } */ - FunctionExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + FunctionExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onFunctionExpression) { - aCallbacks.onFunctionExpression(aNode); + if (callbacks.onFunctionExpression) { + callbacks.onFunctionExpression(node); } - if (aNode.id) { - this[aNode.id.type](aNode.id, aNode, aCallbacks); + if (node.id) { + this[node.id.type](node.id, node, callbacks); } - for (let param of aNode.params) { - this[param.type](param, aNode, aCallbacks); + for (let param of node.params) { + this[param.type](param, node, callbacks); } - for (let _default of aNode.defaults) { - this[_default.type](_default, aNode, aCallbacks); + for (let _default of node.defaults) { + if (_default) { + this[_default.type](_default, node, callbacks); + } } - if (aNode.rest) { - this[aNode.rest.type](aNode.rest, aNode, aCallbacks); + if (node.rest) { + this[node.rest.type](node.rest, node, callbacks); } - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -1643,30 +1681,32 @@ var SyntaxTreeVisitor = { * expression: boolean; * } */ - ArrowFunctionExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ArrowFunctionExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onArrowFunctionExpression) { - aCallbacks.onArrowFunctionExpression(aNode); + if (callbacks.onArrowFunctionExpression) { + callbacks.onArrowFunctionExpression(node); } - for (let param of aNode.params) { - this[param.type](param, aNode, aCallbacks); + for (let param of node.params) { + this[param.type](param, node, callbacks); } - for (let _default of aNode.defaults) { - this[_default.type](_default, aNode, aCallbacks); + for (let _default of node.defaults) { + if (_default) { + this[_default.type](_default, node, callbacks); + } } - if (aNode.rest) { - this[aNode.rest.type](aNode.rest, aNode, aCallbacks); + if (node.rest) { + this[node.rest.type](node.rest, node, callbacks); } - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -1677,22 +1717,22 @@ var SyntaxTreeVisitor = { * expressions: [ Expression ]; * } */ - SequenceExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + SequenceExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onSequenceExpression) { - aCallbacks.onSequenceExpression(aNode); + if (callbacks.onSequenceExpression) { + callbacks.onSequenceExpression(node); } - for (let expression of aNode.expressions) { - this[expression.type](expression, aNode, aCallbacks); + for (let expression of node.expressions) { + this[expression.type](expression, node, callbacks); } }, @@ -1706,21 +1746,21 @@ var SyntaxTreeVisitor = { * argument: Expression; * } */ - UnaryExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + UnaryExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onUnaryExpression) { - aCallbacks.onUnaryExpression(aNode); + if (callbacks.onUnaryExpression) { + callbacks.onUnaryExpression(node); } - this[aNode.argument.type](aNode.argument, aNode, aCallbacks); + this[node.argument.type](node.argument, node, callbacks); }, /** @@ -1733,22 +1773,22 @@ var SyntaxTreeVisitor = { * right: Expression; * } */ - BinaryExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + BinaryExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onBinaryExpression) { - aCallbacks.onBinaryExpression(aNode); + if (callbacks.onBinaryExpression) { + callbacks.onBinaryExpression(node); } - this[aNode.left.type](aNode.left, aNode, aCallbacks); - this[aNode.right.type](aNode.right, aNode, aCallbacks); + this[node.left.type](node.left, node, callbacks); + this[node.right.type](node.right, node, callbacks); }, /** @@ -1761,22 +1801,22 @@ var SyntaxTreeVisitor = { * right: Expression; * } */ - AssignmentExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + AssignmentExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onAssignmentExpression) { - aCallbacks.onAssignmentExpression(aNode); + if (callbacks.onAssignmentExpression) { + callbacks.onAssignmentExpression(node); } - this[aNode.left.type](aNode.left, aNode, aCallbacks); - this[aNode.right.type](aNode.right, aNode, aCallbacks); + this[node.left.type](node.left, node, callbacks); + this[node.right.type](node.right, node, callbacks); }, /** @@ -1789,21 +1829,21 @@ var SyntaxTreeVisitor = { * prefix: boolean; * } */ - UpdateExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + UpdateExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onUpdateExpression) { - aCallbacks.onUpdateExpression(aNode); + if (callbacks.onUpdateExpression) { + callbacks.onUpdateExpression(node); } - this[aNode.argument.type](aNode.argument, aNode, aCallbacks); + this[node.argument.type](node.argument, node, callbacks); }, /** @@ -1816,22 +1856,22 @@ var SyntaxTreeVisitor = { * right: Expression; * } */ - LogicalExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + LogicalExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onLogicalExpression) { - aCallbacks.onLogicalExpression(aNode); + if (callbacks.onLogicalExpression) { + callbacks.onLogicalExpression(node); } - this[aNode.left.type](aNode.left, aNode, aCallbacks); - this[aNode.right.type](aNode.right, aNode, aCallbacks); + this[node.left.type](node.left, node, callbacks); + this[node.right.type](node.right, node, callbacks); }, /** @@ -1844,23 +1884,23 @@ var SyntaxTreeVisitor = { * consequent: Expression; * } */ - ConditionalExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ConditionalExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onConditionalExpression) { - aCallbacks.onConditionalExpression(aNode); + if (callbacks.onConditionalExpression) { + callbacks.onConditionalExpression(node); } - this[aNode.test.type](aNode.test, aNode, aCallbacks); - this[aNode.alternate.type](aNode.alternate, aNode, aCallbacks); - this[aNode.consequent.type](aNode.consequent, aNode, aCallbacks); + this[node.test.type](node.test, node, callbacks); + this[node.alternate.type](node.alternate, node, callbacks); + this[node.consequent.type](node.consequent, node, callbacks); }, /** @@ -1872,24 +1912,24 @@ var SyntaxTreeVisitor = { * arguments: [ Expression | null ]; * } */ - NewExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + NewExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onNewExpression) { - aCallbacks.onNewExpression(aNode); + if (callbacks.onNewExpression) { + callbacks.onNewExpression(node); } - this[aNode.callee.type](aNode.callee, aNode, aCallbacks); - for (let argument of aNode.arguments) { + this[node.callee.type](node.callee, node, callbacks); + for (let argument of node.arguments) { if (argument) { - this[argument.type](argument, aNode, aCallbacks); + this[argument.type](argument, node, callbacks); } } }, @@ -1903,24 +1943,27 @@ var SyntaxTreeVisitor = { * arguments: [ Expression | null ]; * } */ - CallExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + CallExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onCallExpression) { - aCallbacks.onCallExpression(aNode); + if (callbacks.onCallExpression) { + callbacks.onCallExpression(node); } - this[aNode.callee.type](aNode.callee, aNode, aCallbacks); - for (let argument of aNode.arguments) { + this[node.callee.type](node.callee, node, callbacks); + for (let argument of node.arguments) { if (argument) { - this[argument.type](argument, aNode, aCallbacks); + if (!this[argument.type]) { + console.error("Unknown parser object:", argument.type); + } + this[argument.type](argument, node, callbacks); } } }, @@ -1938,22 +1981,22 @@ var SyntaxTreeVisitor = { * computed: boolean; * } */ - MemberExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + MemberExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onMemberExpression) { - aCallbacks.onMemberExpression(aNode); + if (callbacks.onMemberExpression) { + callbacks.onMemberExpression(node); } - this[aNode.object.type](aNode.object, aNode, aCallbacks); - this[aNode.property.type](aNode.property, aNode, aCallbacks); + this[node.object.type](node.object, node, callbacks); + this[node.property.type](node.property, node, callbacks); }, /** @@ -1963,22 +2006,22 @@ var SyntaxTreeVisitor = { * argument: Expression | null; * } */ - YieldExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + YieldExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onYieldExpression) { - aCallbacks.onYieldExpression(aNode); + if (callbacks.onYieldExpression) { + callbacks.onYieldExpression(node); } - if (aNode.argument) { - this[aNode.argument.type](aNode.argument, aNode, aCallbacks); + if (node.argument) { + this[node.argument.type](node.argument, node, callbacks); } }, @@ -1993,26 +2036,26 @@ var SyntaxTreeVisitor = { * filter: Expression | null; * } */ - ComprehensionExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ComprehensionExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onComprehensionExpression) { - aCallbacks.onComprehensionExpression(aNode); + if (callbacks.onComprehensionExpression) { + callbacks.onComprehensionExpression(node); } - this[aNode.body.type](aNode.body, aNode, aCallbacks); - for (let block of aNode.blocks) { - this[block.type](block, aNode, aCallbacks); + this[node.body.type](node.body, node, callbacks); + for (let block of node.blocks) { + this[block.type](block, node, callbacks); } - if (aNode.filter) { - this[aNode.filter.type](aNode.filter, aNode, aCallbacks); + if (node.filter) { + this[node.filter.type](node.filter, node, callbacks); } }, @@ -2027,26 +2070,26 @@ var SyntaxTreeVisitor = { * filter: Expression | null; * } */ - GeneratorExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + GeneratorExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onGeneratorExpression) { - aCallbacks.onGeneratorExpression(aNode); + if (callbacks.onGeneratorExpression) { + callbacks.onGeneratorExpression(node); } - this[aNode.body.type](aNode.body, aNode, aCallbacks); - for (let block of aNode.blocks) { - this[block.type](block, aNode, aCallbacks); + this[node.body.type](node.body, node, callbacks); + for (let block of node.blocks) { + this[block.type](block, node, callbacks); } - if (aNode.filter) { - this[aNode.filter.type](aNode.filter, aNode, aCallbacks); + if (node.filter) { + this[node.filter.type](node.filter, node, callbacks); } }, @@ -2058,21 +2101,21 @@ var SyntaxTreeVisitor = { * expression: Literal; * } */ - GraphExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + GraphExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onGraphExpression) { - aCallbacks.onGraphExpression(aNode); + if (callbacks.onGraphExpression) { + callbacks.onGraphExpression(node); } - this[aNode.expression.type](aNode.expression, aNode, aCallbacks); + this[node.expression.type](node.expression, node, callbacks); }, /** @@ -2082,19 +2125,19 @@ var SyntaxTreeVisitor = { * index: uint32; * } */ - GraphIndexExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + GraphIndexExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onGraphIndexExpression) { - aCallbacks.onGraphIndexExpression(aNode); + if (callbacks.onGraphIndexExpression) { + callbacks.onGraphIndexExpression(node); } }, @@ -2107,27 +2150,27 @@ var SyntaxTreeVisitor = { * body: Expression; * } */ - LetExpression: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + LetExpression: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onLetExpression) { - aCallbacks.onLetExpression(aNode); + if (callbacks.onLetExpression) { + callbacks.onLetExpression(node); } - for (let { id, init } of aNode.head) { - this[id.type](id, aNode, aCallbacks); + for (let { id, init } of node.head) { + this[id.type](id, node, callbacks); if (init) { - this[init.type](init, aNode, aCallbacks); + this[init.type](init, node, callbacks); } } - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -2135,19 +2178,19 @@ var SyntaxTreeVisitor = { * * interface Pattern <: Node { } */ - Pattern: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + Pattern: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onPattern) { - aCallbacks.onPattern(aNode); + if (callbacks.onPattern) { + callbacks.onPattern(node); } }, @@ -2160,23 +2203,23 @@ var SyntaxTreeVisitor = { * properties: [ { key: Literal | Identifier, value: Pattern } ]; * } */ - ObjectPattern: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ObjectPattern: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onObjectPattern) { - aCallbacks.onObjectPattern(aNode); + if (callbacks.onObjectPattern) { + callbacks.onObjectPattern(node); } - for (let { key, value } of aNode.properties) { - this[key.type](key, aNode, aCallbacks); - this[value.type](value, aNode, aCallbacks); + for (let { key, value } of node.properties) { + this[key.type](key, node, callbacks); + this[value.type](value, node, callbacks); } }, @@ -2188,23 +2231,23 @@ var SyntaxTreeVisitor = { * elements: [ Pattern | null ]; * } */ - ArrayPattern: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ArrayPattern: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onArrayPattern) { - aCallbacks.onArrayPattern(aNode); + if (callbacks.onArrayPattern) { + callbacks.onArrayPattern(node); } - for (let element of aNode.elements) { + for (let element of node.elements) { if (element) { - this[element.type](element, aNode, aCallbacks); + this[element.type](element, node, callbacks); } } }, @@ -2219,25 +2262,25 @@ var SyntaxTreeVisitor = { * consequent: [ Statement ]; * } */ - SwitchCase: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + SwitchCase: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onSwitchCase) { - aCallbacks.onSwitchCase(aNode); + if (callbacks.onSwitchCase) { + callbacks.onSwitchCase(node); } - if (aNode.test) { - this[aNode.test.type](aNode.test, aNode, aCallbacks); + if (node.test) { + this[node.test.type](node.test, node, callbacks); } - for (let consequent of aNode.consequent) { - this[consequent.type](consequent, aNode, aCallbacks); + for (let consequent of node.consequent) { + this[consequent.type](consequent, node, callbacks); } }, @@ -2252,25 +2295,25 @@ var SyntaxTreeVisitor = { * body: BlockStatement; * } */ - CatchClause: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + CatchClause: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onCatchClause) { - aCallbacks.onCatchClause(aNode); + if (callbacks.onCatchClause) { + callbacks.onCatchClause(node); } - this[aNode.param.type](aNode.param, aNode, aCallbacks); - if (aNode.guard) { - this[aNode.guard.type](aNode.guard, aNode, aCallbacks); + this[node.param.type](node.param, node, callbacks); + if (node.guard) { + this[node.guard.type](node.guard, node, callbacks); } - this[aNode.body.type](aNode.body, aNode, aCallbacks); + this[node.body.type](node.body, node, callbacks); }, /** @@ -2282,22 +2325,22 @@ var SyntaxTreeVisitor = { * each: boolean; * } */ - ComprehensionBlock: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + ComprehensionBlock: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onComprehensionBlock) { - aCallbacks.onComprehensionBlock(aNode); + if (callbacks.onComprehensionBlock) { + callbacks.onComprehensionBlock(node); } - this[aNode.left.type](aNode.left, aNode, aCallbacks); - this[aNode.right.type](aNode.right, aNode, aCallbacks); + this[node.left.type](node.left, node, callbacks); + this[node.right.type](node.right, node, callbacks); }, /** @@ -2309,19 +2352,19 @@ var SyntaxTreeVisitor = { * name: string; * } */ - Identifier: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + Identifier: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onIdentifier) { - aCallbacks.onIdentifier(aNode); + if (callbacks.onIdentifier) { + callbacks.onIdentifier(node); } }, @@ -2333,19 +2376,48 @@ var SyntaxTreeVisitor = { * value: string | boolean | null | number | RegExp; * } */ - Literal: function(aNode, aParent, aCallbacks) { - aNode._parent = aParent; + Literal: function(node, parent, callbacks) { + node._parent = parent; if (this.break) { return; } - if (aCallbacks.onNode) { - if (aCallbacks.onNode(aNode, aParent) === false) { + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { return; } } - if (aCallbacks.onLiteral) { - aCallbacks.onLiteral(aNode); + if (callbacks.onLiteral) { + callbacks.onLiteral(node); + } + }, + + /** + * A template string literal. + * + * interface TemplateLiteral <: Node { + * type: "TemplateLiteral"; + * elements: [ Expression ]; + * } + */ + TemplateLiteral: function(node, parent, callbacks) { + node._parent = parent; + + if (this.break) { + return; + } + if (callbacks.onNode) { + if (callbacks.onNode(node, parent) === false) { + return; + } + } + if (callbacks.onTemplateLiteral) { + callbacks.onTemplateLiteral(node); + } + for (let element of node.elements) { + if (element) { + this[element.type](element, node, callbacks); + } } } }; diff --git a/devtools/shared/heapsnapshot/shortest-paths.js b/devtools/shared/heapsnapshot/shortest-paths.js index 60a7c57eea91..2d97b7de93c9 100644 --- a/devtools/shared/heapsnapshot/shortest-paths.js +++ b/devtools/shared/heapsnapshot/shortest-paths.js @@ -48,8 +48,20 @@ exports.deduplicatePaths = function (target, paths) { nameSet.add(name); } - for (let path of paths) { + outer: for (let path of paths) { const pathLength = path.length; + + // Check for duplicate predecessors in the path, and skip paths that contain + // them. + const predecessorsSeen = new Set(); + predecessorsSeen.add(target); + for (let i = 0; i < pathLength; i++) { + if (predecessorsSeen.has(path[i].predecessor)) { + continue outer; + } + predecessorsSeen.add(path[i].predecessor); + } + for (let i = 0; i < pathLength - 1; i++) { insert(path[i].predecessor, path[i + 1].predecessor, path[i].edge); } diff --git a/devtools/shared/heapsnapshot/tests/unit/test_deduplicatePaths_01.js b/devtools/shared/heapsnapshot/tests/unit/test_deduplicatePaths_01.js index 49590b2396cd..418b49db3256 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_deduplicatePaths_01.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_deduplicatePaths_01.js @@ -104,12 +104,10 @@ function run_test() { pathEntry(f, "f->g"), ], ], - expectedNodes: [a, b, f, g], + expectedNodes: [a, b, g], expectedEdges: [ edge(a, b, "a->b"), edge(b, g, "b->g"), - edge(g, f, "g->f"), - edge(f, g, "f->g"), ] }); } diff --git a/devtools/shared/webconsole/js-property-provider.js b/devtools/shared/webconsole/js-property-provider.js index 8d8fec164618..b39d800e221d 100644 --- a/devtools/shared/webconsole/js-property-provider.js +++ b/devtools/shared/webconsole/js-property-provider.js @@ -455,7 +455,7 @@ function getExactMatchImpl(obj, name, {chainIterator, getProperty}) { } var JSObjectSupport = { - chainIterator: function*(obj) { + chainIterator: function* (obj) { while (obj) { yield obj; obj = Object.getPrototypeOf(obj); @@ -473,7 +473,7 @@ var JSObjectSupport = { }; var DebuggerObjectSupport = { - chainIterator: function*(obj) { + chainIterator: function* (obj) { while (obj) { yield obj; obj = obj.proto; @@ -491,7 +491,7 @@ var DebuggerObjectSupport = { }; var DebuggerEnvironmentSupport = { - chainIterator: function*(obj) { + chainIterator: function* (obj) { while (obj) { yield obj; obj = obj.parent; diff --git a/devtools/shared/webconsole/server-logger-monitor.js b/devtools/shared/webconsole/server-logger-monitor.js index 665e03cc8f95..0060786f88ab 100644 --- a/devtools/shared/webconsole/server-logger-monitor.js +++ b/devtools/shared/webconsole/server-logger-monitor.js @@ -111,6 +111,7 @@ var ServerLoggerMonitor = { return this.onDetachChild(msg); default: trace.log("Unknown method name: ", method); + return undefined; } }, diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp index 889e326a7d93..2c75577a8a76 100644 --- a/dom/promise/Promise.cpp +++ b/dom/promise/Promise.cpp @@ -2635,15 +2635,22 @@ Promise::Settle(JS::Handle aValue, PromiseState aState) mSettlementTimestamp = TimeStamp::Now(); - SetResult(aValue); - SetState(aState); - AutoJSAPI jsapi; jsapi.Init(); JSContext* cx = jsapi.cx(); JS::RootedObject wrapper(cx, GetWrapper()); MOZ_ASSERT(wrapper); // We preserved it JSAutoCompartment ac(cx, wrapper); + + JS::Rooted value(cx, aValue); + + if (!JS_WrapValue(cx, &value)) { + JS_ClearPendingException(cx); + value = JS::UndefinedValue(); + } + SetResult(value); + SetState(aState); + JS::dbg::onPromiseSettled(cx, wrapper); if (aState == PromiseState::Rejected && diff --git a/mobile/android/app/checkstyle.xml b/mobile/android/app/checkstyle.xml index 55ca93901628..64fe71c112ba 100644 --- a/mobile/android/app/checkstyle.xml +++ b/mobile/android/app/checkstyle.xml @@ -49,6 +49,10 @@ + + + + diff --git a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java index 228345965740..98fca4102dd8 100644 --- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java +++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java @@ -961,7 +961,7 @@ public abstract class GeckoApp SnackbarHelper.showSnackbar(this, getString(R.string.set_image_path_fail), Snackbar.LENGTH_LONG); return; } - String path = Media.insertImage(getContentResolver(),image, null, null); + String path = Media.insertImage(getContentResolver(), image, null, null); if (path == null) { SnackbarHelper.showSnackbar(this, getString(R.string.set_image_path_fail), Snackbar.LENGTH_LONG); return; @@ -2236,12 +2236,12 @@ public abstract class GeckoApp } public void addEnvToIntent(Intent intent) { - Map envMap = System.getenv(); - Set> envSet = envMap.entrySet(); - Iterator> envIter = envSet.iterator(); + Map envMap = System.getenv(); + Set> envSet = envMap.entrySet(); + Iterator> envIter = envSet.iterator(); int c = 0; while (envIter.hasNext()) { - Map.Entry entry = envIter.next(); + Map.Entry entry = envIter.next(); intent.putExtra("env" + c, entry.getKey() + "=" + entry.getValue()); c++; diff --git a/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java b/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java index 96e973511c1c..49dd1871bd78 100644 --- a/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java +++ b/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java @@ -1070,13 +1070,6 @@ public class GeckoAppShell vibrator().cancel(); } - @WrapForJNI - public static void showInputMethodPicker() { - InputMethodManager imm = (InputMethodManager) - getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showInputMethodPicker(); - } - @WrapForJNI public static void setKeepScreenOn(final boolean on) { ThreadUtils.postToUiThread(new Runnable() { diff --git a/mobile/android/base/java/org/mozilla/gecko/db/TabsProvider.java b/mobile/android/base/java/org/mozilla/gecko/db/TabsProvider.java index 6a0d3f50d180..09e4d9cf5e86 100644 --- a/mobile/android/base/java/org/mozilla/gecko/db/TabsProvider.java +++ b/mobile/android/base/java/org/mozilla/gecko/db/TabsProvider.java @@ -328,7 +328,7 @@ public class TabsProvider extends SharedBrowserDatabaseProvider { // Use a subquery to quietly exclude stale duplicate client records. qb.setTables(excludeStaleClientsTable + " AS " + TABLE_CLIENTS + " LEFT OUTER JOIN " + TABLE_TABS + " ON (" + projectColumn(TABLE_CLIENTS, Clients.GUID) + - " = " + projectColumn(TABLE_TABS,Tabs.CLIENT_GUID) + ")"); + " = " + projectColumn(TABLE_TABS, Tabs.CLIENT_GUID) + ")"); groupBy = projectColumn(TABLE_CLIENTS, Clients.GUID); break; diff --git a/mobile/android/base/java/org/mozilla/gecko/gfx/Axis.java b/mobile/android/base/java/org/mozilla/gecko/gfx/Axis.java index fae1b9396e61..2e4330e9659d 100644 --- a/mobile/android/base/java/org/mozilla/gecko/gfx/Axis.java +++ b/mobile/android/base/java/org/mozilla/gecko/gfx/Axis.java @@ -188,14 +188,14 @@ abstract class Axis { private final SubdocumentScrollHelper mSubscroller; private int mOverscrollMode; /* Default to only overscrolling if we're allowed to scroll in a direction */ - private float mFirstTouchPos; /* Position of the first touch event on the current drag. */ - private float mTouchPos; /* Position of the most recent touch event on the current drag. */ - private float mLastTouchPos; /* Position of the touch event before touchPos. */ - private float mVelocity; /* Velocity in this direction; pixels per animation frame. */ - private final float[] mRecentVelocities;/* Circular buffer of recent velocities since last touch start. */ - private int mRecentVelocityCount; /* Number of values put into mRecentVelocities (unbounded). */ - private boolean mScrollingDisabled; /* Whether movement on this axis is locked. */ - private boolean mDisableSnap; /* Whether overscroll snapping is disabled. */ + private float mFirstTouchPos; /* Position of the first touch event on the current drag. */ + private float mTouchPos; /* Position of the most recent touch event on the current drag. */ + private float mLastTouchPos; /* Position of the touch event before touchPos. */ + private float mVelocity; /* Velocity in this direction; pixels per animation frame. */ + private final float[] mRecentVelocities; /* Circular buffer of recent velocities since last touch start. */ + private int mRecentVelocityCount; /* Number of values put into mRecentVelocities (unbounded). */ + private boolean mScrollingDisabled; /* Whether movement on this axis is locked. */ + private boolean mDisableSnap; /* Whether overscroll snapping is disabled. */ private float mDisplacement; private long mLastFlingTime; private float mLastFlingVelocity; diff --git a/mobile/android/base/java/org/mozilla/gecko/gfx/BitmapUtils.java b/mobile/android/base/java/org/mozilla/gecko/gfx/BitmapUtils.java index ad48f8cb87e2..b5cc7248bf35 100644 --- a/mobile/android/base/java/org/mozilla/gecko/gfx/BitmapUtils.java +++ b/mobile/android/base/java/org/mozilla/gecko/gfx/BitmapUtils.java @@ -278,7 +278,7 @@ public final class BitmapUtils { public static int getDominantColor(Bitmap source, boolean applyThreshold) { if (source == null) - return Color.argb(255,255,255,255); + return Color.argb(255, 255, 255, 255); // Keep track of how many times a hue in a given bin appears in the image. // Hue values range [0 .. 360), so dividing by 10, we get 36 bins. @@ -331,7 +331,7 @@ public final class BitmapUtils { // maxBin may never get updated if the image holds only transparent and/or black/white pixels. if (maxBin < 0) - return Color.argb(255,255,255,255); + return Color.argb(255, 255, 255, 255); // Return a color with the average hue/saturation/value of the bin with the most colors. hsv[0] = sumHue[maxBin]/colorBins[maxBin]; diff --git a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryAdapter.java b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryAdapter.java index 14674d336830..6b075db02fb7 100644 --- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryAdapter.java +++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryAdapter.java @@ -254,7 +254,7 @@ public class CombinedHistoryAdapter extends RecyclerView.Adapter DEFAULT_COLORS = Arrays.asList(Color.rgb(215,57,32), - Color.rgb(255,134,5), - Color.rgb(255,203,19), - Color.rgb(95,173,71), - Color.rgb(84,201,168), - Color.rgb(33,161,222), - Color.rgb(16,36,87), - Color.rgb(91,32,103), - Color.rgb(212,221,228), + private final static List DEFAULT_COLORS = Arrays.asList(Color.rgb(215, 57, 32), + Color.rgb(255, 134, 5), + Color.rgb(255, 203, 19), + Color.rgb(95, 173, 71), + Color.rgb(84, 201, 168), + Color.rgb(33, 161, 222), + Color.rgb(16, 36, 87), + Color.rgb(91, 32, 103), + Color.rgb(212, 221, 228), Color.BLACK); private static Drawable mCheckDrawable; diff --git a/mobile/android/base/java/org/mozilla/gecko/widget/DateTimePicker.java b/mobile/android/base/java/org/mozilla/gecko/widget/DateTimePicker.java index 3248014ce7cb..a7a6d376e350 100644 --- a/mobile/android/base/java/org/mozilla/gecko/widget/DateTimePicker.java +++ b/mobile/android/base/java/org/mozilla/gecko/widget/DateTimePicker.java @@ -122,7 +122,7 @@ public class DateTimePicker extends FrameLayout { setTempDate(Calendar.WEEK_OF_YEAR, old, newVal, 0, maxWeekOfYear); } else if (picker == mYearSpinner && mYearEnabled) { int month = mTempDate.get(Calendar.MONTH); - mTempDate.set(Calendar.YEAR,newVal); + mTempDate.set(Calendar.YEAR, newVal); // Changing the year shouldn't change the month. (in case of non-leap year a Feb 29) // change the day instead; if (month != mTempDate.get(Calendar.MONTH)) { @@ -139,12 +139,12 @@ public class DateTimePicker extends FrameLayout { } else if (picker == mMinuteSpinner && mMinuteEnabled) { setTempDate(Calendar.MINUTE, oldVal, newVal, 0, 59); } else if (picker == mAMPMSpinner && mHourEnabled) { - mTempDate.set(Calendar.AM_PM,newVal); + mTempDate.set(Calendar.AM_PM, newVal); } else { throw new IllegalArgumentException(); } } else { - if (DEBUG) Log.d(LOGTAG,"Sdk version < 10, using old behavior"); + if (DEBUG) Log.d(LOGTAG, "Sdk version < 10, using old behavior"); if (picker == mDaySpinner && mDayEnabled){ mTempDate.set(Calendar.DAY_OF_MONTH, newVal); } else if (picker == mMonthSpinner && mMonthEnabled){ @@ -325,13 +325,13 @@ public class DateTimePicker extends FrameLayout { mScreenWidth >= SCREEN_SIZE_THRESHOLD) { if (DEBUG) { - Log.d(LOGTAG,"SDK > 10 and screen wide enough, displaying calendar"); + Log.d(LOGTAG, "SDK > 10 and screen wide enough, displaying calendar"); } mCalendar = new CalendarView(context); mCalendar.setVisibility(GONE); - LayoutParams layoutParams = new LayoutParams(250,280); + LayoutParams layoutParams = new LayoutParams(250, 280); mCalendar.setLayoutParams(layoutParams); mCalendar.setFocusable(true); mCalendar.setFocusableInTouchMode(true); diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index ed04a967b70d..387656258daa 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -471,17 +471,17 @@ &bookmarks_addons; - https://addons.mozilla.org/android/ + https://addons.mozilla.org/android?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid &bookmarks_support; - https://support.mozilla.org/products/mobile + https://support.mozilla.org/products/mobile?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid &bookmarks_restricted_webmaker; https://webmaker.org/ &bookmarks_restricted_support2; - https://support.mozilla.org/kb/controlledaccess + https://support.mozilla.org/kb/controlledaccess?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid &identity_connection_secure; diff --git a/mobile/android/config/mozconfigs/android-api-15-gradle-dependencies/nightly b/mobile/android/config/mozconfigs/android-api-15-gradle-dependencies/nightly index 035387ea1632..32b08b61bea2 100644 --- a/mobile/android/config/mozconfigs/android-api-15-gradle-dependencies/nightly +++ b/mobile/android/config/mozconfigs/android-api-15-gradle-dependencies/nightly @@ -10,6 +10,7 @@ MOZ_AUTOMATION_UPLOAD=0 MOZ_AUTOMATION_UPLOAD_SYMBOLS=0 NO_CACHE=1 +NO_NDK=1 . "$topsrcdir/mobile/android/config/mozconfigs/common" @@ -18,11 +19,11 @@ ac_add_options --with-gradle # We want to use (and populate!) the local Nexus repository. export GRADLE_MAVEN_REPOSITORY="http://localhost:8081/nexus/content/repositories/central/" +# From here on, just like ../android-api-15-frontend/nightly. + ac_add_options --disable-compile-environment ac_add_options --disable-tests -# From here on, like ../android-api-15/nightly. - ac_add_options --enable-profiling # Android diff --git a/python/mach_commands.py b/python/mach_commands.py index f81aa8f52aad..b8dbb10ebcd6 100644 --- a/python/mach_commands.py +++ b/python/mach_commands.py @@ -166,7 +166,18 @@ class MachCommands(MachCommandBase): try: binary = which.which('eslint') except which.WhichError: - pass + npmPath = self.getNodeOrNpmPath("npm") + if npmPath: + try: + output = subprocess.check_output([npmPath, "bin", "-g"], + stderr=subprocess.STDOUT) + if minversion: + base = output.split("\n").strip() + binary = os.path.join(base, "eslint") + if not os.path.is_file(binary): + binary = None + except (subprocess.CalledProcessError, WindowsError): + pass if not binary: print(ESLINT_NOT_FOUND_MESSAGE) @@ -213,7 +224,7 @@ class MachCommands(MachCommandBase): # Note that that's the version currently compatible with the mozilla # eslint plugin. success = self.callProcess("eslint", - [npmPath, "install", "eslint@1.10.3", "-g"]) + [npmPath, "install", "eslint@2.7.0", "-g"]) if not success: return 1 @@ -226,13 +237,13 @@ class MachCommands(MachCommandBase): # Install eslint-plugin-html. success = self.callProcess("eslint-plugin-html", - [npmPath, "install", "eslint-plugin-html", "-g"]) + [npmPath, "install", "eslint-plugin-html@1.4.0", "-g"]) if not success: return 1 # Install eslint-plugin-react. success = self.callProcess("eslint-plugin-react", - [npmPath, "install", "eslint-plugin-react", "-g"]) + [npmPath, "install", "eslint-plugin-react@4.2.3", "-g"]) if not success: return 1 diff --git a/security/manager/.eslintrc.json b/security/manager/.eslintrc.json index 4a93f602c0d5..94fae503e817 100644 --- a/security/manager/.eslintrc.json +++ b/security/manager/.eslintrc.json @@ -33,6 +33,9 @@ // Space after colon not before in property declarations "key-spacing": [2, { "beforeColon": false, "afterColon": true, "mode": "minimum" }], + // Require spaces around keywords + "keyword-spacing": 2, + // Unix linebreaks "linebreak-style": [2, "unix"], @@ -153,27 +156,15 @@ // Always require semicolon at end of statement "semi": [2, "always"], - // Require space after keywords - // Note: Replaced by keyword-spacing in ESLint v2.0. - "space-after-keywords": 2, - // Require space before blocks "space-before-blocks": 2, - // Require spaces before finally, catch, etc. - // Note: Replaced by keyword-spacing in ESLint v2.0. - "space-before-keywords": [2, "always"], - // No space padding in parentheses "space-in-parens": [2, "never"], // Require spaces around operators "space-infix-ops": 2, - // Require spaces after return, throw and case - // Note: Replaced by keyword-spacing in ESLint v2.0. - "space-return-throw-case": 2, - // ++ and -- should not need spacing "space-unary-ops": [2, { "words": true, "nonwords": false }], diff --git a/security/manager/pki/resources/content/createCertInfo.js b/security/manager/pki/resources/content/createCertInfo.js index 48084b19ce08..5e7e9052c626 100644 --- a/security/manager/pki/resources/content/createCertInfo.js +++ b/security/manager/pki/resources/content/createCertInfo.js @@ -20,7 +20,7 @@ function onLoad() window.setCursor("wait"); var obs = { - observe : function keygenListenerObserve(subject, topic, data) { + observe: function keygenListenerObserve(subject, topic, data) { if (topic == "keygen-finished") { window.close(); } diff --git a/security/manager/ssl/tests/unit/test_cert_blocklist.js b/security/manager/ssl/tests/unit/test_cert_blocklist.js index 0057dd7039f6..b7a096601a56 100644 --- a/security/manager/ssl/tests/unit/test_cert_blocklist.js +++ b/security/manager/ssl/tests/unit/test_cert_blocklist.js @@ -107,8 +107,8 @@ var updatedBlocklist = "" + var blocklists = { - "/initialBlocklist/" : initialBlocklist, - "/updatedBlocklist/" : updatedBlocklist + "/initialBlocklist/": initialBlocklist, + "/updatedBlocklist/": updatedBlocklist }; function serveResponse(request, response) { diff --git a/security/manager/ssl/tests/unit/test_signed_apps.js b/security/manager/ssl/tests/unit/test_signed_apps.js index 5ddcaa30dec2..cf3ba6f5c5bf 100644 --- a/security/manager/ssl/tests/unit/test_signed_apps.js +++ b/security/manager/ssl/tests/unit/test_signed_apps.js @@ -167,7 +167,7 @@ add_test(function () { add_test(function () { var tampered = tampered_app_path("missing_rsa"); - tamper(original_app_path("valid_app_1"), tampered, { "META-INF/A.RSA" : removeEntry }, []); + tamper(original_app_path("valid_app_1"), tampered, { "META-INF/A.RSA": removeEntry }, []); certdb.openSignedAppFileAsync( Ci.nsIX509CertDB.AppXPCShellRoot, tampered, check_open_result("missing_rsa", Cr.NS_ERROR_SIGNED_JAR_NOT_SIGNED)); @@ -175,7 +175,7 @@ add_test(function () { add_test(function () { var tampered = tampered_app_path("missing_sf"); - tamper(original_app_path("valid_app_1"), tampered, { "META-INF/A.SF" : removeEntry }, []); + tamper(original_app_path("valid_app_1"), tampered, { "META-INF/A.SF": removeEntry }, []); certdb.openSignedAppFileAsync( Ci.nsIX509CertDB.AppXPCShellRoot, tampered, check_open_result("missing_sf", Cr.NS_ERROR_SIGNED_JAR_MANIFEST_INVALID)); @@ -183,7 +183,7 @@ add_test(function () { add_test(function () { var tampered = tampered_app_path("missing_manifest_mf"); - tamper(original_app_path("valid_app_1"), tampered, { "META-INF/MANIFEST.MF" : removeEntry }, []); + tamper(original_app_path("valid_app_1"), tampered, { "META-INF/MANIFEST.MF": removeEntry }, []); certdb.openSignedAppFileAsync( Ci.nsIX509CertDB.AppXPCShellRoot, tampered, check_open_result("missing_manifest_mf", @@ -192,7 +192,7 @@ add_test(function () { add_test(function () { var tampered = tampered_app_path("missing_entry"); - tamper(original_app_path("valid_app_1"), tampered, { "manifest.webapp" : removeEntry }, []); + tamper(original_app_path("valid_app_1"), tampered, { "manifest.webapp": removeEntry }, []); certdb.openSignedAppFileAsync( Ci.nsIX509CertDB.AppXPCShellRoot, tampered, check_open_result("missing_entry", Cr.NS_ERROR_SIGNED_JAR_ENTRY_MISSING)); @@ -200,7 +200,7 @@ add_test(function () { add_test(function () { var tampered = tampered_app_path("truncated_entry"); - tamper(original_app_path("valid_app_1"), tampered, { "manifest.webapp" : truncateEntry }, []); + tamper(original_app_path("valid_app_1"), tampered, { "manifest.webapp": truncateEntry }, []); certdb.openSignedAppFileAsync( Ci.nsIX509CertDB.AppXPCShellRoot, tampered, check_open_result("truncated_entry", Cr.NS_ERROR_SIGNED_JAR_MODIFIED_ENTRY)); diff --git a/security/manager/ssl/tests/unit/test_weak_crypto.js b/security/manager/ssl/tests/unit/test_weak_crypto.js index e477215ed789..c1160ec3b0ab 100644 --- a/security/manager/ssl/tests/unit/test_weak_crypto.js +++ b/security/manager/ssl/tests/unit/test_weak_crypto.js @@ -178,7 +178,7 @@ function run_test() { } // for sanity check -add_task(function*() { +add_task(function* () { let cert = yield getCert(); ok(!!cert, "Got self-signed cert"); let port = startServer(cert, false); @@ -187,7 +187,7 @@ add_task(function*() { yield startClient(port, Cr.NS_OK, {isPrivate: true}); }); -add_task(function*() { +add_task(function* () { let cert = yield getCert(); ok(!!cert, "Got self-signed cert"); let port = startServer(cert, true); @@ -259,7 +259,7 @@ add_task(function*() { "127.0.0.1"); }); -add_task(function*() { +add_task(function* () { let cert = yield getCert(); ok(!!cert, "Got self-signed cert"); let port = startServer(cert, false); diff --git a/testing/docker/lint/Dockerfile b/testing/docker/lint/Dockerfile index d22d3035a8ba..7dc668f6b844 100644 --- a/testing/docker/lint/Dockerfile +++ b/testing/docker/lint/Dockerfile @@ -6,9 +6,9 @@ WORKDIR /home/worker # install necessary npm packages RUN npm install -g taskcluster-vcs@2.3.12 -RUN npm install -g eslint@1.10.3 -RUN npm install -g eslint-plugin-html@1.1.0 -RUN npm install -g eslint-plugin-react@3.13.1 +RUN npm install -g eslint@2.7.0 +RUN npm install -g eslint-plugin-html@1.4.0 +RUN npm install -g eslint-plugin-react@4.2.3 # Set variable normally configured at login, by the shells parent process, these # are taken from GNU su manual diff --git a/testing/profiles/prefs_general.js b/testing/profiles/prefs_general.js index cdf8a001832f..7aa6d92f3e09 100644 --- a/testing/profiles/prefs_general.js +++ b/testing/profiles/prefs_general.js @@ -98,8 +98,6 @@ user_pref("extensions.hotfix.url", "http://%(server)s/extensions-dummy/hotfixURL user_pref("extensions.systemAddon.update.url", "http://%(server)s/dummy-system-addons.xml"); // Turn off extension updates so they don't bother tests user_pref("extensions.update.enabled", false); -// Bug 1235627 Turn off pocket add-on so it doesn't bother tests -user_pref("extensions.pocket.enabled", false); // Make sure opening about:addons won't hit the network user_pref("extensions.webservice.discoverURL", "http://%(server)s/extensions-dummy/discoveryURL"); // Make sure AddonRepository won't hit the network diff --git a/testing/taskcluster/tasks/branches/base_jobs.yml b/testing/taskcluster/tasks/branches/base_jobs.yml index 66031dceb095..c8a964d0041f 100644 --- a/testing/taskcluster/tasks/branches/base_jobs.yml +++ b/testing/taskcluster/tasks/branches/base_jobs.yml @@ -296,6 +296,7 @@ tasks: root: true when: file_patterns: + - 'mobile/android/config/**' - 'testing/docker/android-gradle-build/**' - 'testing/mozharness/configs/builds/releng_sub_android_configs/*gradle_dependencies.py' - '**/*.gradle' diff --git a/toolkit/.eslintrc b/toolkit/.eslintrc index 7d5da4752436..9b915e7dd001 100644 --- a/toolkit/.eslintrc +++ b/toolkit/.eslintrc @@ -43,6 +43,9 @@ // Space after colon not before in property declarations // "key-spacing": [2, { "beforeColon": false, "afterColon": true, "mode": "minimum" }], + // Require spaces before and after keywords + // "keyword-spacing": 2, + // Unix linebreaks "linebreak-style": [2, "unix"], @@ -163,27 +166,18 @@ // Always require semicolon at end of statement // "semi": [2, "always"], - // Require space after keywords - // "space-after-keywords": 2, - // Require space before blocks // "space-before-blocks": 2, // Never use spaces before function parentheses // "space-before-function-paren": [2, { "anonymous": "always", "named": "never" }], - // Require spaces before finally, catch, etc. - // "space-before-keywords": [2, "always"], - // No space padding in parentheses // "space-in-parens": [2, "never"], // Require spaces around operators // "space-infix-ops": 2, - // Require spaces after return, throw and case - // "space-return-throw-case": 2, - // ++ and -- should not need spacing // "space-unary-ops": [2, { "words": true, "nonwords": false }], diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index c647bdf5706a..54b674d7abf2 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -78,7 +78,7 @@ function assert(aCond, aMsg) { if (!aCond) { reportAssertionFailure(aMsg) - throw(gAssertionFailureMsgPrefix + aMsg); + throw new Error(gAssertionFailureMsgPrefix + aMsg); } } @@ -86,19 +86,19 @@ function assert(aCond, aMsg) function assertInput(aCond, aMsg) { if (!aCond) { - throw "Invalid memory report(s): " + aMsg; + throw new Error("Invalid memory report(s): " + aMsg); } } function handleException(ex) { - let str = ex.toString(); + let str = "" + ex; if (str.startsWith(gAssertionFailureMsgPrefix)) { // Argh, assertion failure within this file! Give up. throw ex; } else { // File or memory reporter problem. Print a message. - updateMainAndFooter(ex.toString(), HIDE_FOOTER, "badInputWarning"); + updateMainAndFooter(str, HIDE_FOOTER, "badInputWarning"); } } @@ -635,8 +635,8 @@ function loadMemoryReportsFromFile(aFilename, aTitleNote, aFn) try { let reader = new FileReader(); - reader.onerror = () => { throw "FileReader.onerror"; }; - reader.onabort = () => { throw "FileReader.onabort"; }; + reader.onerror = () => { throw new Error("FileReader.onerror"); }; + reader.onabort = () => { throw new Error("FileReader.onabort"); }; reader.onload = (aEvent) => { // Clear "Loading..." from above. updateTitleMainAndFooter(aTitleNote, "", SHOW_FOOTER); @@ -661,7 +661,7 @@ function loadMemoryReportsFromFile(aFilename, aTitleNote, aFn) onStopRequest: function(aR, aC, aStatusCode) { try { if (!Components.isSuccessCode(aStatusCode)) { - throw aStatusCode; + throw new Components.Exception("Error while reading gzip file", aStatusCode); } reader.readAsText(new Blob(this.data)); } catch (ex) { @@ -1166,7 +1166,7 @@ TreeNode.prototype = { case UNITS_COUNT_CUMULATIVE: return formatInt(this._amount); case UNITS_PERCENTAGE: return formatPercentage(this._amount); default: - assertInput(false, "bad units in TreeNode.toString"); + throw "Invalid memory report(s): bad units in TreeNode.toString"; } } }; diff --git a/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul b/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul index c195d401de10..c712070cc24f 100644 --- a/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul +++ b/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul @@ -275,7 +275,7 @@ End of Main Process (pid NNN)\n\ // This is the output for a malformed data file. let expectedBad = "\ -Invalid memory report(s): missing 'hasMozMallocUsableSize' property\ +Error: Invalid memory report(s): missing 'hasMozMallocUsableSize' property\ "; // This is the output for a non-verbose diff. diff --git a/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul b/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul index 50ce29fbd349..f2c752ac57cd 100644 --- a/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul +++ b/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul @@ -161,7 +161,7 @@ End of Other-only process\n\ // This is the output for a malformed data file. let expectedBad = "\ -Invalid memory report(s): missing 'hasMozMallocUsableSize' property"; +Error: Invalid memory report(s): missing 'hasMozMallocUsableSize' property"; let frames = [ // This loads a pre-existing file that is valid. diff --git a/toolkit/components/addoncompat/RemoteAddonsParent.jsm b/toolkit/components/addoncompat/RemoteAddonsParent.jsm index f2d5d2b1e27a..bdadb2d1727c 100644 --- a/toolkit/components/addoncompat/RemoteAddonsParent.jsm +++ b/toolkit/components/addoncompat/RemoteAddonsParent.jsm @@ -86,6 +86,7 @@ var NotificationTracker = { if (msg.name == "Addons:GetNotifications") { return this._paths; } + return undefined; } }; NotificationTracker.init(); @@ -136,6 +137,7 @@ var ContentPolicyParent = { return this.shouldLoad(aMessage.data, aMessage.objects); break; } + return undefined; }, shouldLoad: function(aData, aObjects) { @@ -233,6 +235,7 @@ var AboutProtocolParent = { return this.openChannel(msg); break; } + return undefined; }, getURIFlags: function(msg) { @@ -243,6 +246,7 @@ var AboutProtocolParent = { return module.getURIFlags(uri); } catch (e) { Cu.reportError(e); + return undefined; } }, @@ -281,6 +285,7 @@ var AboutProtocolParent = { }; } catch (e) { Cu.reportError(e); + return undefined; } }, }; diff --git a/toolkit/components/asyncshutdown/AsyncShutdown.jsm b/toolkit/components/asyncshutdown/AsyncShutdown.jsm index 76769bb675f3..ff6ac8f146bd 100644 --- a/toolkit/components/asyncshutdown/AsyncShutdown.jsm +++ b/toolkit/components/asyncshutdown/AsyncShutdown.jsm @@ -219,14 +219,14 @@ Services.prefs.addObserver(PREF_DEBUG_LOG, function() { function debug(msg, error=null) { if (DEBUG_LOG) { - return log(msg, "DEBUG: ", error); + log(msg, "DEBUG: ", error); } } function warn(msg, error = null) { - return log(msg, "WARNING: ", error); + log(msg, "WARNING: ", error); } function fatalerr(msg, error = null) { - return log(msg, "FATAL ERROR: ", error); + log(msg, "FATAL ERROR: ", error); } // Utility function designed to get the current state of execution diff --git a/toolkit/components/ctypes/tests/unit/head.js b/toolkit/components/ctypes/tests/unit/head.js index 67d4c70818dd..610705451229 100644 --- a/toolkit/components/ctypes/tests/unit/head.js +++ b/toolkit/components/ctypes/tests/unit/head.js @@ -74,7 +74,8 @@ function structural_check_eq(a, b) { } catch (x) { } if (finished) { - return do_check_eq(asource, bsource); + do_check_eq(asource, bsource); + return; } // 2. Otherwise, perform slower comparison diff --git a/toolkit/components/extensions/.eslintrc b/toolkit/components/extensions/.eslintrc index 5453a5c862a0..dabb3985b82f 100644 --- a/toolkit/components/extensions/.eslintrc +++ b/toolkit/components/extensions/.eslintrc @@ -84,6 +84,9 @@ // Space after colon not before in property declarations "key-spacing": [2, {"beforeColon": false, "afterColon": true, "mode": "minimum"}], + // Require spaces before and after finally, catch, etc. + "keyword-spacing": 2, + // Unix linebreaks "linebreak-style": [2, "unix"], @@ -102,9 +105,6 @@ // No duplicate cases in switch statements "no-duplicate-case": 2, - // No labels - // "no-labels": 2, - // If an if block ends with a return no need for an else block // "no-else-return": 2, @@ -207,15 +207,9 @@ // Never use spaces before function parentheses "space-before-function-paren": [2, {"anonymous": "never", "named": "never"}], - // Require spaces before finally, catch, etc. - "space-before-keywords": [2, "always"], - // Require spaces around operators, except for a|0. "space-infix-ops": [2, {"int32Hint": true}], - // Require spaces after return, throw and case - "space-return-throw-case": 2, - // ++ and -- should not need spacing "space-unary-ops": [1, {"nonwords": false}], @@ -321,9 +315,6 @@ // Allow division operators explicitly at beginning of regular expression. "no-div-regex": 0, - // Disallow use of labels for anything other then loops and switches. - "no-empty-label": 2, - // Disallow use of eval(). We have other APIs to evaluate code in content. "no-eval": 2, @@ -345,6 +336,9 @@ // Allow comments inline after code. "no-inline-comments": 0, + // Disallow use of labels for anything other then loops and switches. + "no-labels": [2, { "allowLoop": true }], + // Disallow use of multiline strings (use template strings instead). "no-multi-str": 1, @@ -446,9 +440,6 @@ // Anyway, one-var is disabled. "sort-vars": 0, - // Require a space after keywords. - "space-after-keywords": [2, "always"], - // Require a space immediately following the // in a line comment. "spaced-comment": [2, "always"], diff --git a/toolkit/components/extensions/ExtensionContent.jsm b/toolkit/components/extensions/ExtensionContent.jsm index 94ec1fbee37e..63afffc31163 100644 --- a/toolkit/components/extensions/ExtensionContent.jsm +++ b/toolkit/components/extensions/ExtensionContent.jsm @@ -546,7 +546,7 @@ DocumentManager = { return promises[0]; }, - enumerateWindows: function*(docShell) { + enumerateWindows: function* (docShell) { let window = docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindow); yield window; diff --git a/toolkit/components/extensions/schemas/notifications.json b/toolkit/components/extensions/schemas/notifications.json index 3f4c3ea9f154..bea9a06b81aa 100644 --- a/toolkit/components/extensions/schemas/notifications.json +++ b/toolkit/components/extensions/schemas/notifications.json @@ -186,6 +186,7 @@ "async": "callback", "parameters": [ { + "optional": true, "type": "string", "name": "notificationId", "description": "Identifier of the notification. If it is empty, this method generates an id. If it matches an existing notification, this method first clears that notification before proceeding with the create operation." diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_download.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_download.html index 8aaead0fcc32..54f1c16e7a7d 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_download.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_download.html @@ -204,7 +204,7 @@ add_task(function* test_downloads() { }); // check for leftover files in the download directory -add_task(function*() { +add_task(function* () { let entries = downloadDir.directoryEntries; while (entries.hasMoreElements()) { let entry = entries.getNext().QueryInterface(Ci.nsIFile); diff --git a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html b/toolkit/components/extensions/test/mochitest/test_ext_notifications.html index b7cf7bae5c86..c5f1b9df7bd7 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_notifications.html @@ -20,7 +20,7 @@ add_task(function* test_notification() { message: "Carry on", }; - browser.notifications.create("", opts).then(id => { + browser.notifications.create(opts).then(id => { browser.test.sendMessage("running", id); browser.test.notifyPass("background test passed"); }); diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html index 9883d563ad29..016d9448b84c 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html @@ -505,8 +505,8 @@ function* test_once(skipCompleted) { } // Run the test twice to make sure it works with caching. -add_task(function*() { yield test_once(false); }); -add_task(function*() { yield test_once(true); }); +add_task(function* () { yield test_once(false); }); +add_task(function* () { yield test_once(true); }); diff --git a/toolkit/components/microformats/Microformats.js b/toolkit/components/microformats/Microformats.js index 14f4e1e5d1e0..d49438ef75e3 100644 --- a/toolkit/components/microformats/Microformats.js +++ b/toolkit/components/microformats/Microformats.js @@ -401,6 +401,7 @@ this.Microformats = { return s; } } + return undefined; }, /** * Used to specifically retrieve a date in a microformat node. @@ -417,6 +418,7 @@ this.Microformats = { if (date) { return Microformats.parser.normalizeISO8601(date); } + return undefined; }, /** * Used to specifically retrieve a URI in a microformat node. This includes @@ -909,6 +911,7 @@ this.Microformats = { } return true; } + return undefined; }, /* This function normalizes an ISO8601 date by adding punctuation and */ /* ensuring that hours and seconds have values */ @@ -1381,6 +1384,7 @@ var hCard_definition = { return {"given-name" : given_name, "family-name" : family_name}; } } + return undefined; } }, "nickname" : { @@ -1637,6 +1641,7 @@ var hCalendar_definition = { return rrule[i].split('=')[1]; } } + return undefined; } } } @@ -1695,6 +1700,7 @@ geo.prototype.toString = function() { return this.latitude + ", " + this.longitude; } } + return undefined; } var geo_definition = { @@ -1717,6 +1723,7 @@ var geo_definition = { } } } + return undefined; } }, "longitude" : { @@ -1734,6 +1741,7 @@ var geo_definition = { } } } + return undefined; } } }, diff --git a/toolkit/components/microformats/microformat-shiv.js b/toolkit/components/microformats/microformat-shiv.js index 709d5c238ced..99ec1e5c4762 100644 --- a/toolkit/components/microformats/microformat-shiv.js +++ b/toolkit/components/microformats/microformat-shiv.js @@ -1067,6 +1067,7 @@ var Microformats; // jshint ignore:line if(propertyType === 'dt') { return modules.dates.concatFragments(out,this.options.dateFormat).toString(this.options.dateFormat); } + return undefined; } else { return null; } diff --git a/toolkit/components/narrate/.eslintrc b/toolkit/components/narrate/.eslintrc index 0bbf0b79448a..e5b60e2cca5a 100644 --- a/toolkit/components/narrate/.eslintrc +++ b/toolkit/components/narrate/.eslintrc @@ -32,6 +32,7 @@ "generator-star-spacing": [1, "after"], "indent": [1, 2, {"SwitchCase": 1}], "key-spacing": [1, {"beforeColon": false, "afterColon": true}], + "keyword-spacing": 1, "max-len": [1, 80, 2, {"ignoreUrls": true}], "max-nested-callbacks": [2, 3], "new-cap": [2, {"capIsNew": false}], @@ -77,12 +78,10 @@ "quotes": [1, "double", "avoid-escape"], "semi": [1, "always"], "semi-spacing": [1, {"before": false, "after": true}], - "space-after-keywords": [1, "always"], "space-before-blocks": [1, "always"], "space-before-function-paren": [1, "never"], "space-in-parens": [1, "never"], "space-infix-ops": [1, {"int32Hint": true}], - "space-return-throw-case": 1, "space-unary-ops": [1, { "words": true, "nonwords": false }], "spaced-comment": [1, "always"], "strict": [2, "global"], diff --git a/toolkit/components/passwordmgr/LoginManagerParent.jsm b/toolkit/components/passwordmgr/LoginManagerParent.jsm index cb9ff9287f32..31c3bb40914d 100644 --- a/toolkit/components/passwordmgr/LoginManagerParent.jsm +++ b/toolkit/components/passwordmgr/LoginManagerParent.jsm @@ -99,6 +99,8 @@ var LoginManagerParent = { break; } } + + return undefined; }, /** diff --git a/toolkit/components/passwordmgr/content/passwordManager.js b/toolkit/components/passwordmgr/content/passwordManager.js index 0d6cb81aafcd..87bc391a10f5 100644 --- a/toolkit/components/passwordmgr/content/passwordManager.js +++ b/toolkit/components/passwordmgr/content/passwordManager.js @@ -270,6 +270,7 @@ function getColumnByName(column) { case "timesUsed": return document.getElementById("timesUsedCol"); } + return undefined; } var lastSignonSortColumn = "hostname"; diff --git a/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html b/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html index 141a7cd92efe..be51daec672e 100644 --- a/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html +++ b/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html @@ -277,6 +277,8 @@ function* runTest() { removePopupListener("popupshown", unexpectedPopup, false); tester.next(); }, 100); + + return undefined; } // We use this function when we're trying to prove that something doesn't diff --git a/toolkit/components/perfmonitoring/PerformanceStats.jsm b/toolkit/components/perfmonitoring/PerformanceStats.jsm index 04cdec2e373e..ee151fdbf63d 100644 --- a/toolkit/components/perfmonitoring/PerformanceStats.jsm +++ b/toolkit/components/perfmonitoring/PerformanceStats.jsm @@ -650,6 +650,7 @@ PerformanceDataLeaf.prototype = { return false; } } + return true; }, /** diff --git a/toolkit/components/places/PlacesBackups.jsm b/toolkit/components/places/PlacesBackups.jsm index 64e22c369bb3..d32e41c98e07 100644 --- a/toolkit/components/places/PlacesBackups.jsm +++ b/toolkit/components/places/PlacesBackups.jsm @@ -209,6 +209,8 @@ this.PlacesBackups = { this._backupFiles.push(filePath); } } + + return undefined; }.bind(this)); iterator.close(); diff --git a/toolkit/components/places/tests/queries/test_async.js b/toolkit/components/places/tests/queries/test_async.js index 8f6ced616440..1a33801129cd 100644 --- a/toolkit/components/places/tests/queries/test_async.js +++ b/toolkit/components/places/tests/queries/test_async.js @@ -325,6 +325,7 @@ var DataHelper = { }; default: do_throw("Unknown data type when populating DB: " + type); + return undefined; } }); }, diff --git a/toolkit/components/places/tests/queries/test_history_queries_titles_liveUpdate.js b/toolkit/components/places/tests/queries/test_history_queries_titles_liveUpdate.js index d204b14e7683..6d227b40b277 100644 --- a/toolkit/components/places/tests/queries/test_history_queries_titles_liveUpdate.js +++ b/toolkit/components/places/tests/queries/test_history_queries_titles_liveUpdate.js @@ -35,6 +35,7 @@ function searchNodeHavingUrl(aRoot, aUrl) { return aRoot.getChild(i); } } + return undefined; } function newQueryWithOptions() diff --git a/toolkit/components/places/tests/queries/test_redirects.js b/toolkit/components/places/tests/queries/test_redirects.js index 3527b4ce7bba..e014825da0f7 100644 --- a/toolkit/components/places/tests/queries/test_redirects.js +++ b/toolkit/components/places/tests/queries/test_redirects.js @@ -63,6 +63,7 @@ function check_results_callback(aSequence) { if (visits[i].uri == aEntry.uri) return i; } + return undefined; } function comparator(a, b) { if (sortingMode == Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING) diff --git a/toolkit/components/printing/content/printUtils.js b/toolkit/components/printing/content/printUtils.js index 4814056ab980..0ba27e702ede 100644 --- a/toolkit/components/printing/content/printUtils.js +++ b/toolkit/components/printing/content/printUtils.js @@ -154,6 +154,7 @@ var PrintUtils = { Deprecated.warning(msg, url); this.printWindow(windowID, browser); + return undefined; }, /** @@ -420,6 +421,7 @@ var PrintUtils = { break; } } + return undefined; }, setPrinterDefaultsForSelectedPrinter: function (aPSSVC, aPrintSettings) diff --git a/toolkit/components/reader/ReaderMode.jsm b/toolkit/components/reader/ReaderMode.jsm index c9e9036a96db..b39e04aaaad5 100644 --- a/toolkit/components/reader/ReaderMode.jsm +++ b/toolkit/components/reader/ReaderMode.jsm @@ -445,6 +445,7 @@ this.ReaderMode = { if (!exists) { return OS.File.makeDir(dir); } + return undefined; }); } }; diff --git a/toolkit/components/satchel/AutoCompleteE10S.jsm b/toolkit/components/satchel/AutoCompleteE10S.jsm index c617fc313471..1d8d398027a2 100644 --- a/toolkit/components/satchel/AutoCompleteE10S.jsm +++ b/toolkit/components/satchel/AutoCompleteE10S.jsm @@ -256,6 +256,7 @@ this.AutoCompleteE10S = { AutoCompleteE10SView.clearResults(); break; } + return undefined; }, handleEnter: function(aIsPopupSelection) { diff --git a/toolkit/components/satchel/test/unit/test_history_api.js b/toolkit/components/satchel/test/unit/test_history_api.js index dd83faf206f6..7535041830b8 100644 --- a/toolkit/components/satchel/test/unit/test_history_api.js +++ b/toolkit/components/satchel/test/unit/test_history_api.js @@ -265,6 +265,7 @@ add_task(function* () let result = results[0]; return [result.timesUsed, result.firstUsed, result.lastUsed, result.guid]; } + return undefined; } results = yield promiseSearchEntries(["timesUsed", "firstUsed", "lastUsed"], diff --git a/toolkit/components/telemetry/TelemetryController.jsm b/toolkit/components/telemetry/TelemetryController.jsm index 58f3544eb9a4..eb848f623b78 100644 --- a/toolkit/components/telemetry/TelemetryController.jsm +++ b/toolkit/components/telemetry/TelemetryController.jsm @@ -795,6 +795,7 @@ var Impl = { return this.setupContentTelemetry(); break; } + return undefined; }, get clientID() { diff --git a/toolkit/components/telemetry/TelemetrySession.jsm b/toolkit/components/telemetry/TelemetrySession.jsm index baf103f4a677..ac3b27406f1e 100644 --- a/toolkit/components/telemetry/TelemetrySession.jsm +++ b/toolkit/components/telemetry/TelemetrySession.jsm @@ -412,6 +412,7 @@ var TelemetryScheduler = { return this._onSchedulerTick(); break; } + return undefined; }, /** @@ -1885,6 +1886,7 @@ var Impl = { TelemetryController.addPendingPing(getPingType(payload), payload, options); break; } + return undefined; }, /** diff --git a/toolkit/components/telemetry/TelemetryStorage.jsm b/toolkit/components/telemetry/TelemetryStorage.jsm index 8030da8892a2..27cacbe4663d 100644 --- a/toolkit/components/telemetry/TelemetryStorage.jsm +++ b/toolkit/components/telemetry/TelemetryStorage.jsm @@ -665,6 +665,7 @@ var TelemetryStorageImpl = { }); Telemetry.getHistogramById("TELEMETRY_ARCHIVE_SESSION_PING_COUNT").add(); + return undefined; }), /** @@ -1026,6 +1027,7 @@ var TelemetryStorageImpl = { } finally { this._enforcePendingPingsQuotaTask = null; } + return undefined; }), /** @@ -1402,6 +1404,7 @@ var TelemetryStorageImpl = { } finally { this._removePendingPingsTask = null; } + return undefined; }), removePendingPings: Task.async(function*() { diff --git a/toolkit/components/viewsource/content/viewSource.js b/toolkit/components/viewsource/content/viewSource.js index 11a1361c6a22..50e5c89de5c5 100644 --- a/toolkit/components/viewsource/content/viewSource.js +++ b/toolkit/components/viewsource/content/viewSource.js @@ -317,6 +317,8 @@ ViewSourceChrome.prototype = { if (!args.partial) { this.loadViewSource(args); } + + return undefined; }, /** diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index 02e0d48171f8..c6192a8d3723 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -294,6 +294,7 @@ var PopupBlocking = { case "pagehide": return this.onPageHide(ev); } + return undefined; }, onPopupBlocked: function(ev) { @@ -659,6 +660,7 @@ var FindBar = { event.preventDefault(); return false; } + return undefined; }, _onMouseup(event) { diff --git a/toolkit/content/tests/browser/browser_findbar.js b/toolkit/content/tests/browser/browser_findbar.js index e438eb55b6de..906265d00f04 100644 --- a/toolkit/content/tests/browser/browser_findbar.js +++ b/toolkit/content/tests/browser/browser_findbar.js @@ -119,11 +119,11 @@ add_task(function* test_tabwise_case_sensitive() { * process into the parent process or the other way around. * This test ensures that findbar properly handles such a change. */ -add_task(function * test_reinitialization_at_remoteness_change() { +add_task(function* test_reinitialization_at_remoteness_change() { // This test only makes sence in e10s evironment. if (!gMultiProcessBrowser) { info("Skipping this test because of non-e10s environment."); - return true; + return; } info("Ensure findbar re-initialization at remoteness change."); @@ -166,7 +166,7 @@ add_task(function* () { // This test only makes sence in e10s evironment. if (!gMultiProcessBrowser) { info("Skipping this test because of non-e10s environment."); - return true; + return; } let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI); diff --git a/toolkit/content/tests/browser/head.js b/toolkit/content/tests/browser/head.js index 07031452e3dd..1c6c2b54f79c 100644 --- a/toolkit/content/tests/browser/head.js +++ b/toolkit/content/tests/browser/head.js @@ -11,8 +11,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "Promise", */ function closeFindbarAndWait(findbar) { return new Promise((resolve) => { - if (findbar.hidden) - return resolve(); + if (findbar.hidden) { + resolve(); + return; + } findbar.addEventListener("transitionend", function cont(aEvent) { if (aEvent.propertyName != "visibility") { return; diff --git a/toolkit/content/widgets/autocomplete.xml b/toolkit/content/widgets/autocomplete.xml index 61965fd78d24..059210279b60 100644 --- a/toolkit/content/widgets/autocomplete.xml +++ b/toolkit/content/widgets/autocomplete.xml @@ -1249,6 +1249,7 @@ extends="chrome://global/content/bindings/popup.xml#popup"> invalidateReason == iface.INVALIDATE_REASON_NEW_RESULT && (item.getAttribute("url") == url || this.richlistbox.mouseSelectedIndex === this._currentIndex)) { + item.handleOverUnderflow(); item.collapsed = false; this._currentIndex++; continue; @@ -1803,10 +1804,7 @@ extends="chrome://global/content/bindings/popup.xml#popup"> + + + + + + ]]> + + + + + + diff --git a/toolkit/content/widgets/findbar.xml b/toolkit/content/widgets/findbar.xml index e0682449fa71..3a95a36122c2 100644 --- a/toolkit/content/widgets/findbar.xml +++ b/toolkit/content/widgets/findbar.xml @@ -791,6 +791,7 @@ return false; } + return undefined; ]]> @@ -811,6 +812,7 @@ return this._onBrowserKeypress(aMessage.data.fakeEvent, aMessage.data.shouldFastFind); } + return undefined; ]]> @@ -1110,6 +1112,7 @@ else this._findAgain(aFindPrevious); + return undefined; ]]> diff --git a/toolkit/content/widgets/remote-browser.xml b/toolkit/content/widgets/remote-browser.xml index d462265f06fe..3e57b2c89eb7 100644 --- a/toolkit/content/widgets/remote-browser.xml +++ b/toolkit/content/widgets/remote-browser.xml @@ -511,6 +511,7 @@ return this._receiveMessage(aMessage); break; } + return undefined; ]]> diff --git a/toolkit/identity/IdentityProvider.jsm b/toolkit/identity/IdentityProvider.jsm index 761abff4d8cf..a74b24f34c82 100644 --- a/toolkit/identity/IdentityProvider.jsm +++ b/toolkit/identity/IdentityProvider.jsm @@ -80,6 +80,8 @@ IdentityProviderService.prototype = { if (typeof aErrBack === 'function') { aErrBack(err); } + + return undefined; }, shutdown: function RP_shutdown() { diff --git a/toolkit/modules/BrowserUtils.jsm b/toolkit/modules/BrowserUtils.jsm index d39e7bc931db..fd75bc730209 100644 --- a/toolkit/modules/BrowserUtils.jsm +++ b/toolkit/modules/BrowserUtils.jsm @@ -42,6 +42,7 @@ this.BrowserUtils = { return undefined; } appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); + return undefined; }, /** diff --git a/toolkit/modules/Finder.jsm b/toolkit/modules/Finder.jsm index 664560d4d0a1..8e0b7987a158 100644 --- a/toolkit/modules/Finder.jsm +++ b/toolkit/modules/Finder.jsm @@ -325,6 +325,7 @@ Finder.prototype = { delete result._framesToCount; this._notifyMatchesCount(result); + return undefined; }, /** diff --git a/toolkit/modules/Log.jsm b/toolkit/modules/Log.jsm index 09dddd272a16..ff16e35419a7 100644 --- a/toolkit/modules/Log.jsm +++ b/toolkit/modules/Log.jsm @@ -350,7 +350,8 @@ Logger.prototype = { throw "An action is required when logging a structured message."; } if (!params) { - return this.log(this.level, undefined, {"action": action}); + this.log(this.level, undefined, {"action": action}); + return; } if (typeof(params) != "object") { throw "The params argument is required to be an object."; @@ -575,6 +576,7 @@ BasicFormatter.prototype = { } return textParts.join(': '); } + return undefined; }, format: function BF_format(message) { @@ -899,6 +901,7 @@ FileAppender.prototype = { if (this._file) { return this._file.write(array); } + return undefined; }); } }, @@ -942,6 +945,7 @@ BoundedFileAppender.prototype = { this._removeFilePromise = null; this.doAppend(formatted); }); + return undefined; }, reset: function () { diff --git a/toolkit/modules/tests/browser/browser_WebRequest.js b/toolkit/modules/tests/browser/browser_WebRequest.js index 5b1426a802e3..0d3012e2bef8 100644 --- a/toolkit/modules/tests/browser/browser_WebRequest.js +++ b/toolkit/modules/tests/browser/browser_WebRequest.js @@ -51,6 +51,7 @@ function onBeforeRequest(details) if (details.url.indexOf("_bad.") != -1) { return {cancel: true}; } + return undefined; } var sendHeaders = []; @@ -70,6 +71,7 @@ function onBeforeSendHeaders(details) if (details.url.indexOf("_redirect.") != -1) { return {redirectUrl: details.url.replace("_redirect.", "_good.")}; } + return undefined; } var beforeRedirect = []; diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index b8caa9e493dd..2f513ee002c4 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -789,6 +789,7 @@ var AddonManagerInternal = { if (providerName(provider) == aName) return provider; } + return undefined; }, /** diff --git a/toolkit/mozapps/extensions/addonManager.js b/toolkit/mozapps/extensions/addonManager.js index d51cb839af8a..db7b9d0c7341 100644 --- a/toolkit/mozapps/extensions/addonManager.js +++ b/toolkit/mozapps/extensions/addonManager.js @@ -175,6 +175,7 @@ amManager.prototype = { payload.hashes, payload.names, payload.icons, callback); } } + return undefined; }, classID: Components.ID("{4399533d-08d1-458c-a87a-235f74451cfa}"), diff --git a/toolkit/mozapps/extensions/internal/AddonRepository.jsm b/toolkit/mozapps/extensions/internal/AddonRepository.jsm index b5572744f5e7..279749ca14d2 100644 --- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm +++ b/toolkit/mozapps/extensions/internal/AddonRepository.jsm @@ -632,7 +632,8 @@ this.AddonRepository = { // Completely remove cache if caching is not enabled if (!this.cacheEnabled) { logger.debug("Clearing cache because it is disabled"); - return this._clearCache(); + yield this._clearCache(); + return; } let ids = allAddons.map(a => a.id); @@ -644,7 +645,8 @@ this.AddonRepository = { // Completely remove cache if there are no add-ons to cache if (addonsToCache.length == 0) { logger.debug("Clearing cache because 0 add-ons were requested"); - return this._clearCache(); + yield this._clearCache(); + return; } yield new Promise((resolve, reject) => diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index c1a6a38230f1..11745596bba3 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -2812,6 +2812,7 @@ this.XPIProvider = { logger.debug("Notifying XPI shutdown observers"); Services.obs.notifyObservers(null, "xpi-provider-shutdown", null); } + return undefined; }, /** @@ -2906,16 +2907,18 @@ this.XPIProvider = { updateSystemAddons: Task.async(function*() { let systemAddonLocation = XPIProvider.installLocationsByName[KEY_APP_SYSTEM_ADDONS]; if (!systemAddonLocation) - return undefined; + return; // Don't do anything in safe mode if (Services.appinfo.inSafeMode) - return undefined; + return; // Download the list of system add-ons let url = Preferences.get(PREF_SYSTEM_ADDON_UPDATE_URL, null); - if (!url) - return systemAddonLocation.cleanDirectories(); + if (!url) { + yield systemAddonLocation.cleanDirectories(); + return; + } url = UpdateUtils.formatUpdateURL(url); @@ -2925,7 +2928,8 @@ this.XPIProvider = { // If there was no list then do nothing. if (!addonList) { logger.info("No system add-ons list was returned."); - return systemAddonLocation.cleanDirectories(); + yield systemAddonLocation.cleanDirectories(); + return; } addonList = new Map( @@ -2957,7 +2961,8 @@ this.XPIProvider = { let updatedAddons = addonMap(yield getAddonsInLocation(KEY_APP_SYSTEM_ADDONS)); if (setMatches(addonList, updatedAddons)) { logger.info("Retaining existing updated system add-ons."); - return systemAddonLocation.cleanDirectories(); + yield systemAddonLocation.cleanDirectories(); + return; } // If this matches the current set in the default location then reset the @@ -2966,7 +2971,8 @@ this.XPIProvider = { if (setMatches(addonList, defaultAddons)) { logger.info("Resetting system add-ons."); systemAddonLocation.resetAddonSet(); - return systemAddonLocation.cleanDirectories(); + yield systemAddonLocation.cleanDirectories(); + return; } // Download all the add-ons @@ -5636,6 +5642,7 @@ AddonInstall.prototype = { repoAddon.compatibilityOverrides : null; this.addon.appDisabled = !isUsableAddon(this.addon); + return undefined; }), observe: function(aSubject, aTopic, aData) { @@ -7389,8 +7396,9 @@ PROP_LOCALE_SINGLE.forEach(function(aProp) { } } + let rest; if (result == null) - [result, ] = chooseValue(addon, addon.selectedLocale, aProp); + [result, ...rest] = chooseValue(addon, addon.selectedLocale, aProp); if (aProp == "creator") return result ? new AddonManagerPrivate.AddonAuthor(result) : null; diff --git a/toolkit/mozapps/extensions/nsBlocklistService.js b/toolkit/mozapps/extensions/nsBlocklistService.js index 994c0ae327ba..1f8ab460f980 100644 --- a/toolkit/mozapps/extensions/nsBlocklistService.js +++ b/toolkit/mozapps/extensions/nsBlocklistService.js @@ -380,6 +380,7 @@ Blocklist.prototype = { default: throw new Error("Unknown blocklist message received from content: " + aMsg.name); } + return undefined; }, /* See nsIBlocklistService */ diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug590347.js b/toolkit/mozapps/extensions/test/browser/browser_bug590347.js index 8fe9c715e599..afe40d396401 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_bug590347.js +++ b/toolkit/mozapps/extensions/test/browser/browser_bug590347.js @@ -51,6 +51,7 @@ function get_list_view_warning_node() { function get_detail_view_warning_node(aManagerWindow) { if(aManagerWindow) return aManagerWindow.document.getElementById("detail-warning"); + return undefined; } function test() { diff --git a/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html b/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html index 2b2033a37bdc..f05564b1782b 100644 --- a/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html +++ b/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html @@ -12,6 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887098 /** Test for Bug 887098 **/ SimpleTest.waitForExplicitFinish(); + /* globals $,evalRef */ function loaded() { var iwin = $('ifr').contentWindow; diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js b/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js index 6fdfd915dd49..f90e38292fcc 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js @@ -15,6 +15,7 @@ function mockAddonProvider(name) { shutdownOrder.push(this.name); if (this.shutdownCallback) return this.shutdownCallback(); + return undefined; }, getAddonByID(id, callback) { if (this.hasShutdown) { diff --git a/widget/android/GeneratedJNIWrappers.cpp b/widget/android/GeneratedJNIWrappers.cpp index 602e12806f56..2cd43c38e0a2 100644 --- a/widget/android/GeneratedJNIWrappers.cpp +++ b/widget/android/GeneratedJNIWrappers.cpp @@ -677,14 +677,6 @@ auto GeckoAppShell::ShowAlertNotificationWrapper(mozilla::jni::String::Param a0, return mozilla::jni::Method::Call(GeckoAppShell::Context(), nullptr, a0, a1, a2, a3, a4, a5); } -constexpr char GeckoAppShell::ShowInputMethodPicker_t::name[]; -constexpr char GeckoAppShell::ShowInputMethodPicker_t::signature[]; - -auto GeckoAppShell::ShowInputMethodPicker() -> void -{ - return mozilla::jni::Method::Call(GeckoAppShell::Context(), nullptr); -} - constexpr char GeckoAppShell::StartMonitoringGamepad_t::name[]; constexpr char GeckoAppShell::StartMonitoringGamepad_t::signature[]; diff --git a/widget/android/GeneratedJNIWrappers.h b/widget/android/GeneratedJNIWrappers.h index 19e52f6e99aa..5bbdd0677317 100644 --- a/widget/android/GeneratedJNIWrappers.h +++ b/widget/android/GeneratedJNIWrappers.h @@ -1415,21 +1415,6 @@ public: static auto ShowAlertNotificationWrapper(mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param) -> void; - struct ShowInputMethodPicker_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "showInputMethodPicker"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - }; - - static auto ShowInputMethodPicker() -> void; - struct StartMonitoringGamepad_t { typedef GeckoAppShell Owner; typedef void ReturnType; diff --git a/widget/android/moz.build b/widget/android/moz.build index 402e69ab957c..16c5d5e2af1b 100644 --- a/widget/android/moz.build +++ b/widget/android/moz.build @@ -40,7 +40,6 @@ UNIFIED_SOURCES += [ 'nsClipboard.cpp', 'nsDeviceContextAndroid.cpp', 'nsIdleServiceAndroid.cpp', - 'nsIMEPicker.cpp', 'nsLookAndFeel.cpp', 'nsPrintOptionsAndroid.cpp', 'nsScreenManagerAndroid.cpp', diff --git a/widget/android/nsIMEPicker.cpp b/widget/android/nsIMEPicker.cpp deleted file mode 100644 index 3bb6146523f1..000000000000 --- a/widget/android/nsIMEPicker.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsIMEPicker.h" -#include "AndroidBridge.h" - -using namespace mozilla; - -NS_IMPL_ISUPPORTS(nsIMEPicker, nsIIMEPicker) - -nsIMEPicker::nsIMEPicker() -{ - /* member initializers and constructor code */ -} - -nsIMEPicker::~nsIMEPicker() -{ - /* destructor code */ -} - -NS_IMETHODIMP nsIMEPicker::Show() -{ - widget::GeckoAppShell::ShowInputMethodPicker(); - return NS_OK; -} diff --git a/widget/android/nsIMEPicker.h b/widget/android/nsIMEPicker.h deleted file mode 100644 index 208cc9995e7d..000000000000 --- a/widget/android/nsIMEPicker.h +++ /dev/null @@ -1,22 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef __nsIMEPicker -#define __nsIMEPicker - -#include "nsIIMEPicker.h" - -class nsIMEPicker final : public nsIIMEPicker -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIIMEPICKER - - nsIMEPicker(); - -private: - ~nsIMEPicker(); -}; - -#endif diff --git a/widget/android/nsWidgetFactory.cpp b/widget/android/nsWidgetFactory.cpp index a80182370d42..92313a40f689 100644 --- a/widget/android/nsWidgetFactory.cpp +++ b/widget/android/nsWidgetFactory.cpp @@ -24,7 +24,6 @@ #include "nsPrintSession.h" #include "nsDeviceContextAndroid.h" #include "nsHTMLFormatConverter.h" -#include "nsIMEPicker.h" #include "nsXULAppAPI.h" #include "nsAndroidProtocolHandler.h" @@ -38,7 +37,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsAndroid, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecAndroid) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsIMEPicker) NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroidBridge) NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroidProtocolHandler) @@ -62,7 +60,6 @@ NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID); NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID); NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID); NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID); -NS_DEFINE_NAMED_CID(NS_IMEPICKER_CID); NS_DEFINE_NAMED_CID(NS_GFXINFO_CID); NS_DEFINE_NAMED_CID(NS_ANDROIDBRIDGE_CID); NS_DEFINE_NAMED_CID(NS_ANDROIDPROTOCOLHANDLER_CID); @@ -80,7 +77,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = { { &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor }, { &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecAndroidConstructor }, { &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor }, - { &kNS_IMEPICKER_CID, false, nullptr, nsIMEPickerConstructor }, { &kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor }, { &kNS_ANDROIDBRIDGE_CID, false, nullptr, nsAndroidBridgeConstructor }, { &kNS_ANDROIDPROTOCOLHANDLER_CID, false, nullptr, nsAndroidProtocolHandlerConstructor }, @@ -100,7 +96,6 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID }, { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID }, { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID }, - { "@mozilla.org/imepicker;1", &kNS_IMEPICKER_CID }, { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID }, { "@mozilla.org/android/bridge;1", &kNS_ANDROIDBRIDGE_CID }, { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "android", &kNS_ANDROIDPROTOCOLHANDLER_CID }, diff --git a/widget/moz.build b/widget/moz.build index f7ef2b3b270f..d02c066f4627 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -74,7 +74,6 @@ XPIDL_SOURCES += [ 'nsIGfxInfoDebug.idl', 'nsIIdleService.idl', 'nsIIdleServiceInternal.idl', - 'nsIIMEPicker.idl', 'nsIPrintOptions.idl', 'nsIPrintSession.idl', 'nsIPrintSettings.idl', diff --git a/widget/nsIIMEPicker.idl b/widget/nsIIMEPicker.idl deleted file mode 100644 index ab081b9cfcc1..000000000000 --- a/widget/nsIIMEPicker.idl +++ /dev/null @@ -1,14 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -[scriptable, uuid(9e631b1d-7a07-4925-a47e-697c6edaf408)] -interface nsIIMEPicker : nsISupports -{ - /** - * Show IME Picker dialog. - */ - void show(); -}; diff --git a/widget/nsWidgetsCID.h b/widget/nsWidgetsCID.h index 802abb259231..54ebe63abcd4 100644 --- a/widget/nsWidgetsCID.h +++ b/widget/nsWidgetsCID.h @@ -186,10 +186,6 @@ { 0xd755a760, 0x9f27, 0x11df, \ { 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66, 0x42, 0x42 } } -#define NS_IMEPICKER_CID \ -{ 0x8e5c35ef, 0xb65b, 0x47aa, \ -{ 0xbb, 0x90, 0x5b, 0x89, 0x6d, 0x88, 0x24, 0x18 } } - #define NS_WINDOWS_UIUTILS_CID \ { 0xe04a55e8, 0xfee3, 0x4ea2, \ { 0xa9, 0x8b, 0x41, 0xd2, 0x62, 0x1a, 0xdc, 0x3c } }