From d2f8bed096eed199151afb200e47010dd7bb1edd Mon Sep 17 00:00:00 2001 From: Jonathan Kingston Date: Tue, 17 Sep 2019 13:31:40 +0000 Subject: [PATCH] Bug 1579444 - Remove offline storage usage prompt r=johannh Differential Revision: https://phabricator.services.mozilla.com/D46075 --HG-- extra : moz-landing-system : lando --- browser/actors/OfflineAppsChild.jsm | 23 ---- browser/base/content/browser.js | 113 ------------------ browser/base/content/test/general/browser.ini | 8 -- .../test/general/browser_gZipOfflineChild.js | 92 -------------- .../browser_offlineQuotaNotification.js | 106 ---------------- .../general/gZipOfflineChild.cacheManifest | 2 - .../gZipOfflineChild.cacheManifest^headers^ | 1 - .../test/general/gZipOfflineChild.html | Bin 303 -> 0 bytes .../general/gZipOfflineChild.html^headers^ | 2 - .../offlineQuotaNotification.cacheManifest | 7 -- .../general/offlineQuotaNotification.html | 9 -- .../test/general/test_offline_gzip.html | 21 ---- .../en-US/chrome/browser/browser.properties | 4 - mobile/android/app/mobile.js | 1 - modules/libpref/init/all.js | 4 - 15 files changed, 393 deletions(-) delete mode 100644 browser/base/content/test/general/browser_gZipOfflineChild.js delete mode 100644 browser/base/content/test/general/browser_offlineQuotaNotification.js delete mode 100644 browser/base/content/test/general/gZipOfflineChild.cacheManifest delete mode 100644 browser/base/content/test/general/gZipOfflineChild.cacheManifest^headers^ delete mode 100644 browser/base/content/test/general/gZipOfflineChild.html delete mode 100644 browser/base/content/test/general/gZipOfflineChild.html^headers^ delete mode 100644 browser/base/content/test/general/offlineQuotaNotification.cacheManifest delete mode 100644 browser/base/content/test/general/offlineQuotaNotification.html delete mode 100644 browser/base/content/test/general/test_offline_gzip.html diff --git a/browser/actors/OfflineAppsChild.jsm b/browser/actors/OfflineAppsChild.jsm index c68a5347b405..3f923343f0cc 100644 --- a/browser/actors/OfflineAppsChild.jsm +++ b/browser/actors/OfflineAppsChild.jsm @@ -14,10 +14,6 @@ const { ActorChild } = ChromeUtils.import( "resource://gre/modules/ActorChild.jsm" ); -XPCOMUtils.defineLazyModuleGetters(this, { - E10SUtils: "resource://gre/modules/E10SUtils.jsm", -}); - class OfflineAppsChild extends ActorChild { constructor(dispatcher) { super(dispatcher); @@ -26,15 +22,9 @@ class OfflineAppsChild extends ActorChild { this._docIdMap = new Map(); this._docManifestSet = new Set(); - - this._observerAdded = false; } registerWindow(aWindow) { - if (!this._observerAdded) { - this._observerAdded = true; - Services.obs.addObserver(this, "offline-cache-update-completed", true); - } let manifestURI = this._getManifestURI(aWindow); this._docManifestSet.add(manifestURI.spec); } @@ -97,19 +87,6 @@ class OfflineAppsChild extends ActorChild { this._docIdMap.delete(aMessage.data.docId); } } - - observe(aSubject, aTopic, aState) { - if (aTopic == "offline-cache-update-completed") { - let cacheUpdate = aSubject.QueryInterface(Ci.nsIOfflineCacheUpdate); - let uri = cacheUpdate.manifestURI; - if (uri && this._docManifestSet.has(uri.spec)) { - this.mm.sendAsyncMessage("OfflineApps:CheckUsage", { - uri: uri.spec, - principal: E10SUtils.serializePrincipal(cacheUpdate.loadingPrincipal), - }); - } - } - } } OfflineAppsChild.prototype.QueryInterface = ChromeUtils.generateQI([ diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index ddb3fe51fab8..d29536a83818 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1979,10 +1979,6 @@ var gBrowserInit = { // until all of its dependencies are handled. Services.appShell.hiddenDOMWindow; - // We need to set the OfflineApps message listeners up before we - // load homepages, which might need them. - OfflineApps.init(); - gBrowser.addEventListener( "InsecureLoginFormsStateChange", function() { @@ -7933,115 +7929,6 @@ var BrowserOffline = { }, }; -var OfflineApps = { - warnUsage(browser, principal, host) { - if (!browser) { - return; - } - - let mainAction = { - label: gNavigatorBundle.getString("offlineApps.manageUsage"), - accessKey: gNavigatorBundle.getString("offlineApps.manageUsageAccessKey"), - callback: this.manage, - }; - - let warnQuotaKB = Services.prefs.getIntPref("offline-apps.quota.warn"); - // This message shows the quota in MB, and so we divide the quota (in kb) by 1024. - let message = gNavigatorBundle.getFormattedString("offlineApps.usage", [ - host, - warnQuotaKB / 1024, - ]); - - let anchorID = "indexedDB-notification-icon"; - let options = { - persistent: true, - hideClose: true, - }; - PopupNotifications.show( - browser, - "offline-app-usage", - message, - anchorID, - mainAction, - null, - options - ); - - // Now that we've warned once, prevent the warning from showing up - // again. - Services.perms.addFromPrincipal( - principal, - "offline-app", - Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN - ); - }, - - // XXX: duplicated in preferences/advanced.js - _getOfflineAppUsage(host, groups) { - let cacheService = Cc[ - "@mozilla.org/network/application-cache-service;1" - ].getService(Ci.nsIApplicationCacheService); - if (!groups) { - try { - groups = cacheService.getGroups(); - } catch (ex) { - return 0; - } - } - - let usage = 0; - for (let group of groups) { - let uri = Services.io.newURI(group); - if (uri.asciiHost == host) { - let cache = cacheService.getActiveCache(group); - usage += cache.usage; - } - } - - return usage; - }, - - _usedMoreThanWarnQuota(principal, asciiHost) { - // if the user has already allowed excessive usage, don't bother checking - if ( - Services.perms.testExactPermissionFromPrincipal( - principal, - "offline-app" - ) != Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN - ) { - let usageBytes = this._getOfflineAppUsage(asciiHost); - let warnQuotaKB = Services.prefs.getIntPref("offline-apps.quota.warn"); - // The pref is in kb, the usage we get is in bytes, so multiply the quota - // to compare correctly: - if (usageBytes >= warnQuotaKB * 1024) { - return true; - } - } - - return false; - }, - - manage() { - openPreferences("panePrivacy"); - }, - - receiveMessage(msg) { - if (msg.name !== "OfflineApps:CheckUsage") { - return; - } - let uri = makeURI(msg.data.uri); - let principal = E10SUtils.deserializePrincipal(msg.data.principal); - if (this._usedMoreThanWarnQuota(principal, uri.asciiHost)) { - this.warnUsage(msg.target, principal, uri.host); - } - }, - - init() { - let mm = window.messageManager; - mm.addMessageListener("OfflineApps:CheckUsage", this); - }, -}; - var IndexedDBPromptHelper = { _permissionsPrompt: "indexedDB-permissions-prompt", _permissionsResponse: "indexedDB-permissions-response", diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index 860683ab679d..d1060afe8f5d 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -302,14 +302,6 @@ tags = clipboard # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. [browser_new_http_window_opened_from_file_tab.js] # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. -[browser_offlineQuotaNotification.js] -support-files = offlineQuotaNotification.cacheManifest offlineQuotaNotification.html -skip-if = true # Bug 1579444 -# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. -[browser_gZipOfflineChild.js] -skip-if = true # Bug 1579444 -support-files = test_offline_gzip.html gZipOfflineChild.cacheManifest gZipOfflineChild.cacheManifest^headers^ gZipOfflineChild.html gZipOfflineChild.html^headers^ -# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. [browser_page_style_menu.js] # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. [browser_page_style_menu_update.js] diff --git a/browser/base/content/test/general/browser_gZipOfflineChild.js b/browser/base/content/test/general/browser_gZipOfflineChild.js deleted file mode 100644 index ae7802c2ed3b..000000000000 --- a/browser/base/content/test/general/browser_gZipOfflineChild.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -const URL = - "http://mochi.test:8888/browser/browser/base/content/test/general/test_offline_gzip.html"; - -registerCleanupFunction(function() { - // Clean up after ourself - let uri = Services.io.newURI(URL); - let principal = Services.scriptSecurityManager.createContentPrincipal( - uri, - {} - ); - Services.perms.removeFromPrincipal(principal, "offline-app"); -}); - -// -// Handle "message" events which are posted from the iframe upon -// offline cache events. -// -function contentTask() { - const { clearInterval, setInterval } = ChromeUtils.import( - "resource://gre/modules/Timer.jsm" - ); - - let resolve; - let promise = new Promise(r => { - resolve = r; - }); - - var cacheCount = 0; - var intervalID = 0; - - function handleMessageEvents(event) { - cacheCount++; - switch (cacheCount) { - case 1: - // This is the initial caching off offline data. - is(event.data, "oncache", "Child was successfully cached."); - // Reload the frame; this will generate an error message - // in the case of bug 501422. - event.source.location.reload(); - // Use setInterval to repeatedly call a function which - // checks that one of two things has occurred: either - // the offline cache is udpated (which means our iframe - // successfully reloaded), or the string "error" appears - // in the iframe, as in the case of bug 501422. - intervalID = setInterval(function() { - // Sometimes document.body may not exist, and trying to access - // it will throw an exception, so handle this case. - try { - var bodyInnerHTML = event.source.document.body.innerHTML; - } catch (e) { - bodyInnerHTML = ""; - } - if (cacheCount == 2 || bodyInnerHTML.includes("error")) { - clearInterval(intervalID); - is(cacheCount, 2, "frame not reloaded successfully"); - if (cacheCount != 2) { - finish(); - } - } - }, 100); - break; - case 2: - is(event.data, "onupdate", "Child was successfully updated."); - clearInterval(intervalID); - resolve(); - break; - default: - // how'd we get here? - ok(false, "cacheCount not 1 or 2"); - } - } - - content.addEventListener("message", handleMessageEvents); - return promise; -} - -function test() { - waitForExplicitFinish(); - - // Open a new tab. - gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL); - registerCleanupFunction(() => gBrowser.removeCurrentTab()); - - BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => { - ContentTask.spawn(gBrowser.selectedBrowser, null, contentTask).then(finish); - }); -} diff --git a/browser/base/content/test/general/browser_offlineQuotaNotification.js b/browser/base/content/test/general/browser_offlineQuotaNotification.js deleted file mode 100644 index 90ec4370f2e4..000000000000 --- a/browser/base/content/test/general/browser_offlineQuotaNotification.js +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// Test offline quota warnings - must be run as a mochitest-browser test or -// else the test runner gets in the way of notifications due to bug 857897. - -const URL = - "http://mochi.test:8888/browser/browser/base/content/test/general/offlineQuotaNotification.html"; - -registerCleanupFunction(function() { - // Clean up after ourself - let uri = Services.io.newURI(URL); - let principal = Services.scriptSecurityManager.createContentPrincipal( - uri, - {} - ); - Services.perms.removeFromPrincipal(principal, "offline-app"); - Services.prefs.clearUserPref("offline-apps.quota.warn"); - let { OfflineAppCacheHelper } = ChromeUtils.import( - "resource://gre/modules/offlineAppCache.jsm" - ); - OfflineAppCacheHelper.clear(); -}); - -// Same as the other one, but for in-content preferences -function checkInContentPreferences(win) { - let doc = win.document; - let sel = doc.getElementById("categories").selectedItems[0].id; - is( - gBrowser.currentURI.spec, - "about:preferences#privacy", - "about:preferences loaded" - ); - is(sel, "category-privacy", "Privacy pane was selected"); - // all good, we are done. - win.close(); - finish(); -} - -async function test() { - waitForExplicitFinish(); - - let notificationShown = promiseNotification(); - - // Open a new tab. - gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL); - registerCleanupFunction(() => gBrowser.removeCurrentTab()); - - // Wait for the tab to load. - await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - info("Loaded page, adding onCached handler"); - // Need a promise to keep track of when we've added our handler. - let mm = gBrowser.selectedBrowser.messageManager; - let onCachedAttached = BrowserTestUtils.waitForMessage( - mm, - "Test:OnCachedAttached" - ); - let gotCached = ContentTask.spawn( - gBrowser.selectedBrowser, - null, - async function() { - return new Promise(resolve => { - content.window.applicationCache.oncached = function() { - setTimeout(resolve, 0); - }; - sendAsyncMessage("Test:OnCachedAttached"); - }); - } - ); - gotCached.then(async function() { - // We got cached - now we should have provoked the quota warning. - await notificationShown; - let notification = PopupNotifications.getNotification("offline-app-usage"); - ok(notification, "have offline-app-usage notification"); - // select the default action - this should cause the preferences - // tab to open - which we track via an "Initialized" event. - PopupNotifications.panel.firstElementChild.button.click(); - let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab); - newTabBrowser.addEventListener( - "Initialized", - function() { - executeSoon(function() { - checkInContentPreferences(newTabBrowser.contentWindow); - }); - }, - { capture: true, once: true } - ); - }); - onCachedAttached.then(function() { - Services.prefs.setIntPref("offline-apps.quota.warn", 1); - }); -} - -function promiseNotification() { - return new Promise(resolve => { - PopupNotifications.panel.addEventListener( - "popupshown", - function() { - resolve(); - }, - { once: true } - ); - }); -} diff --git a/browser/base/content/test/general/gZipOfflineChild.cacheManifest b/browser/base/content/test/general/gZipOfflineChild.cacheManifest deleted file mode 100644 index ae0545d12bed..000000000000 --- a/browser/base/content/test/general/gZipOfflineChild.cacheManifest +++ /dev/null @@ -1,2 +0,0 @@ -CACHE MANIFEST -gZipOfflineChild.html diff --git a/browser/base/content/test/general/gZipOfflineChild.cacheManifest^headers^ b/browser/base/content/test/general/gZipOfflineChild.cacheManifest^headers^ deleted file mode 100644 index 257f2eb60f11..000000000000 --- a/browser/base/content/test/general/gZipOfflineChild.cacheManifest^headers^ +++ /dev/null @@ -1 +0,0 @@ -Content-Type: text/cache-manifest diff --git a/browser/base/content/test/general/gZipOfflineChild.html b/browser/base/content/test/general/gZipOfflineChild.html deleted file mode 100644 index ea2caa12553bc4754c59e9d3007cacd76460a572..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 303 zcmV+~0nq**iwFoCjp|kc17>e;E@*UZYyfqUF;BxV5QTUDiX&5tNTO~?I9WPZEKF?1 zzSLKxwq;)^1@*sUC#}RlCrkJFy}NrSEgwfXDn|n*?yCJeh1X#i$>G-0Xd11w#od)x zy^t1_=>>p%sB3t$lwhC{A;0@?3IPqU2OUu{g8%C@cdF}b!Neo>vRz&wkH`wNRWV^6 zVd9~FE}fE&6d3p%u&WrqxIL&(wNx_~!{juRcXk5GsU`v?^ZPvTozuytaW3ZcSF%_SUGn@+^nTe`@EaU`haY z^$WjifHC@bUp?bREM&VRk^^g(+X(sL&AFUv)6daouqpUjZp$Tl@eAkxgv$E?007-I BlHC9R diff --git a/browser/base/content/test/general/gZipOfflineChild.html^headers^ b/browser/base/content/test/general/gZipOfflineChild.html^headers^ deleted file mode 100644 index 4204d8601d32..000000000000 --- a/browser/base/content/test/general/gZipOfflineChild.html^headers^ +++ /dev/null @@ -1,2 +0,0 @@ -Content-Type: text/html -Content-Encoding: gzip diff --git a/browser/base/content/test/general/offlineQuotaNotification.cacheManifest b/browser/base/content/test/general/offlineQuotaNotification.cacheManifest deleted file mode 100644 index 2e210abd29d4..000000000000 --- a/browser/base/content/test/general/offlineQuotaNotification.cacheManifest +++ /dev/null @@ -1,7 +0,0 @@ -CACHE MANIFEST -# Any copyright is dedicated to the Public Domain. -# http://creativecommons.org/publicdomain/zero/1.0/ - -# store a "large" file so an "over quota warning" will be issued - any file -# larger than 1kb and in '_BROWSER_FILES' should be right... -title_test.svg diff --git a/browser/base/content/test/general/offlineQuotaNotification.html b/browser/base/content/test/general/offlineQuotaNotification.html deleted file mode 100644 index b1b91bf9e009..000000000000 --- a/browser/base/content/test/general/offlineQuotaNotification.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - Test offline app quota notification - - - diff --git a/browser/base/content/test/general/test_offline_gzip.html b/browser/base/content/test/general/test_offline_gzip.html deleted file mode 100644 index a18d6604e5d9..000000000000 --- a/browser/base/content/test/general/test_offline_gzip.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - Test gzipped offline resources - - - -

