Bug 1568884. Remove unnecessary QIs to nsIObjectLoadingContent. r=mossop
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 25 Jul 2019 15:27:39 +0000
changeset 484738 7756e54abf1492b1baee7c529ec1a916d5ed7021
parent 484737 6b69fa403574484dcf9b8b7daf9c4bdd3dd22ca0
child 484739 240af4c05f02716dc22a429ec04254249a318e44
push id90908
push userbzbarsky@mozilla.com
push dateThu, 25 Jul 2019 16:57:30 +0000
treeherderautoland@7756e54abf14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1568884
milestone70.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 1568884. Remove unnecessary QIs to nsIObjectLoadingContent. r=mossop They're no-ops with Web IDL bindings. Differential Revision: https://phabricator.services.mozilla.com/D39356
browser/actors/PluginChild.jsm
browser/base/content/test/plugins/browser_CTP_crashreporting.js
browser/base/content/test/plugins/browser_blocking.js
browser/base/content/test/plugins/browser_bug743421.js
browser/base/content/test/plugins/browser_pluginCrashReportNonDeterminism.js
browser/base/content/test/plugins/browser_private_clicktoplay.js
browser/base/content/test/plugins/head.js
toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js
--- a/browser/actors/PluginChild.jsm
+++ b/browser/actors/PluginChild.jsm
@@ -132,17 +132,16 @@ class PluginChild extends JSWindowActorC
       pluginElement.openOrClosedShadowRoot.isUAWidget()
     ) {
       return pluginElement.openOrClosedShadowRoot.getElementById(anonid);
     }
     return null;
   }
 
   _getPluginInfo(pluginElement) {
-    pluginElement.QueryInterface(Ci.nsIObjectLoadingContent);
     if (this.isKnownPlugin(pluginElement)) {
       let pluginTag = gPluginHost.getPluginTagForType(pluginElement.actualType);
       let pluginName = BrowserUtils.makeNicePluginName(pluginTag.name);
       let fallbackType = pluginElement.defaultFallbackType;
       let permissionString = gPluginHost.getPermissionStringForType(
         pluginElement.actualType
       );
       return { pluginTag, pluginName, fallbackType, permissionString };
@@ -670,24 +669,23 @@ class PluginChild extends JSWindowActorC
 
   reloadPage() {
     this.contentWindow.location.reload();
   }
 
   // Event listener for click-to-play plugins.
   _handleClickToPlayEvent(plugin) {
     let doc = plugin.ownerDocument;
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
     // guard against giving pluginHost.getPermissionStringForType a type
     // not associated with any known plugin
-    if (!this.isKnownPlugin(objLoadingContent)) {
+    if (!this.isKnownPlugin(plugin)) {
       return;
     }
     let permissionString = gPluginHost.getPermissionStringForType(
-      objLoadingContent.actualType
+      plugin.actualType
     );
     let principal = doc.defaultView.top.document.nodePrincipal;
     let pluginPermission = Services.perms.testPermissionFromPrincipal(
       principal,
       permissionString
     );
 
     let overlay = this.getPluginUI(plugin, "main");
@@ -731,33 +729,31 @@ class PluginChild extends JSWindowActorC
 
   reshowClickToPlayNotification() {
     let { plugins } = this.contentWindow.windowUtils;
     for (let plugin of plugins) {
       let overlay = this.getPluginUI(plugin, "main");
       if (overlay) {
         overlay.removeEventListener("click", this, true);
       }
-      let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-      if (this.canActivatePlugin(objLoadingContent)) {
+      if (this.canActivatePlugin(plugin)) {
         this._handleClickToPlayEvent(plugin);
       }
     }
     this.showClickToPlayNotification(null, false);
   }
 
   /**
    * Activate the plugins that the user has specified.
    */
   activatePlugins(activationInfo, newState) {
     let { plugins } = this.contentWindow.windowUtils;
 
     let pluginFound = false;
     for (let plugin of plugins) {
-      plugin.QueryInterface(Ci.nsIObjectLoadingContent);
       if (!this.isKnownPlugin(plugin)) {
         continue;
       }
       if (
         activationInfo.permissionString ==
         gPluginHost.getPermissionStringForType(plugin.actualType)
       ) {
         let overlay = this.getPluginUI(plugin, "main");
--- a/browser/base/content/test/plugins/browser_CTP_crashreporting.js
+++ b/browser/base/content/test/plugins/browser_CTP_crashreporting.js
@@ -85,17 +85,16 @@ add_task(async function() {
     };
     let crashReportPromise = TestUtils.topicObserved(
       "crash-report-status",
       crashReportChecker
     );
 
     await ContentTask.spawn(browser, null, async function() {
       let plugin = content.document.getElementById("test");
-      plugin.QueryInterface(Ci.nsIObjectLoadingContent);
 
       await ContentTaskUtils.waitForCondition(() => {
         return plugin.activated;
       }, "Waited too long for plugin to activate.");
 
       try {
         Cu.waiveXrays(plugin).crash();
       } catch (e) {}
@@ -202,17 +201,16 @@ add_task(async function() {
       };
       let crashReportPromise = TestUtils.topicObserved(
         "crash-report-status",
         crashReportChecker
       );
 
       await ContentTask.spawn(browser, null, async function() {
         let plugin = content.document.getElementById("test");
-        plugin.QueryInterface(Ci.nsIObjectLoadingContent);
 
         await ContentTaskUtils.waitForCondition(() => {
           return plugin.activated;
         }, "Waited too long for plugin to activate.");
 
         try {
           Cu.waiveXrays(plugin).crash();
         } catch (e) {}
--- a/browser/base/content/test/plugins/browser_blocking.js
+++ b/browser/base/content/test/plugins/browser_blocking.js
@@ -424,12 +424,11 @@ add_task(async function() {
   is(
     pluginInfo.pluginFallbackType,
     Ci.nsIObjectLoadingContent.PLUGIN_BLOCKLISTED,
     "Test 26, plugin fallback type should be PLUGIN_BLOCKLISTED"
   );
 
   await ContentTask.spawn(gTestBrowser, null, async function() {
     let plugin = content.document.getElementById("test");
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    Assert.ok(!objLoadingContent.activated, "Plugin should not be activated.");
+    Assert.ok(!plugin.activated, "Plugin should not be activated.");
   });
 });
--- a/browser/base/content/test/plugins/browser_bug743421.js
+++ b/browser/base/content/test/plugins/browser_bug743421.js
@@ -63,99 +63,74 @@ add_task(async function() {
   });
 
   await promisePopupNotification("click-to-play-plugins");
 });
 
 add_task(async function() {
   await ContentTask.spawn(gTestBrowser, {}, async function() {
     let plugin = content.document.getElementsByTagName("embed")[0];
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    Assert.ok(
-      !objLoadingContent.activated,
-      "Test 1b, Plugin should not be activated"
-    );
+    Assert.ok(!plugin.activated, "Test 1b, Plugin should not be activated");
   });
 
   // Click the activate button on doorhanger to make sure it works
   let notification = PopupNotifications.getNotification(
     "click-to-play-plugins",
     gTestBrowser
   );
 
   await promiseForNotificationShown(notification);
 
   PopupNotifications.panel.firstElementChild.button.click();
 
   await ContentTask.spawn(gTestBrowser, {}, async function() {
     let plugin = content.document.getElementsByTagName("embed")[0];
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    Assert.ok(
-      objLoadingContent.activated,
-      "Test 1b, Plugin should be activated"
-    );
+    Assert.ok(plugin.activated, "Test 1b, Plugin should be activated");
   });
 });
 
 add_task(async function() {
   let notification = PopupNotifications.getNotification(
     "click-to-play-plugins",
     gTestBrowser
   );
   ok(notification, "Test 1c, Should still have a click-to-play notification");
 
   await ContentTask.spawn(gTestBrowser, {}, async function() {
     new XPCNativeWrapper(XPCNativeWrapper.unwrap(content).addPlugin());
     let plugin = content.document.getElementsByTagName("embed")[1];
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
     Assert.ok(
-      objLoadingContent.activated,
+      plugin.activated,
       "Test 1c, Newly inserted plugin in activated page should be activated"
     );
   });
 });
 
 add_task(async function() {
   await ContentTask.spawn(gTestBrowser, {}, async function() {
     let plugin = content.document.getElementsByTagName("embed")[1];
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    Assert.ok(
-      objLoadingContent.activated,
-      "Test 1d, Plugin should be activated"
-    );
+    Assert.ok(plugin.activated, "Test 1d, Plugin should be activated");
 
     let promise = ContentTaskUtils.waitForEvent(content, "hashchange");
     content.location += "#anchorNavigation";
     await promise;
   });
 });
 
 add_task(async function() {
   await ContentTask.spawn(gTestBrowser, {}, async function() {
     new XPCNativeWrapper(XPCNativeWrapper.unwrap(content).addPlugin());
     let plugin = content.document.getElementsByTagName("embed")[2];
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    Assert.ok(
-      objLoadingContent.activated,
-      "Test 1e, Plugin should be activated"
-    );
+    Assert.ok(plugin.activated, "Test 1e, Plugin should be activated");
   });
 });
 
 add_task(async function() {
   await ContentTask.spawn(gTestBrowser, {}, async function() {
     let plugin = content.document.getElementsByTagName("embed")[2];
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    Assert.ok(
-      objLoadingContent.activated,
-      "Test 1f, Plugin should be activated"
-    );
+    Assert.ok(plugin.activated, "Test 1f, Plugin should be activated");
 
     content.history.replaceState({}, "", "replacedState");
     new XPCNativeWrapper(XPCNativeWrapper.unwrap(content).addPlugin());
     plugin = content.document.getElementsByTagName("embed")[3];
-    objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    Assert.ok(
-      objLoadingContent.activated,
-      "Test 1g, Plugin should be activated"
-    );
+    Assert.ok(plugin.activated, "Test 1g, Plugin should be activated");
   });
 });
--- a/browser/base/content/test/plugins/browser_pluginCrashReportNonDeterminism.js
+++ b/browser/base/content/test/plugins/browser_pluginCrashReportNonDeterminism.js
@@ -56,17 +56,16 @@ const CRASH_URL =
  *        the run ID for the crashed plugin. It rejects if we never get into
  *        the crash reporter state.
  */
 function preparePlugin(browser, pluginFallbackState) {
   return ContentTask.spawn(browser, pluginFallbackState, async function(
     contentPluginFallbackState
   ) {
     let plugin = content.document.getElementById("plugin");
-    plugin.QueryInterface(Ci.nsIObjectLoadingContent);
     // CRASH_URL will load a plugin that crashes immediately. We
     // wait until the plugin has finished being put into the crash
     // state.
     let statusDiv;
     await ContentTaskUtils.waitForCondition(() => {
       statusDiv = plugin.openOrClosedShadowRoot.getElementById("submitStatus");
 
       return statusDiv && statusDiv.getAttribute("status") == "please";
@@ -159,17 +158,16 @@ add_task(async function testChromeHearsP
   // for crash data. in `testContentHearsCrashFirst we will delay the
   // response (simulating what happens if the parent doesn't know about
   // the crash yet).
   await ContentTask.spawn(browser, null, async function() {
     // At this point, the content process should have heard the
     // plugin crash message from the parent, and we are OK to emit
     // the PluginCrashed event.
     let plugin = content.document.getElementById("plugin");
-    plugin.QueryInterface(Ci.nsIObjectLoadingContent);
     let statusDiv = plugin.openOrClosedShadowRoot.getElementById(
       "submitStatus"
     );
 
     if (statusDiv.getAttribute("status") == "please") {
       Assert.ok(false, "Did not expect plugin to be in crash report mode yet.");
       return;
     }
@@ -246,17 +244,16 @@ add_task(async function testContentHears
     });
   });
 
   await ContentTask.spawn(browser, null, async function() {
     // At this point, the content process has not yet heard from the
     // parent about the crash report. Let's ensure that by making sure
     // we're not showing the plugin crash report UI.
     let plugin = content.document.getElementById("plugin");
-    plugin.QueryInterface(Ci.nsIObjectLoadingContent);
     let statusDiv = plugin.openOrClosedShadowRoot.getElementById(
       "submitStatus"
     );
 
     if (statusDiv.getAttribute("status") == "please") {
       Assert.ok(false, "Did not expect plugin to be in crash report mode yet.");
     }
 
@@ -271,17 +268,16 @@ add_task(async function testContentHears
 
     plugin.dispatchEvent(event);
   });
   let receivedData = await parentRequestPromise;
   is(receivedData.runID, runID, "Should get a request for the same crash.");
 
   await ContentTask.spawn(browser, null, function() {
     let plugin = content.document.getElementById("plugin");
-    plugin.QueryInterface(Ci.nsIObjectLoadingContent);
     let statusDiv = plugin.openOrClosedShadowRoot.getElementById(
       "submitStatus"
     );
     Assert.notEqual(
       statusDiv.getAttribute("status"),
       "please",
       "Should not yet be showing crash report UI"
     );
@@ -290,17 +286,16 @@ add_task(async function testContentHears
   // Now allow the parent to respond to the child with crash info:
   allowParentToRespond.resolve();
 
   await ContentTask.spawn(browser, null, async function() {
     // At this point, the content process will have heard the message
     // from the parent and reacted to it. We should be showing the plugin
     // crash report UI now.
     let plugin = content.document.getElementById("plugin");
-    plugin.QueryInterface(Ci.nsIObjectLoadingContent);
     let statusDiv = plugin.openOrClosedShadowRoot.getElementById(
       "submitStatus"
     );
     await ContentTaskUtils.waitForCondition(() => {
       return statusDiv && statusDiv.getAttribute("status") == "please";
     });
 
     Assert.equal(
--- a/browser/base/content/test/plugins/browser_private_clicktoplay.js
+++ b/browser/base/content/test/plugins/browser_private_clicktoplay.js
@@ -60,18 +60,17 @@ add_task(async function test1b() {
   let popupNotification = gPrivateWindow.PopupNotifications.getNotification(
     "click-to-play-plugins",
     gPrivateBrowser
   );
   ok(popupNotification, "Test 1b, Should have a click-to-play notification");
 
   await ContentTask.spawn(gPrivateBrowser, null, function() {
     let plugin = content.document.getElementById("test");
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    ok(!objLoadingContent.activated, "Test 1b, Plugin should not be activated");
+    ok(!plugin.activated, "Test 1b, Plugin should not be activated");
   });
 
   // Check the button status
   let promiseShown = BrowserTestUtils.waitForEvent(
     gPrivateWindow.PopupNotifications.panel,
     "Shown"
   );
   popupNotification.reshow();
@@ -102,34 +101,32 @@ add_task(async function test2a() {
   let popupNotification = PopupNotifications.getNotification(
     "click-to-play-plugins",
     gTestBrowser
   );
   ok(popupNotification, "Test 2a, Should have a click-to-play notification");
 
   await ContentTask.spawn(gTestBrowser, null, function() {
     let plugin = content.document.getElementById("test");
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    ok(!objLoadingContent.activated, "Test 2a, Plugin should not be activated");
+    ok(!plugin.activated, "Test 2a, Plugin should not be activated");
   });
 
   // Simulate clicking the "Allow Now" button.
   let promiseShown = BrowserTestUtils.waitForEvent(
     PopupNotifications.panel,
     "Shown"
   );
   popupNotification.reshow();
   await promiseShown;
 
   PopupNotifications.panel.firstElementChild.button.click();
 
   await ContentTask.spawn(gTestBrowser, null, async function() {
     let plugin = content.document.getElementById("test");
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    let condition = () => objLoadingContent.activated;
+    let condition = () => plugin.activated;
     await ContentTaskUtils.waitForCondition(
       condition,
       "Test 2a, Waited too long for plugin to activate"
     );
   });
 });
 
 add_task(async function test2c() {
@@ -144,18 +141,17 @@ add_task(async function test2c() {
       "click-to-play-plugins",
       gPrivateBrowser
     );
   }, "Waiting for click-to-play-plugins notification in the private window");
   ok(popupNotification, "Test 2c, Should have a click-to-play notification");
 
   await ContentTask.spawn(gPrivateBrowser, null, function() {
     let plugin = content.document.getElementById("test");
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    ok(objLoadingContent.activated, "Test 2c, Plugin should be activated");
+    ok(plugin.activated, "Test 2c, Plugin should be activated");
   });
 
   // Check the button status
   let promiseShown = BrowserTestUtils.waitForEvent(
     gPrivateWindow.PopupNotifications.panel,
     "Shown"
   );
   popupNotification.reshow();
@@ -193,33 +189,31 @@ add_task(async function test3a() {
   let popupNotification = PopupNotifications.getNotification(
     "click-to-play-plugins",
     gTestBrowser
   );
   ok(popupNotification, "Test 3a, Should have a click-to-play notification");
 
   await ContentTask.spawn(gTestBrowser, null, function() {
     let plugin = content.document.getElementById("test");
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    ok(!objLoadingContent.activated, "Test 3a, Plugin should not be activated");
+    ok(!plugin.activated, "Test 3a, Plugin should not be activated");
   });
 
   // Simulate clicking the "Allow" button.
   let promiseShown = BrowserTestUtils.waitForEvent(
     PopupNotifications.panel,
     "Shown"
   );
   popupNotification.reshow();
   await promiseShown;
   PopupNotifications.panel.firstElementChild.button.click();
 
   await ContentTask.spawn(gTestBrowser, null, async function() {
     let plugin = content.document.getElementById("test");
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    let condition = () => objLoadingContent.activated;
+    let condition = () => plugin.activated;
     await ContentTaskUtils.waitForCondition(
       condition,
       "Test 3a, Waited too long for plugin to activate"
     );
   });
 });
 
 add_task(async function test3c() {
--- a/browser/base/content/test/plugins/head.js
+++ b/browser/base/content/test/plugins/head.js
@@ -158,24 +158,21 @@ function promiseForPluginInfo(aId, aBrow
       pluginFallbackType: plugin.pluginFallbackType,
       activated: plugin.activated,
       hasRunningPlugin: plugin.hasRunningPlugin,
       displayedType: plugin.displayedType,
     };
   });
 }
 
-// Return a promise and call the plugin's nsIObjectLoadingContent
-// playPlugin() method.
+// Return a promise and call the plugin's playPlugin() method.
 function promisePlayObject(aId, aBrowser) {
   let browser = aBrowser || gTestBrowser;
   return ContentTask.spawn(browser, aId, async function(contentId) {
-    let plugin = content.document.getElementById(contentId);
-    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-    objLoadingContent.playPlugin();
+    content.document.getElementById(contentId).playPlugin();
   });
 }
 
 function promiseCrashObject(aId, aBrowser) {
   let browser = aBrowser || gTestBrowser;
   return ContentTask.spawn(browser, aId, async function(contentId) {
     let plugin = content.document.getElementById(contentId);
     Cu.waiveXrays(plugin).crash();
--- a/toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js
@@ -125,25 +125,22 @@ add_task(async function test_CTP_plugins
   pluginTab = await BrowserTestUtils.openNewForegroundTab(
     gBrowser,
     gHttpTestRoot + "plugin_test.html"
   );
 
   await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
     let testPlugin = content.document.getElementById("test");
     ok(testPlugin, "part5: should have a plugin element in the page");
-    let objLoadingContent = testPlugin.QueryInterface(
-      Ci.nsIObjectLoadingContent
-    );
-    let condition = () => objLoadingContent.activated;
+    let condition = () => testPlugin.activated;
     await ContentTaskUtils.waitForCondition(
       condition,
       "part5: waited too long for plugin to activate"
     );
-    ok(objLoadingContent.activated, "part6: plugin should be activated");
+    ok(testPlugin.activated, "part6: plugin should be activated");
   });
 
   BrowserTestUtils.removeTab(pluginTab);
 
   setPluginActivateState({
     managerWindow,
     pluginId: testPluginId,
     activateState: "never-activate",
@@ -153,20 +150,17 @@ add_task(async function test_CTP_plugins
     gBrowser,
     gHttpTestRoot + "plugin_test.html"
   );
   pluginBrowser = pluginTab.linkedBrowser;
 
   await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
     let testPlugin = content.document.getElementById("test");
     ok(testPlugin, "part7: should have a plugin element in the page");
-    let objLoadingContent = testPlugin.QueryInterface(
-      Ci.nsIObjectLoadingContent
-    );
-    ok(!objLoadingContent.activated, "part7: plugin should not be activated");
+    ok(!testPlugin.activated, "part7: plugin should not be activated");
   });
 
   BrowserTestUtils.removeTab(pluginTab);
 
   info("part8: test plugin state is never-activate");
   pluginEl = get_addon_element(managerWindow, testPluginId);
 
   pluginOptions = pluginEl.querySelector("plugin-options");
@@ -188,25 +182,22 @@ add_task(async function test_CTP_plugins
     gBrowser,
     gHttpTestRoot + "plugin_test.html"
   );
   pluginBrowser = pluginTab.linkedBrowser;
 
   await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
     let testPlugin = content.document.getElementById("test");
     ok(testPlugin, "part9: should have a plugin element in the page");
-    let objLoadingContent = testPlugin.QueryInterface(
-      Ci.nsIObjectLoadingContent
-    );
-    let condition = () => objLoadingContent.activated;
+    let condition = () => testPlugin.activated;
     await ContentTaskUtils.waitForCondition(
       condition,
       "part9: waited too long for plugin to activate"
     );
-    ok(objLoadingContent.activated, "part10: plugin should be activated");
+    ok(testPlugin.activated, "part10: plugin should be activated");
   });
 
   BrowserTestUtils.removeTab(pluginTab);
 
   setPluginActivateState({
     managerWindow,
     pluginId: testPluginId,
     activateState: "ask-to-activate",