Bug 1632231 - Fix potential crash by gracefully failing when GV tries to add/remove/check content blocking exceptions for invalid URIs. r=esawin
authorDylan Roeh <droeh@mozilla.com>
Wed, 29 Apr 2020 16:45:27 +0000
changeset 526716 ea0374547549c2e17c49feb6fd06ac343c3d5caf
parent 526715 20a4d1902d33c843ea288b55dc6cf91049fb37f6
child 526717 6be8e31c4ab4f9b1965e8c53b35d50daf50c0675
push id37361
push usermalexandru@mozilla.com
push dateWed, 29 Apr 2020 21:55:39 +0000
treeherdermozilla-central@bc0932b38478 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1632231
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1632231 - Fix potential crash by gracefully failing when GV tries to add/remove/check content blocking exceptions for invalid URIs. r=esawin Differential Revision: https://phabricator.services.mozilla.com/D72012
mobile/android/modules/geckoview/GeckoViewContentBlockingController.jsm
--- a/mobile/android/modules/geckoview/GeckoViewContentBlockingController.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewContentBlockingController.jsm
@@ -36,42 +36,61 @@ const GeckoViewContentBlockingController
     debug`onEvent: event=${aEvent}, data=${aData}`;
 
     switch (aEvent) {
       case "ContentBlocking:AddException": {
         const sessionWindow = Services.ww.getWindowByName(
           aData.sessionId,
           null
         );
-        ContentBlockingAllowList.add(sessionWindow.browser);
+
+        if (ContentBlockingAllowList.canHandle(sessionWindow.browser)) {
+          ContentBlockingAllowList.add(sessionWindow.browser);
+        } else {
+          warn`Could not add content blocking exception`;
+        }
+
         break;
       }
 
       case "ContentBlocking:RemoveException": {
         const sessionWindow = Services.ww.getWindowByName(
           aData.sessionId,
           null
         );
-        ContentBlockingAllowList.remove(sessionWindow.browser);
+
+        if (ContentBlockingAllowList.canHandle(sessionWindow.browser)) {
+          ContentBlockingAllowList.remove(sessionWindow.browser);
+        } else {
+          warn`Could not remove content blocking exception`;
+        }
+
         break;
       }
 
       case "ContentBlocking:RemoveExceptionByPrincipal": {
         const principal = E10SUtils.deserializePrincipal(aData.principal);
         ContentBlockingAllowList.removeByPrincipal(principal);
         break;
       }
 
       case "ContentBlocking:CheckException": {
         const sessionWindow = Services.ww.getWindowByName(
           aData.sessionId,
           null
         );
-        const res = ContentBlockingAllowList.includes(sessionWindow.browser);
-        aCallback.onSuccess(res);
+
+        if (ContentBlockingAllowList.canHandle(sessionWindow.browser)) {
+          const res = ContentBlockingAllowList.includes(sessionWindow.browser);
+          aCallback.onSuccess(res);
+        } else {
+          warn`Could not check content blocking exception`;
+          aCallback.onSuccess(false);
+        }
+
         break;
       }
 
       case "ContentBlocking:SaveList": {
         const list = ContentBlockingAllowList.getAllowListedPrincipals();
         const principals = list.map(p => E10SUtils.serializePrincipal(p));
         const uris = list.map(p => (p.URI ? p.URI.displaySpec : null));
         aCallback.onSuccess({