- - -

- - diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index df61628fa4d3..8fbe821b02f4 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -437,10 +437,6 @@ offlineApps.allowStoring.accesskey=A offlineApps.dontAllow.label=Don’t Allow offlineApps.dontAllow.accesskey=n -offlineApps.usage=This website (%S) is now storing more than %SMB of data on your computer for offline use. -offlineApps.manageUsage=Show settings -offlineApps.manageUsageAccessKey=S - # Canvas permission prompt # LOCALIZATION NOTE (canvas.siteprompt): %S is hostname canvas.siteprompt=Will you allow %S to use your HTML5 canvas image data? This may be used to uniquely identify your computer. diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js index 9f3896c5f7fc..8cbab2c1dabb 100644 --- a/mobile/android/app/mobile.js +++ b/mobile/android/app/mobile.js @@ -80,7 +80,6 @@ pref("image.cache.size", 1048576); // bytes /* offline cache prefs */ pref("browser.offline-apps.notify", true); pref("browser.cache.offline.capacity", 5120); // kilobytes -pref("offline-apps.quota.warn", 1024); // kilobytes // Automatically shrink-to-fit image documents. pref("browser.enable_automatic_image_resizing", true); diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 572549539e15..b91c5c5bc1b0 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -227,10 +227,6 @@ pref("browser.cache.offline.insecure.enable", false); // offline cache capacity in kilobytes pref("browser.cache.offline.capacity", 512000); -// the user should be warned if offline app disk usage exceeds this amount -// (in kilobytes) -pref("offline-apps.quota.warn", 51200); - // Don't show "Open with" option on download dialog if true. pref("browser.download.forbid_open_with", false);