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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-07-25 15:27:39 +00:00
parent bdbe1ab086
commit c411601264
8 changed files with 24 additions and 79 deletions

View File

@ -137,7 +137,6 @@ class PluginChild extends JSWindowActorChild {
}
_getPluginInfo(pluginElement) {
pluginElement.QueryInterface(Ci.nsIObjectLoadingContent);
if (this.isKnownPlugin(pluginElement)) {
let pluginTag = gPluginHost.getPluginTagForType(pluginElement.actualType);
let pluginName = BrowserUtils.makeNicePluginName(pluginTag.name);
@ -675,14 +674,13 @@ class PluginChild extends JSWindowActorChild {
// 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(
@ -736,8 +734,7 @@ class PluginChild extends JSWindowActorChild {
if (overlay) {
overlay.removeEventListener("click", this, true);
}
let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
if (this.canActivatePlugin(objLoadingContent)) {
if (this.canActivatePlugin(plugin)) {
this._handleClickToPlayEvent(plugin);
}
}
@ -752,7 +749,6 @@ class PluginChild extends JSWindowActorChild {
let pluginFound = false;
for (let plugin of plugins) {
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
if (!this.isKnownPlugin(plugin)) {
continue;
}

View File

@ -90,7 +90,6 @@ add_task(async function() {
await ContentTask.spawn(browser, null, async function() {
let plugin = content.document.getElementById("test");
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
await ContentTaskUtils.waitForCondition(() => {
return plugin.activated;
@ -207,7 +206,6 @@ add_task(async function() {
await ContentTask.spawn(browser, null, async function() {
let plugin = content.document.getElementById("test");
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
await ContentTaskUtils.waitForCondition(() => {
return plugin.activated;

View File

@ -429,7 +429,6 @@ add_task(async function() {
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.");
});
});

View File

@ -68,11 +68,7 @@ add_task(async function() {
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
@ -87,11 +83,7 @@ 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 be activated"
);
Assert.ok(plugin.activated, "Test 1b, Plugin should be activated");
});
});
@ -105,9 +97,8 @@ add_task(async function() {
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"
);
});
@ -116,11 +107,7 @@ add_task(async function() {
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";
@ -132,30 +119,18 @@ 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");
});
});

View File

@ -61,7 +61,6 @@ function preparePlugin(browser, pluginFallbackState) {
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.
@ -164,7 +163,6 @@ add_task(async function testChromeHearsPluginCrashFirst() {
// 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"
);
@ -251,7 +249,6 @@ add_task(async function testContentHearsCrashFirst() {
// 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"
);
@ -276,7 +273,6 @@ add_task(async function testContentHearsCrashFirst() {
await ContentTask.spawn(browser, null, function() {
let plugin = content.document.getElementById("plugin");
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
let statusDiv = plugin.openOrClosedShadowRoot.getElementById(
"submitStatus"
);
@ -295,7 +291,6 @@ add_task(async function testContentHearsCrashFirst() {
// 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"
);

View File

@ -65,8 +65,7 @@ add_task(async function test1b() {
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
@ -107,8 +106,7 @@ add_task(async function test2a() {
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.
@ -123,8 +121,7 @@ add_task(async function test2a() {
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"
@ -149,8 +146,7 @@ add_task(async function test2c() {
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
@ -198,8 +194,7 @@ add_task(async function test3a() {
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.
@ -213,8 +208,7 @@ add_task(async function test3a() {
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"

View File

@ -163,14 +163,11 @@ function promiseForPluginInfo(aId, aBrowser) {
});
}
// 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();
});
}

View File

@ -130,15 +130,12 @@ add_task(async function test_CTP_plugins() {
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);
@ -158,10 +155,7 @@ add_task(async function test_CTP_plugins() {
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);
@ -193,15 +187,12 @@ add_task(async function test_CTP_plugins() {
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);