Bug 1550877 - Use correct E10SUtils in GeckoViewNavigation. r=snorp
☠☠ backed out by 55e45fc9d529 ☠ ☠
authorAgi Sferro <agi@sferro.dev>
Fri, 17 May 2019 04:10:53 +0000
changeset 474294 877ae9359a2774f9ccee1f68935b4e7194a5711e
parent 474293 aee7bbc03bff773a8ce895d0bd58174f2f8aafa1
child 474295 aa06b77b2d6b613e2c0d51cf19f730ad3a1f27d7
push id36027
push usershindli@mozilla.com
push dateFri, 17 May 2019 16:24:38 +0000
treeherdermozilla-central@c94c54aff466 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1550877
milestone68.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 1550877 - Use correct E10SUtils in GeckoViewNavigation. r=snorp This fixes a crash in `browser.tabs.update` when used with WebExtension pages. Differential Revision: https://phabricator.services.mozilla.com/D31453
mobile/android/geckoview/src/androidTest/assets/web_extensions/extension-page-update/background-script.js
mobile/android/geckoview/src/androidTest/assets/web_extensions/extension-page-update/manifest.json
mobile/android/geckoview/src/androidTest/assets/web_extensions/extension-page-update/tab.html
mobile/android/geckoview/src/androidTest/assets/web_extensions/extension-page-update/tabs.js
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebExtensionTest.kt
mobile/android/modules/geckoview/GeckoViewNavigation.jsm
new file mode 100644
--- /dev/null
+++ b/mobile/android/geckoview/src/androidTest/assets/web_extensions/extension-page-update/background-script.js
@@ -0,0 +1,7 @@
+browser.runtime.onMessage.addListener(notify);
+
+function notify(message) {
+  if (message.action == "showTab") {
+    browser.tabs.update({url: "/tab.html"});
+  }
+}
new file mode 100644
--- /dev/null
+++ b/mobile/android/geckoview/src/androidTest/assets/web_extensions/extension-page-update/manifest.json
@@ -0,0 +1,24 @@
+{
+  "manifest_version": 2,
+  "name": "Mozilla Android Components - Tabs Update Test",
+  "version": "1.0",
+  "background": {
+    "scripts": ["background-script.js"]
+  },
+  "content_scripts": [
+    {
+      "matches": ["*://*.example.com/*"],
+      "js": ["tabs.js"],
+      "run_at": "document_idle"
+    }
+  ],
+  "web_accessible_resources": [
+    "tab.html"
+  ],
+  "permissions": [
+    "geckoViewAddons",
+    "nativeMessaging",
+    "tabs",
+    "<all_urls>"
+  ]
+}
new file mode 100644
--- /dev/null
+++ b/mobile/android/geckoview/src/androidTest/assets/web_extensions/extension-page-update/tab.html
@@ -0,0 +1,1 @@
+<h1>Hello World!</h1>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/mobile/android/geckoview/src/androidTest/assets/web_extensions/extension-page-update/tabs.js
@@ -0,0 +1,1 @@
+browser.runtime.sendMessage({"action": "showTab"});
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebExtensionTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebExtensionTest.kt
@@ -4,25 +4,28 @@
 
 package org.mozilla.geckoview.test
 
 import android.support.test.InstrumentationRegistry
 import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.ReuseSession
 
 import android.support.test.filters.MediumTest
 import android.support.test.runner.AndroidJUnit4
+import org.hamcrest.core.StringEndsWith.endsWith
 import org.hamcrest.core.IsEqual.equalTo
 import org.json.JSONObject
 import org.junit.Assert
 import org.junit.Assert.assertTrue
 import org.junit.Assert.fail
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.mozilla.geckoview.*
+import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
 import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDevToolsAPI
+import org.mozilla.geckoview.test.util.Callbacks
 import org.mozilla.geckoview.test.util.HttpBin
 import java.net.URI
 
 import java.util.UUID
 
 @RunWith(AndroidJUnit4::class)
 @MediumTest
 @ReuseSession(false)
@@ -456,16 +459,59 @@ class WebExtensionTest : BaseSessionTest
             sessionRule.waitForPageStop()
             testIframeTopLevel()
         } finally {
             httpBin.stop()
         }
     }
 
     @Test
+    fun loadWebExtensionPage() {
+        val extension = WebExtension("resource://android/assets/web_extensions/extension-page-update/")
+        sessionRule.waitForResult(sessionRule.runtime.registerWebExtension(extension))
+
+        mainSession.loadUri("http://example.com");
+
+        mainSession.waitUntilCalled(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate {
+            @GeckoSessionTestRule.AssertCalled(count = 1)
+            override fun onLocationChange(session: GeckoSession, url: String?) {
+                assertThat("Url should load example.com first",
+                        url, equalTo("http://example.com/"))
+            }
+
+            @GeckoSessionTestRule.AssertCalled(count = 1)
+            override fun onPageStop(session: GeckoSession, success: Boolean) {
+                assertThat("Page should load successfully.",
+                        success, equalTo(true))
+            }
+        })
+
+
+        var page: String? = null
+        var pageStop = GeckoResult<Boolean>()
+
+        mainSession.delegateUntilTestEnd(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate {
+            override fun onLocationChange(session: GeckoSession, url: String?) {
+                page = url
+            }
+
+            override fun onPageStop(session: GeckoSession, success: Boolean) {
+                if (success && page != null && page!!.endsWith("/tab.html")) {
+                    pageStop.complete(true)
+                }
+            }
+        })
+
+        // Make sure the page loaded successfully
+        sessionRule.waitForResult(pageStop)
+
+        assertThat("Url should load WebExtension page", page, endsWith("/tab.html"))
+    }
+
+    @Test
     fun badFileType() {
         testRegisterError("resource://android/bad/location/error",
                 "does not point to a folder or an .xpi")
     }
 
     @Test
     fun badLocationXpi() {
         testRegisterError("resource://android/bad/location/error.xpi",
--- a/mobile/android/modules/geckoview/GeckoViewNavigation.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewNavigation.jsm
@@ -5,17 +5,17 @@
 "use strict";
 
 var EXPORTED_SYMBOLS = ["GeckoViewNavigation"];
 
 const {GeckoViewModule} = ChromeUtils.import("resource://gre/modules/GeckoViewModule.jsm");
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
-  E10SUtils: "resource://gre/modules/sessionstore/Utils.jsm",
+  E10SUtils: "resource://gre/modules/E10SUtils.jsm",
   LoadURIDelegate: "resource://gre/modules/LoadURIDelegate.jsm",
   Services: "resource://gre/modules/Services.jsm",
 });
 
 XPCOMUtils.defineLazyGetter(this, "ReferrerInfo", () =>
   Components.Constructor(
     "@mozilla.org/referrer-info;1",
     "nsIReferrerInfo",