gecko-dev/browser/base/content/test/plugins/browser_bug797677.js
Kris Maglione 94e3b0bd8d Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

Differential Revision: https://phabricator.services.mozilla.com/D53740

--HG--
extra : moz-landing-system : lando
2019-12-13 20:36:16 +00:00

52 lines
1.4 KiB
JavaScript

var gTestRoot = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content/",
"http://127.0.0.1:8888/"
);
var gTestBrowser = null;
var gConsoleErrors = 0;
add_task(async function() {
registerCleanupFunction(function() {
clearAllPluginPermissions();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(
Ci.nsIPluginTag.STATE_ENABLED,
"Second Test Plug-in"
);
Services.console.unregisterListener(errorListener);
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
let errorListener = {
observe(aMessage) {
if (aMessage.message.includes("NS_ERROR_FAILURE")) {
gConsoleErrors++;
}
},
};
Services.console.registerListener(errorListener);
await promiseTabLoadEvent(
gBrowser.selectedTab,
gTestRoot + "plugin_bug797677.html"
);
let pluginInfo = await promiseForPluginInfo("plugin");
is(
pluginInfo.pluginFallbackType,
Ci.nsIObjectLoadingContent.PLUGIN_UNSUPPORTED,
"plugin should not have been found."
);
// simple cpows
await SpecialPowers.spawn(gTestBrowser, [], function() {
let plugin = content.document.getElementById("plugin");
ok(plugin, "plugin should be in the page");
});
is(gConsoleErrors, 0, "should have no console errors");
});