Bug 1497940 - Part V, Convert pluginProblem to UA Widget r=smaug

This patch creates a pluginProblem UA Widget and constructs it (instead of the XBL pluginProblem binding) when UA Widget is enabled.

Tests in browser/base/content/test/plugins/ are duplicated so that we could test both versions.

Depends on D11702

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

--HG--
rename : browser/base/content/test/plugins/.eslintrc.js => browser/base/content/test/plugins/xbl/.eslintrc.js
rename : browser/base/content/test/plugins/blockNoPlugins.xml => browser/base/content/test/plugins/xbl/blockNoPlugins.xml
rename : browser/base/content/test/plugins/blockPluginHard.xml => browser/base/content/test/plugins/xbl/blockPluginHard.xml
rename : browser/base/content/test/plugins/blockPluginInfoURL.xml => browser/base/content/test/plugins/xbl/blockPluginInfoURL.xml
rename : browser/base/content/test/plugins/blockPluginVulnerableNoUpdate.xml => browser/base/content/test/plugins/xbl/blockPluginVulnerableNoUpdate.xml
rename : browser/base/content/test/plugins/blockPluginVulnerableUpdatable.xml => browser/base/content/test/plugins/xbl/blockPluginVulnerableUpdatable.xml
rename : browser/base/content/test/plugins/blocklist_proxy.js => browser/base/content/test/plugins/xbl/blocklist_proxy.js
rename : browser/base/content/test/plugins/browser.ini => browser/base/content/test/plugins/xbl/browser.ini
rename : browser/base/content/test/plugins/browser_CTP_context_menu.js => browser/base/content/test/plugins/xbl/browser_CTP_context_menu.js
rename : browser/base/content/test/plugins/browser_CTP_crashreporting.js => browser/base/content/test/plugins/xbl/browser_CTP_crashreporting.js
rename : browser/base/content/test/plugins/browser_CTP_drag_drop.js => browser/base/content/test/plugins/xbl/browser_CTP_drag_drop.js
rename : browser/base/content/test/plugins/browser_CTP_favorfallback.js => browser/base/content/test/plugins/xbl/browser_CTP_favorfallback.js
rename : browser/base/content/test/plugins/browser_CTP_hide_overlay.js => browser/base/content/test/plugins/xbl/browser_CTP_hide_overlay.js
rename : browser/base/content/test/plugins/browser_CTP_iframe.js => browser/base/content/test/plugins/xbl/browser_CTP_iframe.js
rename : browser/base/content/test/plugins/browser_CTP_nonplugins.js => browser/base/content/test/plugins/xbl/browser_CTP_nonplugins.js
rename : browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js => browser/base/content/test/plugins/xbl/browser_CTP_outsideScrollArea.js
rename : browser/base/content/test/plugins/browser_CTP_overlay_styles.js => browser/base/content/test/plugins/xbl/browser_CTP_overlay_styles.js
rename : browser/base/content/test/plugins/browser_CTP_resize.js => browser/base/content/test/plugins/xbl/browser_CTP_resize.js
rename : browser/base/content/test/plugins/browser_CTP_shouldShowOverlay.js => browser/base/content/test/plugins/xbl/browser_CTP_shouldShowOverlay.js
rename : browser/base/content/test/plugins/browser_CTP_zoom.js => browser/base/content/test/plugins/xbl/browser_CTP_zoom.js
rename : browser/base/content/test/plugins/browser_blocking.js => browser/base/content/test/plugins/xbl/browser_blocking.js
rename : browser/base/content/test/plugins/browser_blocklist_content.js => browser/base/content/test/plugins/xbl/browser_blocklist_content.js
rename : browser/base/content/test/plugins/browser_bug743421.js => browser/base/content/test/plugins/xbl/browser_bug743421.js
rename : browser/base/content/test/plugins/browser_bug744745.js => browser/base/content/test/plugins/xbl/browser_bug744745.js
rename : browser/base/content/test/plugins/browser_bug787619.js => browser/base/content/test/plugins/xbl/browser_bug787619.js
rename : browser/base/content/test/plugins/browser_bug797677.js => browser/base/content/test/plugins/xbl/browser_bug797677.js
rename : browser/base/content/test/plugins/browser_bug812562.js => browser/base/content/test/plugins/xbl/browser_bug812562.js
rename : browser/base/content/test/plugins/browser_bug818118.js => browser/base/content/test/plugins/xbl/browser_bug818118.js
rename : browser/base/content/test/plugins/browser_bug820497.js => browser/base/content/test/plugins/xbl/browser_bug820497.js
rename : browser/base/content/test/plugins/browser_clearplugindata.html => browser/base/content/test/plugins/xbl/browser_clearplugindata.html
rename : browser/base/content/test/plugins/browser_clearplugindata.js => browser/base/content/test/plugins/xbl/browser_clearplugindata.js
rename : browser/base/content/test/plugins/browser_clearplugindata_noage.html => browser/base/content/test/plugins/xbl/browser_clearplugindata_noage.html
rename : browser/base/content/test/plugins/browser_enable_DRM_prompt.js => browser/base/content/test/plugins/xbl/browser_enable_DRM_prompt.js
rename : browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js => browser/base/content/test/plugins/xbl/browser_globalplugin_crashinfobar.js
rename : browser/base/content/test/plugins/browser_iterate_hidden_plugins.js => browser/base/content/test/plugins/xbl/browser_iterate_hidden_plugins.js
rename : browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js => browser/base/content/test/plugins/xbl/browser_pluginCrashCommentAndURL.js
rename : browser/base/content/test/plugins/browser_pluginCrashReportNonDeterminism.js => browser/base/content/test/plugins/xbl/browser_pluginCrashReportNonDeterminism.js
rename : browser/base/content/test/plugins/browser_plugin_reloading.js => browser/base/content/test/plugins/xbl/browser_plugin_reloading.js
rename : browser/base/content/test/plugins/browser_pluginnotification.js => browser/base/content/test/plugins/xbl/browser_pluginnotification.js
rename : browser/base/content/test/plugins/browser_private_browsing_eme_persistent_state.js => browser/base/content/test/plugins/xbl/browser_private_browsing_eme_persistent_state.js
rename : browser/base/content/test/plugins/browser_private_clicktoplay.js => browser/base/content/test/plugins/xbl/browser_private_clicktoplay.js
rename : browser/base/content/test/plugins/browser_subframe_access_hidden_plugins.js => browser/base/content/test/plugins/xbl/browser_subframe_access_hidden_plugins.js
rename : browser/base/content/test/plugins/empty_file.html => browser/base/content/test/plugins/xbl/empty_file.html
rename : browser/base/content/test/plugins/plugin_add_dynamically.html => browser/base/content/test/plugins/xbl/plugin_add_dynamically.html
rename : browser/base/content/test/plugins/plugin_alternate_content.html => browser/base/content/test/plugins/xbl/plugin_alternate_content.html
rename : browser/base/content/test/plugins/plugin_big.html => browser/base/content/test/plugins/xbl/plugin_big.html
rename : browser/base/content/test/plugins/plugin_both.html => browser/base/content/test/plugins/xbl/plugin_both.html
rename : browser/base/content/test/plugins/plugin_both2.html => browser/base/content/test/plugins/xbl/plugin_both2.html
rename : browser/base/content/test/plugins/plugin_bug744745.html => browser/base/content/test/plugins/xbl/plugin_bug744745.html
rename : browser/base/content/test/plugins/plugin_bug749455.html => browser/base/content/test/plugins/xbl/plugin_bug749455.html
rename : browser/base/content/test/plugins/plugin_bug787619.html => browser/base/content/test/plugins/xbl/plugin_bug787619.html
rename : browser/base/content/test/plugins/plugin_bug797677.html => browser/base/content/test/plugins/xbl/plugin_bug797677.html
rename : browser/base/content/test/plugins/plugin_bug820497.html => browser/base/content/test/plugins/xbl/plugin_bug820497.html
rename : browser/base/content/test/plugins/plugin_clickToPlayAllow.html => browser/base/content/test/plugins/xbl/plugin_clickToPlayAllow.html
rename : browser/base/content/test/plugins/plugin_clickToPlayDeny.html => browser/base/content/test/plugins/xbl/plugin_clickToPlayDeny.html
rename : browser/base/content/test/plugins/plugin_crashCommentAndURL.html => browser/base/content/test/plugins/xbl/plugin_crashCommentAndURL.html
rename : browser/base/content/test/plugins/plugin_favorfallback.html => browser/base/content/test/plugins/xbl/plugin_favorfallback.html
rename : browser/base/content/test/plugins/plugin_hidden_to_visible.html => browser/base/content/test/plugins/xbl/plugin_hidden_to_visible.html
rename : browser/base/content/test/plugins/plugin_iframe.html => browser/base/content/test/plugins/xbl/plugin_iframe.html
rename : browser/base/content/test/plugins/plugin_outsideScrollArea.html => browser/base/content/test/plugins/xbl/plugin_outsideScrollArea.html
rename : browser/base/content/test/plugins/plugin_overlay_styles.html => browser/base/content/test/plugins/xbl/plugin_overlay_styles.html
rename : browser/base/content/test/plugins/plugin_shouldShowOverlay.html => browser/base/content/test/plugins/xbl/plugin_shouldShowOverlay.html
rename : browser/base/content/test/plugins/plugin_simple_blank.swf => browser/base/content/test/plugins/xbl/plugin_simple_blank.swf
rename : browser/base/content/test/plugins/plugin_small.html => browser/base/content/test/plugins/xbl/plugin_small.html
rename : browser/base/content/test/plugins/plugin_small_2.html => browser/base/content/test/plugins/xbl/plugin_small_2.html
rename : browser/base/content/test/plugins/plugin_syncRemoved.html => browser/base/content/test/plugins/xbl/plugin_syncRemoved.html
rename : browser/base/content/test/plugins/plugin_test.html => browser/base/content/test/plugins/xbl/plugin_test.html
rename : browser/base/content/test/plugins/plugin_test2.html => browser/base/content/test/plugins/xbl/plugin_test2.html
rename : browser/base/content/test/plugins/plugin_test3.html => browser/base/content/test/plugins/xbl/plugin_test3.html
rename : browser/base/content/test/plugins/plugin_two_types.html => browser/base/content/test/plugins/xbl/plugin_two_types.html
rename : browser/base/content/test/plugins/plugin_unknown.html => browser/base/content/test/plugins/xbl/plugin_unknown.html
rename : browser/base/content/test/plugins/plugin_zoom.html => browser/base/content/test/plugins/xbl/plugin_zoom.html
rename : toolkit/pluginproblem/content/pluginProblem.xml => toolkit/content/widgets/pluginProblem.js
extra : moz-landing-system : lando
This commit is contained in:
Timothy Guan-tin Chien 2018-11-22 05:49:54 +00:00
Родитель b4eeedcbf1
Коммит 1fc139dbad
99 изменённых файлов: 4899 добавлений и 120 удалений

Просмотреть файл

@ -695,13 +695,15 @@ class ContextMenuChild extends ActorChild {
let node = aEvent.composedTarget;
// Set the node to containing <video>/<audio> if the node
// is in the videocontrols UA Widget.
// Set the node to containing <video>/<audio>/<embed>/<object> if the node
// is in the videocontrols/pluginProblem UA Widget.
if (this.content.ShadowRoot) {
let n = node;
while (n) {
if (n instanceof this.content.ShadowRoot) {
if (n.host instanceof this.content.HTMLMediaElement) {
if (n.host instanceof this.content.HTMLMediaElement ||
n.host instanceof this.content.HTMLEmbedElement ||
n.host instanceof this.content.HTMLObjectElement) {
node = n.host;
break;
}

Просмотреть файл

@ -121,8 +121,12 @@ class PluginChild extends ActorChild {
}
getPluginUI(plugin, anonid) {
if (plugin.openOrClosedShadowRoot &&
plugin.openOrClosedShadowRoot.isUAWidget()) {
return plugin.openOrClosedShadowRoot.getElementById(anonid);
}
return plugin.ownerDocument.
getAnonymousElementByAttribute(plugin, "anonid", anonid);
getAnonymousElementByAttribute(plugin, "anonid", anonid);
}
_getPluginInfo(pluginElement) {
@ -632,7 +636,8 @@ class PluginChild extends ActorChild {
let overlay = this.getPluginUI(plugin, "main");
// Have to check that the target is not the link to update the plugin
if (!(ChromeUtils.getClassName(event.originalTarget) === "HTMLAnchorElement") &&
(event.originalTarget.getAttribute("anonid") != "closeIcon") &&
event.originalTarget.getAttribute("anonid") != "closeIcon" &&
event.originalTarget.id != "closeIcon" &&
!overlay.hasAttribute("dismissed") &&
event.button == 0 &&
event.isTrusted) {

Просмотреть файл

@ -1,4 +1,5 @@
[DEFAULT]
prefs = dom.ua_widget.enabled=true
support-files =
blocklist_proxy.js
blockNoPlugins.xml

Просмотреть файл

@ -96,10 +96,8 @@ add_task(async function() {
} catch (e) {
}
let doc = plugin.ownerDocument;
let getUI = (anonid) => {
return doc.getAnonymousElementByAttribute(plugin, "anonid", anonid);
let getUI = (id) => {
return plugin.openOrClosedShadowRoot.getElementById(id);
};
// Now wait until the plugin crash report UI shows itself, which is

Просмотреть файл

@ -33,8 +33,8 @@ add_task(async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let closeIcon = doc.getAnonymousElementByAttribute(plugin, "anonid", "closeIcon");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
let closeIcon = plugin.openOrClosedShadowRoot.getElementById("closeIcon");
let bounds = closeIcon.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
@ -59,8 +59,8 @@ add_task(async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let closeIcon = doc.getAnonymousElementByAttribute(plugin, "anonid", "closeIcon");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
let closeIcon = plugin.openOrClosedShadowRoot.getElementById("closeIcon");
let closeIconBounds = closeIcon.getBoundingClientRect();
let overlayBounds = overlay.getBoundingClientRect();
let overlayLeft = (overlayBounds.left + overlayBounds.right) / 2;

Просмотреть файл

@ -29,11 +29,11 @@ add_task(async function() {
let frame = content.document.getElementById("frame");
let doc = frame.contentDocument;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(plugin && overlay.classList.contains("visible"),
"Test 1, Plugin overlay should exist, not be hidden");
let closeIcon = doc.getAnonymousElementByAttribute(plugin, "anonid", "closeIcon");
let closeIcon = plugin.openOrClosedShadowRoot.getElementById("closeIcon");
let bounds = closeIcon.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;

Просмотреть файл

@ -55,8 +55,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, {}, async function() {
let plugin = content.document.getElementById("test");
let doc = content.document;
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(overlay && overlay.classList.contains("visible") &&
overlay.getAttribute("sizing") != "blank",
"Test 2, overlay should be visible.");
@ -85,8 +84,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let plugin = content.document.getElementById("test");
let doc = content.document;
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(overlay && overlay.classList.contains("visible") &&
overlay.getAttribute("sizing") != "blank",
"Test 3, overlay should be visible.");
@ -114,8 +112,7 @@ add_task(async function() {
await promisePopupNotification("click-to-play-plugins");
await ContentTask.spawn(gTestBrowser, null, async function() {
let plugin = content.document.getElementById("test");
let doc = content.document;
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank",
"Test 4, overlay should be blank.");
});

Просмотреть файл

@ -75,7 +75,7 @@ add_task(async function() {
for (let testcaseId of Object.keys(testcases)) {
let plugin = doc.querySelector(`#${testcaseId} > object`);
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(overlay, `overlay exists in ${testcaseId}`);
let expectations = testcases[testcaseId];

Просмотреть файл

@ -45,7 +45,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank",
"Test 2, overlay should be blank.");
});
@ -63,7 +63,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank",
"Test 3, overlay should be blank.");
});
@ -83,7 +83,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(overlay && overlay.getAttribute("sizing") != "blank",
"Test 4, overlay should be visible.");
});
@ -103,7 +103,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank",
"Test 5, overlay should be blank.");
});
@ -123,7 +123,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(overlay && overlay.getAttribute("sizing") != "blank",
"Test 6, overlay should be visible.");
});

Просмотреть файл

@ -51,7 +51,7 @@ add_task(async function() {
let plugin = testcase.querySelector("object");
Assert.ok(plugin, `plugin exists in ${testcase.id}`);
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(overlay, `overlay exists in ${testcase.id}`);
let expectedVisibility = (testcase.getAttribute("shouldshow") == "true");

Просмотреть файл

@ -52,7 +52,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, { count }, async function(args) {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(overlay && overlay.classList.contains("visible"),
"Overlay should be visible for zoom change count " + args.count);
});

Просмотреть файл

@ -55,11 +55,11 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(overlay && overlay.classList.contains("visible"),
"Test 18a, Plugin overlay should exist, not be hidden");
let updateLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "checkForUpdatesLink");
let updateLink = plugin.openOrClosedShadowRoot.getElementById("checkForUpdatesLink");
Assert.ok(updateLink.style.visibility != "hidden",
"Test 18a, Plugin should have an update link");
});
@ -69,7 +69,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, {}, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let updateLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "checkForUpdatesLink");
let updateLink = plugin.openOrClosedShadowRoot.getElementById("checkForUpdatesLink");
let bounds = updateLink.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
@ -94,7 +94,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(overlay && overlay.classList.contains("visible"),
"Test 18b, Plugin overlay should exist, not be hidden");
});
@ -122,11 +122,11 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(overlay && overlay.classList.contains("visible"),
"Test 18c, Plugin overlay should exist, not be hidden");
let updateLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "checkForUpdatesLink");
let updateLink = plugin.openOrClosedShadowRoot.getElementById("checkForUpdatesLink");
Assert.ok(updateLink && updateLink.style.display != "block",
"Test 18c, Plugin should not have an update link");
});

Просмотреть файл

@ -63,10 +63,10 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, config, async function(aConfig) {
let doc = content.document;
let plugin = doc.getElementById("plugin");
let pleaseSubmit = doc.getAnonymousElementByAttribute(plugin, "anonid", "pleaseSubmit");
let submitButton = doc.getAnonymousElementByAttribute(plugin, "anonid", "submitButton");
let pleaseSubmit = plugin.openOrClosedShadowRoot.getElementById("pleaseSubmit");
let submitButton = plugin.openOrClosedShadowRoot.getElementById("submitButton");
// Test that we don't send the URL when urlOptIn is false.
doc.getAnonymousElementByAttribute(plugin, "anonid", "submitURLOptIn").checked = aConfig.urlOptIn;
plugin.openOrClosedShadowRoot.getElementById("submitURLOptIn").checked = aConfig.urlOptIn;
submitButton.click();
Assert.equal(content.getComputedStyle(pleaseSubmit).display == "block",
aConfig.shouldSubmissionUIBeVisible, "The crash UI should be visible");
@ -100,11 +100,11 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, config, async function(aConfig) {
let doc = content.document;
let plugin = doc.getElementById("plugin");
let pleaseSubmit = doc.getAnonymousElementByAttribute(plugin, "anonid", "pleaseSubmit");
let submitButton = doc.getAnonymousElementByAttribute(plugin, "anonid", "submitButton");
let pleaseSubmit = plugin.openOrClosedShadowRoot.getElementById("pleaseSubmit");
let submitButton = plugin.openOrClosedShadowRoot.getElementById("submitButton");
// Test that we send the URL when urlOptIn is true.
doc.getAnonymousElementByAttribute(plugin, "anonid", "submitURLOptIn").checked = aConfig.urlOptIn;
doc.getAnonymousElementByAttribute(plugin, "anonid", "submitComment").value = aConfig.comment;
plugin.openOrClosedShadowRoot.getElementById("submitURLOptIn").checked = aConfig.urlOptIn;
plugin.openOrClosedShadowRoot.getElementById("submitComment").value = aConfig.comment;
submitButton.click();
Assert.equal(content.getComputedStyle(pleaseSubmit).display == "block",
aConfig.shouldSubmissionUIBeVisible, "The crash UI should be visible");
@ -171,7 +171,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, config, async function(aConfig) {
let doc = content.document;
let plugin = doc.getElementById("plugin");
let pleaseSubmit = doc.getAnonymousElementByAttribute(plugin, "anonid", "pleaseSubmit");
let pleaseSubmit = plugin.openOrClosedShadowRoot.getElementById("pleaseSubmit");
Assert.equal(!!pleaseSubmit && content.getComputedStyle(pleaseSubmit).display == "block",
aConfig.shouldSubmissionUIBeVisible, "Plugin crash UI should not be visible");
});

Просмотреть файл

@ -59,9 +59,8 @@ function preparePlugin(browser, pluginFallbackState) {
// state.
let statusDiv;
await ContentTaskUtils.waitForCondition(() => {
statusDiv = plugin.ownerDocument
.getAnonymousElementByAttribute(plugin, "anonid",
"submitStatus");
statusDiv = plugin.openOrClosedShadowRoot.getElementById("submitStatus");
return statusDiv && statusDiv.getAttribute("status") == "please";
}, "Timed out waiting for plugin to be in crash report state");
@ -158,9 +157,7 @@ add_task(async function testChromeHearsPluginCrashFirst() {
// the PluginCrashed event.
let plugin = content.document.getElementById("plugin");
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
let statusDiv = plugin.ownerDocument
.getAnonymousElementByAttribute(plugin, "anonid",
"submitStatus");
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.");
@ -220,9 +217,7 @@ add_task(async function testContentHearsCrashFirst() {
// we're not showing the plugin crash report UI.
let plugin = content.document.getElementById("plugin");
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
let statusDiv = plugin.ownerDocument
.getAnonymousElementByAttribute(plugin, "anonid",
"submitStatus");
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.");
@ -255,9 +250,7 @@ add_task(async function testContentHearsCrashFirst() {
// crash report UI now.
let plugin = content.document.getElementById("plugin");
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
let statusDiv = plugin.ownerDocument
.getAnonymousElementByAttribute(plugin, "anonid",
"submitStatus");
let statusDiv = plugin.openOrClosedShadowRoot.getElementById("submitStatus");
Assert.equal(statusDiv.getAttribute("status"), "please",
"Should have been showing crash report UI");

Просмотреть файл

@ -90,7 +90,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let bounds = doc.getAnonymousElementByAttribute(plugin, "anonid", "main").getBoundingClientRect();
let bounds = plugin.openOrClosedShadowRoot.getElementById("main").getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
@ -195,7 +195,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let mainBox = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let mainBox = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(!!mainBox, "Test 15, Plugin overlay should exist");
});
});
@ -230,7 +230,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let icon = doc.getAnonymousElementByAttribute(plugin, "class", "icon");
let icon = plugin.openOrClosedShadowRoot.getElementById("icon");
let bounds = icon.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
@ -259,7 +259,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let text = doc.getAnonymousElementByAttribute(plugin, "class", "msg msgClickToPlay");
let text = plugin.openOrClosedShadowRoot.getElementById("clickToPlay");
let bounds = text.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
@ -319,14 +319,14 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
Assert.ok(!!overlay, "Test 20a, Plugin overlay should exist");
});
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let mainBox = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let mainBox = plugin.openOrClosedShadowRoot.getElementById("main");
let overlayRect = mainBox.getBoundingClientRect();
Assert.ok(overlayRect.width == 0 && overlayRect.height == 0,
"Test 20a, plugin should have an overlay with 0px width and height");
@ -351,7 +351,7 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let mainBox = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let mainBox = plugin.openOrClosedShadowRoot.getElementById("main");
let overlayRect = mainBox.getBoundingClientRect();
Assert.ok(overlayRect.width == 200 && overlayRect.height == 200,
"Test 20c, plugin should have overlay dims of 200px");
@ -383,9 +383,8 @@ add_task(async function() {
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlayRect = doc.getAnonymousElementByAttribute(plugin, "anonid", "main").getBoundingClientRect();
Assert.ok(overlayRect.width == 0 && overlayRect.height == 0,
"Test 20c, plugin should have overlay dims of 0px");
Assert.ok(!plugin.openOrClosedShadowRoot,
"Test 20c, CTP UA Widget Shadow Root is removed");
});
clearAllPluginPermissions();

Просмотреть файл

@ -200,13 +200,12 @@ add_task(async function test3d() {
"Shown");
popupNotification.reshow();
await promiseShown;
let doc = gPrivateWindow.document;
for (let item of gPrivateWindow.PopupNotifications.panel.firstElementChild.children) {
let allowalways = doc.getAnonymousElementByAttribute(item, "anonid", "allowalways");
let allowalways = item.openOrClosedShadowRoot.getElementById("allowalways");
ok(allowalways, "Test 3d, should have list item for allow always");
let allownow = doc.getAnonymousElementByAttribute(item, "anonid", "allownow");
let allownow = item.openOrClosedShadowRoot.getElementById("allownow");
ok(allownow, "Test 3d, should have list item for allow now");
let block = doc.getAnonymousElementByAttribute(item, "anonid", "block");
let block = item.openOrClosedShadowRoot.getElementById("block");
ok(block, "Test 3d, should have list item for block");
if (item.action.pluginName === "Test") {

Просмотреть файл

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"plugin:mozilla/browser-test"
]
};

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310001">
<emItems>
</emItems>
<pluginItems>
</pluginItems>
</blocklist>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310000">
<emItems>
</emItems>
<pluginItems>
<pluginItem blockID="p9999">
<match name="filename" exp="libnptest\.so|nptest\.dll|Test\.plugin" />
<versionRange severity="2"></versionRange>
</pluginItem>
</pluginItems>
</blocklist>

Просмотреть файл

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310000">
<emItems>
</emItems>
<pluginItems>
<pluginItem blockID="p9999">
<match name="filename" exp="libnptest\.so|nptest\.dll|Test\.plugin" />
<versionRange severity="2"></versionRange>
<infoURL>http://test.url.com/</infoURL>
</pluginItem>
</pluginItems>
</blocklist>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310000">
<emItems>
</emItems>
<pluginItems>
<pluginItem blockID="p9999">
<match name="filename" exp="libnptest\.so|nptest\.dll|Test\.plugin" />
<versionRange severity="0" vulnerabilitystatus="2"></versionRange>
</pluginItem>
</pluginItems>
</blocklist>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310000">
<emItems>
</emItems>
<pluginItems>
<pluginItem blockID="p9999">
<match name="filename" exp="libnptest\.so|nptest\.dll|Test\.plugin" />
<versionRange severity="0" vulnerabilitystatus="1"></versionRange>
</pluginItem>
</pluginItems>
</blocklist>

Просмотреть файл

@ -0,0 +1,69 @@
var Cm = Components.manager;
const kBlocklistServiceUUID = "{66354bc9-7ed1-4692-ae1d-8da97d6b205e}";
const kBlocklistServiceContractID = "@mozilla.org/extensions/blocklist;1";
const kBlocklistServiceFactory = Cm.getClassObject(Cc[kBlocklistServiceContractID], Ci.nsIFactory);
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Timer.jsm");
SimpleTest.requestFlakyTimeout("Need to simulate blocklist calls actually taking non-0 time to return");
/*
* A lightweight blocklist proxy for the testing purposes.
*/
var BlocklistProxy = {
_uuid: null,
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver,
Ci.nsIBlocklistService,
Ci.nsITimerCallback]),
init() {
if (!this._uuid) {
this._uuid =
Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator)
.generateUUID();
Cm.nsIComponentRegistrar.registerFactory(this._uuid, "",
"@mozilla.org/extensions/blocklist;1",
this);
}
},
uninit() {
if (this._uuid) {
Cm.nsIComponentRegistrar.unregisterFactory(this._uuid, this);
Cm.nsIComponentRegistrar.registerFactory(Components.ID(kBlocklistServiceUUID),
"Blocklist Service",
"@mozilla.org/extensions/blocklist;1",
kBlocklistServiceFactory);
this._uuid = null;
}
},
notify(aTimer) {
},
observe(aSubject, aTopic, aData) {
},
async getAddonBlocklistState(aAddon, aAppVersion, aToolkitVersion) {
await new Promise(r => setTimeout(r, 150));
return 0; // STATE_NOT_BLOCKED
},
async getPluginBlocklistState(aPluginTag, aAppVersion, aToolkitVersion) {
await new Promise(r => setTimeout(r, 150));
return 0; // STATE_NOT_BLOCKED
},
async getPluginBlockURL(aPluginTag) {
await new Promise(r => setTimeout(r, 150));
return "";
},
};
BlocklistProxy.init();
addEventListener("unload", () => {
BlocklistProxy.uninit();
});

Просмотреть файл

@ -0,0 +1,98 @@
[DEFAULT]
prefs = dom.ua_widget.enabled=false
support-files =
blocklist_proxy.js
blockNoPlugins.xml
blockPluginHard.xml
blockPluginInfoURL.xml
blockPluginVulnerableNoUpdate.xml
blockPluginVulnerableUpdatable.xml
browser_clearplugindata.html
browser_clearplugindata_noage.html
empty_file.html
../head.js
plugin_add_dynamically.html
plugin_alternate_content.html
plugin_big.html
plugin_both.html
plugin_both2.html
plugin_bug744745.html
plugin_bug749455.html
plugin_bug787619.html
plugin_bug797677.html
plugin_bug820497.html
plugin_clickToPlayAllow.html
plugin_clickToPlayDeny.html
plugin_favorfallback.html
plugin_hidden_to_visible.html
plugin_iframe.html
plugin_outsideScrollArea.html
plugin_overlay_styles.html
plugin_simple_blank.swf
plugin_shouldShowOverlay.html
plugin_small.html
plugin_small_2.html
plugin_syncRemoved.html
plugin_test.html
plugin_test2.html
plugin_test3.html
plugin_two_types.html
plugin_unknown.html
plugin_crashCommentAndURL.html
plugin_zoom.html
[browser_bug743421.js]
tags = blocklist
[browser_bug744745.js]
[browser_bug787619.js]
[browser_bug797677.js]
[browser_bug812562.js]
tags = blocklist
[browser_bug818118.js]
[browser_bug820497.js]
[browser_clearplugindata.js]
tags = blocklist
[browser_CTP_context_menu.js]
skip-if = toolkit == "gtk3" # fails intermittently on Linux (bug 909342)
tags = blocklist
[browser_CTP_crashreporting.js]
skip-if = !crashreporter || verify
tags = blocklist
[browser_CTP_drag_drop.js]
tags = blocklist
[browser_CTP_favorfallback.js]
[browser_CTP_hide_overlay.js]
tags = blocklist
[browser_CTP_iframe.js]
tags = blocklist
[browser_CTP_nonplugins.js]
skip-if = verify
tags = blocklist
[browser_CTP_outsideScrollArea.js]
tags = blocklist
[browser_CTP_overlay_styles.js]
[browser_CTP_resize.js]
tags = blocklist
[browser_CTP_shouldShowOverlay.js]
[browser_CTP_zoom.js]
tags = blocklist
[browser_blocking.js]
tags = blocklist
[browser_iterate_hidden_plugins.js]
[browser_pluginnotification.js]
tags = blocklist
[browser_plugin_reloading.js]
tags = blocklist
[browser_blocklist_content.js]
skip-if = !e10s
tags = blocklist
[browser_enable_DRM_prompt.js]
[browser_private_browsing_eme_persistent_state.js]
[browser_globalplugin_crashinfobar.js]
skip-if = !crashreporter
[browser_pluginCrashCommentAndURL.js]
skip-if = !crashreporter
[browser_pluginCrashReportNonDeterminism.js]
skip-if = !crashreporter
[browser_private_clicktoplay.js]
[browser_subframe_access_hidden_plugins.js]

Просмотреть файл

@ -0,0 +1,70 @@
/* import-globals-from ../head.js */
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
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.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
gBrowser.removeCurrentTab();
window.focus();
});
});
// Test that the activate action in content menus for CTP plugins works
add_task(async function() {
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
let bindingPromise = BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "PluginBindingAttached", true, null, true);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
await bindingPromise;
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser);
ok(popupNotification, "Test 1, Should have a click-to-play notification");
// check plugin state
let pluginInfo = await promiseForPluginInfo("test", gBrowser.selectedBrowser);
ok(!pluginInfo.activated, "plugin should not be activated");
// Display a context menu on the test plugin so we can test
// activation menu options.
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let plugin = content.document.getElementById("test");
let bounds = plugin.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
utils.sendMouseEvent("contextmenu", left, top, 2, 1, 0);
});
popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser);
ok(popupNotification, "Should have a click-to-play notification");
ok(popupNotification.dismissed, "notification should be dismissed");
// fixes a occasional test timeout on win7 opt
await promiseForCondition(() => document.getElementById("context-ctp-play"));
let actMenuItem = document.getElementById("context-ctp-play");
ok(actMenuItem, "Should have a context menu entry for activating the plugin");
// Activate the plugin via the context menu
EventUtils.synthesizeMouseAtCenter(actMenuItem, {});
await promiseForCondition(() => !PopupNotifications.panel.dismissed && PopupNotifications.panel.firstElementChild);
// Activate the plugin
PopupNotifications.panel.firstElementChild.button.click();
// check plugin state
pluginInfo = await promiseForPluginInfo("test", gBrowser.selectedBrowser);
ok(pluginInfo.activated, "plugin should not be activated");
});

Просмотреть файл

@ -0,0 +1,234 @@
/* import-globals-from ../head.js */
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
const SERVER_URL = "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs";
const PLUGIN_PAGE = gTestRoot + "plugin_big.html";
const PLUGIN_SMALL_PAGE = gTestRoot + "plugin_small.html";
/**
* Takes an nsIPropertyBag and converts it into a JavaScript Object. It
* will also convert any nsIPropertyBag's within the nsIPropertyBag
* recursively.
*
* @param aBag
* The nsIPropertyBag to convert.
* @return Object
* Keyed on the names of the nsIProperty's within the nsIPropertyBag,
* and mapping to their values.
*/
function convertPropertyBag(aBag) {
let result = {};
for (let { name, value } of aBag.enumerator) {
if (value instanceof Ci.nsIPropertyBag) {
value = convertPropertyBag(value);
}
result[name] = value;
}
return result;
}
add_task(async function setup() {
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
// The test harness sets MOZ_CRASHREPORTER_NO_REPORT, which disables plugin
// crash reports. This test needs them enabled. The test also needs a mock
// report server, and fortunately one is already set up by toolkit/
// crashreporter/test/Makefile.in. Assign its URL to MOZ_CRASHREPORTER_URL,
// which CrashSubmit.jsm uses as a server override.
let env = Cc["@mozilla.org/process/environment;1"].
getService(Ci.nsIEnvironment);
let noReport = env.get("MOZ_CRASHREPORTER_NO_REPORT");
let serverURL = env.get("MOZ_CRASHREPORTER_URL");
env.set("MOZ_CRASHREPORTER_NO_REPORT", "");
env.set("MOZ_CRASHREPORTER_URL", SERVER_URL);
Services.prefs.setBoolPref("plugins.click_to_play", true);
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
registerCleanupFunction(function cleanUp() {
clearAllPluginPermissions();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
env.set("MOZ_CRASHREPORTER_NO_REPORT", noReport);
env.set("MOZ_CRASHREPORTER_URL", serverURL);
Services.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
window.focus();
});
});
/**
* Test that plugin crash submissions still work properly after
* click-to-play activation.
*/
add_task(async function() {
await BrowserTestUtils.withNewTab({
gBrowser,
url: PLUGIN_PAGE,
}, async function(browser) {
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(browser);
let pluginInfo = await promiseForPluginInfo("test", browser);
ok(!pluginInfo.activated, "Plugin should not be activated");
// Simulate clicking the "Allow Always" button.
let notification = PopupNotifications.getNotification("click-to-play-plugins", browser);
await promiseForNotificationShown(notification, browser);
PopupNotifications.panel.firstElementChild.button.click();
// Prepare a crash report topic observer that only returns when
// the crash report has been successfully sent.
let crashReportChecker = (subject, data) => {
return (data == "success");
};
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) {
}
let doc = plugin.ownerDocument;
let getUI = (anonid) => {
return doc.getAnonymousElementByAttribute(plugin, "anonid", anonid);
};
// Now wait until the plugin crash report UI shows itself, which is
// asynchronous.
let statusDiv;
await ContentTaskUtils.waitForCondition(() => {
statusDiv = getUI("submitStatus");
return statusDiv.getAttribute("status") == "please";
}, "Waited too long for plugin to show crash report UI");
// Make sure the UI matches our expectations...
let style = content.getComputedStyle(getUI("pleaseSubmit"));
if (style.display != "block") {
throw new Error(`Submission UI visibility is not correct. ` +
`Expected block style, got ${style.display}.`);
}
// Fill the crash report in with some test values that we'll test for in
// the parent.
getUI("submitComment").value = "a test comment";
let optIn = getUI("submitURLOptIn");
if (!optIn.checked) {
throw new Error("URL opt-in should default to true.");
}
// Submit the report.
optIn.click();
getUI("submitButton").click();
// And wait for the parent to say that the crash report was submitted
// successfully. This can take time on debug builds.
await ContentTaskUtils.waitForCondition(() => {
return statusDiv.getAttribute("status") == "success";
}, "Timed out waiting for plugin binding to be in success state",
100, 200);
});
let [subject ] = await crashReportPromise;
ok(subject instanceof Ci.nsIPropertyBag,
"The crash report subject should be an nsIPropertyBag.");
let crashData = convertPropertyBag(subject);
ok(crashData.serverCrashID, "Should have a serverCrashID set.");
// Remove the submitted report file after ensuring it exists.
let file = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsIFile);
file.initWithPath(Services.crashmanager._submittedDumpsDir);
file.append(crashData.serverCrashID + ".txt");
ok(file.exists(), "Submitted report file should exist");
file.remove(false);
ok(crashData.extra, "Extra data should exist");
is(crashData.extra.PluginUserComment, "a test comment",
"Comment in extra data should match comment in textbox");
is(crashData.extra.PluginContentURL, undefined,
"URL should be absent from extra data when opt-in not checked");
});
});
/**
* Test that plugin crash submissions still work properly after
* click-to-play with the notification bar.
*/
add_task(async function() {
await BrowserTestUtils.withNewTab({
gBrowser,
url: PLUGIN_SMALL_PAGE,
}, async function(browser) {
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(browser);
let pluginInfo = await promiseForPluginInfo("test", browser);
ok(pluginInfo.activated, "Plugin should be activated from previous test");
// Prepare a crash report topic observer that only returns when
// the crash report has been successfully sent.
let crashReportChecker = (subject, data) => {
return (data == "success");
};
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) {}
});
// Wait for the notification bar to be displayed.
let notification = await waitForNotificationBar("plugin-crashed", browser);
// Then click the button to submit the crash report.
let buttons = notification.querySelectorAll(".notification-button");
is(buttons.length, 2, "Should have two buttons.");
// The "Submit Crash Report" button should be the second one.
let submitButton = buttons[1];
submitButton.click();
let [subject ] = await crashReportPromise;
ok(subject instanceof Ci.nsIPropertyBag,
"The crash report subject should be an nsIPropertyBag.");
let crashData = convertPropertyBag(subject);
ok(crashData.serverCrashID, "Should have a serverCrashID set.");
// Remove the submitted report file after ensuring it exists.
let file = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsIFile);
file.initWithPath(Services.crashmanager._submittedDumpsDir);
file.append(crashData.serverCrashID + ".txt");
ok(file.exists(), "Submitted report file should exist");
file.remove(false);
is(crashData.extra.PluginContentURL, undefined,
"URL should be absent from extra data when opt-in not checked");
});
});

Просмотреть файл

@ -0,0 +1,97 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gNewWindow = null;
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.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
gNewWindow.close();
gNewWindow = null;
window.focus();
});
});
add_task(async function() {
Services.prefs.setBoolPref("plugins.click_to_play", true);
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
await promisePopupNotification("click-to-play-plugins");
});
add_task(async function() {
gNewWindow = gBrowser.replaceTabWithWindow(gBrowser.selectedTab);
// XXX technically can't load fire before we get this call???
await BrowserTestUtils.waitForEvent(gNewWindow, "load", true);
await promisePopupNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser);
ok(PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser), "Should have a click-to-play notification in the tab in the new window");
ok(!PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should not have a click-to-play notification in the old window now");
});
add_task(async function() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, gNewWindow.gBrowser.selectedTab);
await promisePopupNotification("click-to-play-plugins", gBrowser.selectedBrowser);
ok(PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should have a click-to-play notification in the initial tab again");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
});
add_task(async function() {
await promisePopupNotification("click-to-play-plugins");
gNewWindow = gBrowser.replaceTabWithWindow(gBrowser.selectedTab);
await promiseWaitForFocus(gNewWindow);
await promisePopupNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser);
});
add_task(async function() {
ok(PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser), "Should have a click-to-play notification in the tab in the new window");
ok(!PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should not have a click-to-play notification in the old window now");
let pluginInfo = await promiseForPluginInfo("test", gNewWindow.gBrowser.selectedBrowser);
ok(!pluginInfo.activated, "plugin should not be activated");
await ContentTask.spawn(gNewWindow.gBrowser.selectedBrowser, {}, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let bounds = plugin.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
});
let condition = () => !PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser).dismissed && gNewWindow.PopupNotifications.panel.firstElementChild;
await promiseForCondition(condition);
});
add_task(async function() {
// Click the activate button on doorhanger to make sure it works
gNewWindow.PopupNotifications.panel.firstElementChild.button.click();
let pluginInfo = await promiseForPluginInfo("test", gNewWindow.gBrowser.selectedBrowser);
ok(pluginInfo.activated, "plugin should be activated");
});

Просмотреть файл

@ -0,0 +1,86 @@
/* import-globals-from ../head.js */
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
add_task(async function() {
registerCleanupFunction(function() {
clearAllPluginPermissions();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Shockwave Flash");
Services.prefs.clearUserPref("plugins.favorfallback.mode");
Services.prefs.clearUserPref("plugins.favorfallback.rules");
});
});
add_task(async function() {
Services.prefs.setCharPref("plugins.favorfallback.mode", "follow-ctp");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Shockwave Flash");
});
/* The expected behavior of each testcase is documented with its markup
* in plugin_favorfallback.html.
*
* - "name" is the name of the testcase in the test file.
* - "rule" is how the plugins.favorfallback.rules must be configured
* for this testcase.
*/
const testcases = [
{
name: "video",
rule: "video",
},
{
name: "nosrc",
rule: "nosrc",
},
{
name: "embed",
rule: "embed,true",
},
{
name: "adobelink",
rule: "adobelink,true",
},
{
name: "installinstructions",
rule: "installinstructions,true",
},
];
add_task(async function() {
for (let testcase of Object.values(testcases)) {
info(`Running testcase ${testcase.name}`);
Services.prefs.setCharPref("plugins.favorfallback.rules", testcase.rule);
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
`${gTestRoot}plugin_favorfallback.html?testcase=${testcase.name}`
);
await ContentTask.spawn(tab.linkedBrowser, testcase.name, async function testPlugins(name) {
let testcaseDiv = content.document.getElementById(`testcase_${name}`);
let ctpPlugins = testcaseDiv.querySelectorAll(".expected_ctp");
for (let ctpPlugin of ctpPlugins) {
ok(ctpPlugin instanceof Ci.nsIObjectLoadingContent, "This is a plugin object");
is(ctpPlugin.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "Plugin is CTP");
}
let fallbackPlugins = testcaseDiv.querySelectorAll(".expected_fallback");
for (let fallbackPlugin of fallbackPlugins) {
ok(fallbackPlugin instanceof Ci.nsIObjectLoadingContent, "This is a plugin object");
is(fallbackPlugin.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_ALTERNATE, "Plugin fallback content was used");
}
});
BrowserTestUtils.removeTab(tab);
}
});

Просмотреть файл

@ -0,0 +1,88 @@
/* import-globals-from ../head.js */
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
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.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
gBrowser.removeCurrentTab();
window.focus();
});
});
add_task(async function() {
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
// Tests that the overlay can be hidden for plugins using the close icon.
await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let closeIcon = doc.getAnonymousElementByAttribute(plugin, "anonid", "closeIcon");
let bounds = closeIcon.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
Assert.ok(!overlay.classList.contains("visible"), "overlay should be hidden.");
});
});
// Test that the overlay cannot be interacted with after the user closes the overlay
add_task(async function() {
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let closeIcon = doc.getAnonymousElementByAttribute(plugin, "anonid", "closeIcon");
let closeIconBounds = closeIcon.getBoundingClientRect();
let overlayBounds = overlay.getBoundingClientRect();
let overlayLeft = (overlayBounds.left + overlayBounds.right) / 2;
let overlayTop = (overlayBounds.left + overlayBounds.right) / 2 ;
let closeIconLeft = (closeIconBounds.left + closeIconBounds.right) / 2;
let closeIconTop = (closeIconBounds.top + closeIconBounds.bottom) / 2;
let utils = content.windowUtils;
// Simulate clicking on the close icon.
utils.sendMouseEvent("mousedown", closeIconLeft, closeIconTop, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", closeIconLeft, closeIconTop, 0, 1, 0, false, 0, 0);
// Simulate clicking on the overlay.
utils.sendMouseEvent("mousedown", overlayLeft, overlayTop, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", overlayLeft, overlayTop, 0, 1, 0, false, 0, 0);
Assert.ok(overlay.hasAttribute("dismissed") && !overlay.classList.contains("visible"),
"Overlay should be hidden");
});
let notification = PopupNotifications.getNotification("click-to-play-plugins");
ok(notification.dismissed, "No notification should be shown");
});

Просмотреть файл

@ -0,0 +1,49 @@
/* import-globals-from ../head.js */
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
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.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
gBrowser.removeCurrentTab();
window.focus();
});
});
add_task(async function() {
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_iframe.html");
// Tests that the overlays are visible and actionable if the plugin is in an iframe.
await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
let frame = content.document.getElementById("frame");
let doc = frame.contentDocument;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(plugin && overlay.classList.contains("visible"),
"Test 1, Plugin overlay should exist, not be hidden");
let closeIcon = doc.getAnonymousElementByAttribute(plugin, "anonid", "closeIcon");
let bounds = closeIcon.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = doc.defaultView.windowUtils;
utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
Assert.ok(!overlay.classList.contains("visible"),
"Test 1, Plugin overlay should exist, be hidden");
});
});

Просмотреть файл

@ -0,0 +1,60 @@
/* import-globals-from ../head.js */
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
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.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
gBrowser.removeCurrentTab();
window.focus();
});
});
add_task(async function() {
Services.prefs.setBoolPref("plugins.click_to_play", true);
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_DISABLED, "Test Plug-in");
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_two_types.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
// Test that the click-to-play notification is not shown for non-plugin object elements
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser);
ok(popupNotification, "Test 1, Should have a click-to-play notification");
let pluginRemovedPromise = BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "PluginRemoved", true, null, true);
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let plugin = content.document.getElementById("secondtestA");
plugin.remove();
plugin = content.document.getElementById("secondtestB");
plugin.remove();
let image = content.document.createElement("object");
image.type = "image/png";
image.data = "moz.png";
content.document.body.appendChild(image);
});
await pluginRemovedPromise;
popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser);
ok(popupNotification, "Test 2, Should have a click-to-play notification");
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let plugin = content.document.getElementById("test");
plugin.remove();
});
popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser);
ok(popupNotification, "Test 3, Should still have a click-to-play notification");
});

Просмотреть файл

@ -0,0 +1,124 @@
/* import-globals-from ../head.js */
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
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.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
Services.prefs.setBoolPref("plugins.click_to_play", true);
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
let newTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!popupNotification, "Test 1, Should not have a click-to-play notification");
});
// Test that the click-to-play overlay is not hidden for elements
// partially or fully outside the viewport.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_outsideScrollArea.html");
await ContentTask.spawn(gTestBrowser, {}, async function() {
let doc = content.document;
let p = doc.createElement("embed");
p.setAttribute("id", "test");
p.setAttribute("type", "application/x-test");
p.style.left = "0";
p.style.bottom = "200px";
doc.getElementById("container").appendChild(p);
});
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await promisePopupNotification("click-to-play-plugins");
await ContentTask.spawn(gTestBrowser, {}, async function() {
let plugin = content.document.getElementById("test");
let doc = content.document;
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(overlay && overlay.classList.contains("visible") &&
overlay.getAttribute("sizing") != "blank",
"Test 2, overlay should be visible.");
});
});
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_outsideScrollArea.html");
await ContentTask.spawn(gTestBrowser, {}, async function() {
let doc = content.document;
let p = doc.createElement("embed");
p.setAttribute("id", "test");
p.setAttribute("type", "application/x-test");
p.style.left = "0";
p.style.bottom = "-410px";
doc.getElementById("container").appendChild(p);
});
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await promisePopupNotification("click-to-play-plugins");
await ContentTask.spawn(gTestBrowser, null, async function() {
let plugin = content.document.getElementById("test");
let doc = content.document;
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(overlay && overlay.classList.contains("visible") &&
overlay.getAttribute("sizing") != "blank",
"Test 3, overlay should be visible.");
});
});
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_outsideScrollArea.html");
await ContentTask.spawn(gTestBrowser, {}, async function() {
let doc = content.document;
let p = doc.createElement("embed");
p.setAttribute("id", "test");
p.setAttribute("type", "application/x-test");
p.style.left = "-600px";
p.style.bottom = "0";
doc.getElementById("container").appendChild(p);
});
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await promisePopupNotification("click-to-play-plugins");
await ContentTask.spawn(gTestBrowser, null, async function() {
let plugin = content.document.getElementById("test");
let doc = content.document;
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank",
"Test 4, overlay should be blank.");
});
});

Просмотреть файл

@ -0,0 +1,95 @@
/* import-globals-from ../head.js */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* This test ensures that the click-to-play "Activate Plugin" overlay
* is shown in the right style (which is dependent on its size).
*/
const rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
const gTestcases = {
// 10x10
testcase1: {
sizing: "blank",
notext: null,
},
// 40x40
testcase2: {
sizing: "tiny",
notext: "notext",
},
// 100x70
testcase3: {
sizing: "reduced",
notext: "notext",
},
// 200x200
testcase4: {
sizing: null,
notext: "notext",
},
// 300x300
testcase5: {
sizing: null,
notext: null,
},
};
add_task(async function() {
registerCleanupFunction(function() {
clearAllPluginPermissions();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
gBrowser.removeCurrentTab();
gTestBrowser = null;
});
});
add_task(async function() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!popupNotification, "Sanity check, should not have a click-to-play notification");
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_overlay_styles.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await ContentTask.spawn(gTestBrowser, gTestcases, async function(testcases) {
let doc = content.document;
for (let testcaseId of Object.keys(testcases)) {
let plugin = doc.querySelector(`#${testcaseId} > object`);
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(overlay, `overlay exists in ${testcaseId}`);
let expectations = testcases[testcaseId];
Assert.ok(overlay.classList.contains("visible"),
`The expected visibility is correct in ${testcaseId}`);
Assert.ok(overlay.getAttribute("sizing") == expectations.sizing,
`The expected sizing is correct in ${testcaseId}`);
Assert.ok(overlay.getAttribute("notext") == expectations.notext,
`The expected notext is correct in ${testcaseId}`);
}
});
});

Просмотреть файл

@ -0,0 +1,132 @@
/* import-globals-from ../head.js */
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
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.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
Services.prefs.setBoolPref("plugins.click_to_play", true);
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
let newTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!popupNotification, "Test 1, Should not have a click-to-play notification");
await promiseTabLoadEvent(newTab, gTestRoot + "plugin_small.html"); // 10x10 plugin
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await promisePopupNotification("click-to-play-plugins");
});
// Test that the overlay is hidden for "small" plugin elements and is shown
// once they are resized to a size that can hold the overlay
add_task(async function() {
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(popupNotification, "Test 2, Should have a click-to-play notification");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank",
"Test 2, overlay should be blank.");
});
});
add_task(async function() {
await ContentTask.spawn(gTestBrowser, {}, async function() {
let plugin = content.document.getElementById("test");
plugin.style.width = "300px";
});
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank",
"Test 3, overlay should be blank.");
});
});
add_task(async function() {
await ContentTask.spawn(gTestBrowser, {}, async function() {
let plugin = content.document.getElementById("test");
plugin.style.height = "300px";
});
await ContentTask.spawn(gTestBrowser, {}, async function() {
content.document.getElementById("test").clientTop;
});
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(overlay && overlay.getAttribute("sizing") != "blank",
"Test 4, overlay should be visible.");
});
});
add_task(async function() {
await ContentTask.spawn(gTestBrowser, {}, async function() {
let plugin = content.document.getElementById("test");
plugin.style.width = "10px";
plugin.style.height = "10px";
});
await ContentTask.spawn(gTestBrowser, {}, async function() {
content.document.getElementById("test").clientTop;
});
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank",
"Test 5, overlay should be blank.");
});
});
add_task(async function() {
await ContentTask.spawn(gTestBrowser, {}, async function() {
let plugin = content.document.getElementById("test");
plugin.style.height = "300px";
plugin.style.width = "300px";
});
await ContentTask.spawn(gTestBrowser, {}, async function() {
content.document.getElementById("test").clientTop;
});
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(overlay && overlay.getAttribute("sizing") != "blank",
"Test 6, overlay should be visible.");
});
});

Просмотреть файл

@ -0,0 +1,64 @@
/* import-globals-from ../head.js */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* This test ensures that the click-to-play "Activate Plugin" overlay
* is shown when expected.
* All testcases are in the plugin_shouldShowOverlay.html file.
*
* Note: Technically, the overlay is *always* shown. When this test was
* originally written, the meaning of "shown" was "shown with the contents",
* as opposed to "shown as blank". The behavior hasn't changed, but the naming
* has: now, a "shown as blank" overlay no longer receives a ".hidden" class.
* It receives a sizing="blank" attribute.
*/
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
add_task(async function() {
registerCleanupFunction(function() {
clearAllPluginPermissions();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
gBrowser.removeCurrentTab();
gTestBrowser = null;
});
});
add_task(async function() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!popupNotification, "Sanity check, should not have a click-to-play notification");
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_shouldShowOverlay.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let testcases = doc.querySelectorAll(".testcase");
for (let testcase of testcases) {
let plugin = testcase.querySelector("object");
Assert.ok(plugin, `plugin exists in ${testcase.id}`);
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(overlay, `overlay exists in ${testcase.id}`);
let expectedVisibility = (testcase.getAttribute("shouldshow") == "true");
Assert.ok((overlay.getAttribute("sizing") != "blank") == expectedVisibility,
`The expected visibility is correct in ${testcase.id}`);
}
});
});

Просмотреть файл

@ -0,0 +1,64 @@
/* import-globals-from ../head.js */
"use strict";
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
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.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
FullZoom.reset(); // must be called before closing the tab we zoomed!
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
Services.prefs.setBoolPref("plugins.click_to_play", true);
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!popupNotification, "Test 1, Should not have a click-to-play notification");
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_zoom.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await promisePopupNotification("click-to-play-plugins");
});
// Enlarges the zoom level 4 times and tests that the overlay is
// visible after each enlargement.
add_task(async function() {
for (let count = 0; count < 4; count++) {
FullZoom.enlarge();
// Reload the page
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_zoom.html");
await promiseUpdatePluginBindings(gTestBrowser);
await ContentTask.spawn(gTestBrowser, { count }, async function(args) {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(overlay && overlay.classList.contains("visible"),
"Overlay should be visible for zoom change count " + args.count);
});
}
});

Просмотреть файл

@ -0,0 +1,309 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
function updateAllTestPlugins(aState) {
setTestPluginEnabledState(aState, "Test Plug-in");
setTestPluginEnabledState(aState, "Second Test Plug-in");
}
add_task(async function() {
registerCleanupFunction(async function() {
clearAllPluginPermissions();
updateAllTestPlugins(Ci.nsIPluginTag.STATE_ENABLED);
Services.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
resetBlocklist();
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
Services.prefs.setBoolPref("plugins.click_to_play", true);
// Prime the content process
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>hi</html>");
});
// Tests a vulnerable, updatable plugin
add_task(async function() {
// enable hard blocklisting of test
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable.xml", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await promisePopupNotification("click-to-play-plugins");
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_UPDATABLE,
"Test 18a, plugin fallback type should be PLUGIN_VULNERABLE_UPDATABLE");
ok(!pluginInfo.activated, "Test 18a, Plugin should not be activated");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(overlay && overlay.classList.contains("visible"),
"Test 18a, Plugin overlay should exist, not be hidden");
let updateLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "checkForUpdatesLink");
Assert.ok(updateLink.style.visibility != "hidden",
"Test 18a, Plugin should have an update link");
});
let promise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen", true);
await ContentTask.spawn(gTestBrowser, {}, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let updateLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "checkForUpdatesLink");
let bounds = updateLink.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
});
await promise;
promise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabClose", true);
gBrowser.removeCurrentTab();
await promise;
});
add_task(async function() {
// clicking the update link should not activate the plugin
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_UPDATABLE,
"Test 18a, plugin fallback type should be PLUGIN_VULNERABLE_UPDATABLE");
ok(!pluginInfo.activated, "Test 18b, Plugin should not be activated");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(overlay && overlay.classList.contains("visible"),
"Test 18b, Plugin overlay should exist, not be hidden");
});
});
// Tests a vulnerable plugin with no update
add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableNoUpdate.xml", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 18c, Should have a click-to-play notification");
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_NO_UPDATE,
"Test 18c, plugin fallback type should be PLUGIN_VULNERABLE_NO_UPDATE");
ok(!pluginInfo.activated, "Test 18c, Plugin should not be activated");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(overlay && overlay.classList.contains("visible"),
"Test 18c, Plugin overlay should exist, not be hidden");
let updateLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "checkForUpdatesLink");
Assert.ok(updateLink && updateLink.style.display != "block",
"Test 18c, Plugin should not have an update link");
});
// check that click "Allow" works with blocked plugins
await promiseForNotificationShown(notification);
PopupNotifications.panel.firstElementChild.button.click();
pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_NO_UPDATE,
"Test 18c, plugin fallback type should be PLUGIN_VULNERABLE_NO_UPDATE");
ok(pluginInfo.activated, "Test 18c, Plugin should be activated");
let enabledState = getTestPluginEnabledState();
ok(enabledState, "Test 18c, Plugin enabled state should be STATE_CLICKTOPLAY");
});
// continue testing "Always allow", make sure it sticks.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let pluginInfo = await promiseForPluginInfo("test");
ok(pluginInfo.activated, "Test 18d, Waited too long for plugin to activate");
clearAllPluginPermissions();
});
// clicking the in-content overlay of a vulnerable plugin should bring
// up the notification and not directly activate the plugin
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 18f, Should have a click-to-play notification");
ok(notification.dismissed, "Test 18f, notification should start dismissed");
let pluginInfo = await promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Test 18f, Waited too long for plugin to activate");
var oldEventCallback = notification.options.eventCallback;
let promise = promiseForCondition(() => oldEventCallback == null);
notification.options.eventCallback = function() {
if (oldEventCallback) {
oldEventCallback();
}
oldEventCallback = null;
};
await ContentTask.spawn(gTestBrowser, {}, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let bounds = plugin.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
});
await promise;
ok(notification, "Test 18g, Should have a click-to-play notification");
ok(!notification.dismissed, "Test 18g, notification should be open");
pluginInfo = await promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Test 18g, Plugin should not be activated");
});
// Test that "always allow"-ing a plugin will not allow it when it becomes
// blocklisted.
add_task(async function() {
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 24a, Should have a click-to-play notification");
// Plugin should start as CTP
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
"Test 24a, plugin fallback type should be PLUGIN_CLICK_TO_PLAY");
ok(!pluginInfo.activated, "Test 24a, Plugin should not be active.");
// simulate "allow"
await promiseForNotificationShown(notification);
PopupNotifications.panel.firstElementChild.button.click();
pluginInfo = await promiseForPluginInfo("test");
ok(pluginInfo.activated, "Test 24a, Plugin should be active.");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable.xml", gTestBrowser);
});
// the plugin is now blocklisted, so it should not automatically load
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 24b, Should have a click-to-play notification");
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_UPDATABLE,
"Test 24b, plugin fallback type should be PLUGIN_VULNERABLE_UPDATABLE");
ok(!pluginInfo.activated, "Test 24b, Plugin should not be active.");
// simulate "allow"
await promiseForNotificationShown(notification);
PopupNotifications.panel.firstElementChild.button.click();
pluginInfo = await promiseForPluginInfo("test");
ok(pluginInfo.activated, "Test 24b, Plugin should be active.");
clearAllPluginPermissions();
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
});
// Plugin sync removal test. Note this test produces a notification drop down since
// the plugin we add has zero dims.
add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_syncRemoved.html");
// Maybe there some better trick here, we need to wait for the page load, then
// wait for the js to execute in the page.
await waitForMs(500);
let notification = PopupNotifications.getNotification("click-to-play-plugins");
ok(notification, "Test 25: There should be a plugin notification even if the plugin was immediately removed");
ok(notification.dismissed, "Test 25: The notification should be dismissed by default");
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>hi</html>");
});
// Tests a page with a blocked plugin in it and make sure the infoURL property
// the blocklist file gets used.
add_task(async function() {
clearAllPluginPermissions();
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginInfoURL.xml", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins");
// Since the plugin notification is dismissed by default, reshow it.
await promiseForNotificationShown(notification);
let pluginInfo = await promiseForPluginInfo("test");
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.");
});
});

Просмотреть файл

@ -0,0 +1,104 @@
/* import-globals-from ../head.js */
var gTestBrowser = null;
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gChromeRoot = getRootDirectory(gTestPath);
add_task(async function() {
registerCleanupFunction(async function() {
clearAllPluginPermissions();
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
resetBlocklist();
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
Services.prefs.setBoolPref("plugins.click_to_play", true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
});
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await ContentTask.spawn(gTestBrowser, {}, async function() {
let test = content.document.getElementById("test");
Assert.ok(test.activated, "task 1a: test plugin should be activated!");
});
});
// Load a fresh page, load a new plugin blocklist, then load the same page again.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>GO!</html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginHard.xml", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await ContentTask.spawn(gTestBrowser, {}, async function() {
let test = content.document.getElementById("test");
ok(!test.activated, "task 2a: test plugin shouldn't activate!");
});
});
// Unload the block list and lets do this again, only this time lets
// hack around in the content blocklist service maliciously.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>GO!</html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
// Hack the planet! Load our blocklist shim, so we can mess with blocklist
// return results in the content process. Active until we close our tab.
let mm = gTestBrowser.messageManager;
info("test 3a: loading " + gChromeRoot + "blocklist_proxy.js\n");
mm.loadFrameScript(gChromeRoot + "blocklist_proxy.js", true);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await ContentTask.spawn(gTestBrowser, {}, async function() {
let test = content.document.getElementById("test");
Assert.ok(test.activated, "task 3a: test plugin should be activated!");
});
});
// Load a fresh page, load a new plugin blocklist, then load the same page again.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>GO!</html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginHard.xml", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await ContentTask.spawn(gTestBrowser, {}, async function() {
let test = content.document.getElementById("test");
Assert.ok(!test.activated, "task 4a: test plugin shouldn't activate!");
});
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
});

Просмотреть файл

@ -0,0 +1,118 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
add_task(async function() {
registerCleanupFunction(async function() {
clearAllPluginPermissions();
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
resetBlocklist();
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
let newTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
});
// Tests that navigation within the page and the window.history API doesn't break click-to-play state.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_add_dynamically.html");
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!notification, "Test 1a, Should not have a click-to-play notification");
await ContentTask.spawn(gTestBrowser, {}, async function() {
new XPCNativeWrapper(XPCNativeWrapper.unwrap(content).addPlugin());
});
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");
});
// 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");
});
});
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,
"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");
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");
});
});
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");
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");
});
});

Просмотреть файл

@ -0,0 +1,52 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
var gNumPluginBindingsAttached = 0;
function pluginBindingAttached() {
gNumPluginBindingsAttached++;
if (gNumPluginBindingsAttached != 1) {
ok(false, "if we've gotten here, something is quite wrong");
}
}
add_task(async function() {
registerCleanupFunction(function() {
gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
clearAllPluginPermissions();
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
BrowserTestUtils.addContentEventListener(gTestBrowser, "PluginBindingAttached", pluginBindingAttached, true, null, true);
let testRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
await promiseTabLoadEvent(gBrowser.selectedTab, testRoot + "plugin_bug744745.html");
await promiseForCondition(function() { return gNumPluginBindingsAttached == 1; });
await ContentTask.spawn(gTestBrowser, {}, async function() {
let plugin = content.document.getElementById("test");
if (!plugin) {
Assert.ok(false, "plugin element not available.");
return;
}
// We can't use MochiKit's routine
let style = content.getComputedStyle(plugin);
Assert.ok(("opacity" in style) && style.opacity == 1, "plugin style properly configured.");
});
});

Просмотреть файл

@ -0,0 +1,66 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
var gWrapperClickCount = 0;
add_task(async function() {
registerCleanupFunction(function() {
clearAllPluginPermissions();
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
Services.prefs.setBoolPref("plugins.click_to_play", true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
let testRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
await promiseTabLoadEvent(gBrowser.selectedTab, testRoot + "plugin_bug787619.html");
// Due to layout being async, "PluginBindAttached" may trigger later.
// This forces a layout flush, thus triggering it, and schedules the
// test so it is definitely executed afterwards.
await promiseUpdatePluginBindings(gTestBrowser);
// check plugin state
let pluginInfo = await promiseForPluginInfo("plugin");
ok(!pluginInfo.activated, "1a plugin should not be activated");
// click the overlay to prompt
let promise = promisePopupNotification("click-to-play-plugins");
await ContentTask.spawn(gTestBrowser, {}, async function() {
let plugin = content.document.getElementById("plugin");
let bounds = plugin.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
});
await promise;
// check plugin state
pluginInfo = await promiseForPluginInfo("plugin");
ok(!pluginInfo.activated, "1b plugin should not be activated");
let condition = () => !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed &&
PopupNotifications.panel.firstElementChild;
await promiseForCondition(condition);
PopupNotifications.panel.firstElementChild.button.click();
// check plugin state
pluginInfo = await promiseForPluginInfo("plugin");
ok(pluginInfo.activated, "plugin should be activated");
is(gWrapperClickCount, 0, "wrapper should not have received any clicks");
});

Просмотреть файл

@ -0,0 +1,40 @@
/* import-globals-from ../head.js */
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 ContentTask.spawn(gTestBrowser, null, function() {
let plugin = content.document.getElementById("plugin");
ok(plugin, "plugin should be in the page");
});
is(gConsoleErrors, 0, "should have no console errors");
});

Просмотреть файл

@ -0,0 +1,80 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
add_task(async function() {
registerCleanupFunction(async function() {
clearAllPluginPermissions();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
resetBlocklist();
Services.prefs.clearUserPref("plugins.click_to_play");
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
});
// Tests that the going back will reshow the notification for click-to-play
// blocklisted plugins
add_task(async function() {
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable.xml", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(popupNotification, "test part 1: Should have a click-to-play notification");
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_UPDATABLE, "plugin should be marked as VULNERABLE");
await ContentTask.spawn(gTestBrowser, null, async function() {
Assert.ok(!!content.document.getElementById("test"),
"test part 1: plugin should not be activated");
});
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
});
add_task(async function() {
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!popupNotification, "test part 2: Should not have a click-to-play notification");
await ContentTask.spawn(gTestBrowser, null, async function() {
Assert.ok(!content.document.getElementById("test"),
"test part 2: plugin should not be activated");
});
let obsPromise = TestUtils.topicObserved("PopupNotifications-updateNotShowing");
let overlayPromise = promisePopupNotification("click-to-play-plugins");
gTestBrowser.goBack();
await obsPromise;
await overlayPromise;
});
add_task(async function() {
await promiseUpdatePluginBindings(gTestBrowser);
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(popupNotification, "test part 3: Should have a click-to-play notification");
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_UPDATABLE, "plugin should be marked as VULNERABLE");
await ContentTask.spawn(gTestBrowser, null, async function() {
Assert.ok(!!content.document.getElementById("test"),
"test part 3: plugin should not be activated");
});
});

Просмотреть файл

@ -0,0 +1,42 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
add_task(async function() {
registerCleanupFunction(function() {
clearAllPluginPermissions();
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
Services.prefs.setBoolPref("plugins.click_to_play", true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_both.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(popupNotification, "should have a click-to-play notification");
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "plugin should be click to play");
ok(!pluginInfo.activated, "plugin should not be activated");
await ContentTask.spawn(gTestBrowser, null, () => {
let unknown = content.document.getElementById("unknown");
ok(unknown, "should have unknown plugin in page");
});
});

Просмотреть файл

@ -0,0 +1,73 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
var gNumPluginBindingsAttached = 0;
add_task(async function() {
registerCleanupFunction(function() {
clearAllPluginPermissions();
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
Services.prefs.setBoolPref("plugins.click_to_play", true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
BrowserTestUtils.addContentEventListener(gTestBrowser, "PluginBindingAttached", function() { gNumPluginBindingsAttached++; }, true, null, true);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_bug820497.html");
await promiseForCondition(function() { return gNumPluginBindingsAttached == 1; });
await ContentTask.spawn(gTestBrowser, null, () => {
// Note we add the second plugin in the code farther down, so there's
// no way we got here with anything but one plugin loaded.
let doc = content.document;
let testplugin = doc.getElementById("test");
ok(testplugin, "should have test plugin");
let secondtestplugin = doc.getElementById("secondtest");
ok(!secondtestplugin, "should not yet have second test plugin");
});
await promisePopupNotification("click-to-play-plugins");
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "should have a click-to-play notification");
await promiseForNotificationShown(notification);
is(notification.options.pluginData.size, 1, "should be 1 type of plugin in the popup notification");
await ContentTask.spawn(gTestBrowser, {}, async function() {
XPCNativeWrapper.unwrap(content).addSecondPlugin();
});
await promiseForCondition(function() { return gNumPluginBindingsAttached == 2; });
await ContentTask.spawn(gTestBrowser, null, () => {
let doc = content.document;
let testplugin = doc.getElementById("test");
ok(testplugin, "should have test plugin");
let secondtestplugin = doc.getElementById("secondtest");
ok(secondtestplugin, "should have second test plugin");
});
notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "should have popup notification");
await promiseForNotificationShown(notification);
is(notification.options.pluginData.size, 2, "aited too long for 2 types of plugins in popup notification");
});

Просмотреть файл

@ -0,0 +1,29 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>Plugin Clear Site Data sanitize test</title>
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
<script type="application/javascript">
function testSteps() {
// Make sure clearing by timerange is supported.
var p = document.getElementById("plugin1");
p.setSitesWithDataCapabilities(true);
p.setSitesWithData(
"foo.com:0:5," +
"bar.com:0:100," +
"baz.com:1:5," +
"qux.com:1:100"
);
}
</script>
</head>
<body onload="testSteps();"></body>
</html>

Просмотреть файл

@ -0,0 +1,113 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
var gTestBrowser = null;
// Test clearing plugin data using Sanitizer.jsm.
const testURL1 = gTestRoot + "browser_clearplugindata.html";
const testURL2 = gTestRoot + "browser_clearplugindata_noage.html";
const {Sanitizer} = ChromeUtils.import("resource:///modules/Sanitizer.jsm", {});
const pluginHostIface = Ci.nsIPluginHost;
var pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
pluginHost.QueryInterface(pluginHostIface);
var pluginTag = getTestPlugin();
function stored(needles) {
let something = pluginHost.siteHasData(this.pluginTag, null);
if (!needles)
return something;
if (!something)
return false;
for (let i = 0; i < needles.length; ++i) {
if (!pluginHost.siteHasData(this.pluginTag, needles[i]))
return false;
}
return true;
}
add_task(async function() {
registerCleanupFunction(function() {
clearAllPluginPermissions();
Services.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
if (gTestBrowser) {
gBrowser.removeCurrentTab();
}
window.focus();
gTestBrowser = null;
});
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
});
function setPrefs(cookies, pluginData) {
let itemPrefs = Services.prefs.getBranch("privacy.cpd.");
itemPrefs.setBoolPref("history", false);
itemPrefs.setBoolPref("downloads", false);
itemPrefs.setBoolPref("cache", false);
itemPrefs.setBoolPref("cookies", cookies);
itemPrefs.setBoolPref("formdata", false);
itemPrefs.setBoolPref("offlineApps", false);
itemPrefs.setBoolPref("passwords", false);
itemPrefs.setBoolPref("sessions", false);
itemPrefs.setBoolPref("siteSettings", false);
itemPrefs.setBoolPref("pluginData", pluginData);
}
async function testClearingData(url) {
// Load page to set data for the plugin.
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
await promiseTabLoadEvent(gBrowser.selectedTab, url);
await promiseUpdatePluginBindings(gTestBrowser);
ok(stored(["foo.com", "bar.com", "baz.com", "qux.com"]),
"Data stored for sites");
// Clear 20 seconds ago.
// In the case of testURL2 the plugin will throw
// NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED, which should result in us
// clearing all data regardless of age.
let now_uSec = Date.now() * 1000;
let range = [now_uSec - 20 * 1000000, now_uSec];
await Sanitizer.sanitize(null, {range, ignoreTimespan: false});
if (url == testURL1) {
ok(stored(["bar.com", "qux.com"]), "Data stored for sites");
ok(!stored(["foo.com"]), "Data cleared for foo.com");
ok(!stored(["baz.com"]), "Data cleared for baz.com");
// Clear everything.
await Sanitizer.sanitize(null, {ignoreTimespan: false});
}
ok(!stored(null), "All data cleared");
gBrowser.removeCurrentTab();
gTestBrowser = null;
}
add_task(async function() {
// Test when sanitizing cookies.
await setPrefs(true, false);
await testClearingData(testURL1);
await testClearingData(testURL2);
// Test when sanitizing pluginData.
await setPrefs(false, true);
await testClearingData(testURL1);
await testClearingData(testURL2);
});

Просмотреть файл

@ -0,0 +1,29 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>Plugin Clear Site Data sanitize test without age</title>
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
<script type="application/javascript">
function testSteps() {
// Make sure clearing by timerange is disabled.
var p = document.getElementById("plugin1");
p.setSitesWithDataCapabilities(false);
p.setSitesWithData(
"foo.com:0:5," +
"bar.com:0:100," +
"baz.com:1:5," +
"qux.com:1:100"
);
}
</script>
</head>
<body onload="testSteps();"></body>
</html>

Просмотреть файл

@ -0,0 +1,67 @@
/*
* Bug 1366167 - Tests that the "Enable DRM" prompt shows if EME is requested while EME is disabled.
*/
const TEST_URL =
getRootDirectory(gTestPath).replace("chrome://mochitests/content",
"https://example.com") + "empty_file.html";
add_task(async function() {
await BrowserTestUtils.withNewTab(TEST_URL, async function(browser) {
// Note: SpecialPowers.pushPrefEnv has problems with the "Enable DRM"
// button on the notification box toggling the prefs. So manually
// set/unset the prefs the UI we're testing toggles.
let emeWasEnabled = Services.prefs.getBoolPref("media.eme.enabled", false);
let cdmWasEnabled = Services.prefs.getBoolPref("media.gmp-widevinecdm.enabled", false);
// Restore the preferences to their pre-test state on test finish.
registerCleanupFunction(function() {
Services.prefs.setBoolPref("media.eme.enabled", emeWasEnabled);
Services.prefs.setBoolPref("media.gmp-widevinecdm.enabled", cdmWasEnabled);
});
// Turn off EME and Widevine CDM.
Services.prefs.setBoolPref("media.eme.enabled", false);
Services.prefs.setBoolPref("media.gmp-widevinecdm.enabled", false);
// Have content request access to Widevine, UI should drop down to
// prompt user to enable DRM.
let result = await ContentTask.spawn(browser, {}, async function() {
try {
let config = [{
initDataTypes: ["webm"],
videoCapabilities: [{contentType: 'video/webm; codecs="vp9"'}],
}];
await content.navigator.requestMediaKeySystemAccess("com.widevine.alpha", config);
} catch (ex) {
return {rejected: true};
}
return {rejected: false};
});
is(result.rejected, true, "EME request should be denied because EME disabled.");
// Verify the UI prompt showed.
let box = gBrowser.getNotificationBox(browser);
let notification = box.currentNotification;
ok(notification, "Notification should be visible");
is(notification.getAttribute("value"), "drmContentDisabled",
"Should be showing the right notification");
// Verify the "Enable DRM" button is there.
let buttons = notification.querySelectorAll(".notification-button");
is(buttons.length, 1, "Should have one button.");
// Prepare a Promise that should resolve when the "Enable DRM" button's
// page reload completes.
let refreshPromise = BrowserTestUtils.browserLoaded(browser);
buttons[0].click();
// Wait for the reload to complete.
await refreshPromise;
// Verify clicking the "Enable DRM" button enabled DRM.
let enabled = Services.prefs.getBoolPref("media.eme.enabled", true);
is(enabled, true, "EME should be enabled after click on 'Enable DRM' button");
});
});

Просмотреть файл

@ -0,0 +1,36 @@
/* import-globals-from ../head.js */
/**
* Test that the notification bar for crashed GMPs works.
*/
add_task(async function() {
await BrowserTestUtils.withNewTab({
gBrowser,
url: "about:blank",
}, async function(browser) {
await ContentTask.spawn(browser, null, async function() {
const GMP_CRASH_EVENT = {
pluginID: 1,
pluginName: "GlobalTestPlugin",
submittedCrashReport: false,
bubbles: true,
cancelable: true,
gmpPlugin: true,
};
let crashEvent = new content.PluginCrashedEvent("PluginCrashed",
GMP_CRASH_EVENT);
content.dispatchEvent(crashEvent);
});
let notification = await waitForNotificationBar("plugin-crashed", browser);
let notificationBox = gBrowser.getNotificationBox(browser);
ok(notification, "Infobar was shown.");
is(notification.priority, notificationBox.PRIORITY_WARNING_MEDIUM,
"Correct priority.");
is(notification.messageText.textContent,
"The GlobalTestPlugin plugin has crashed.",
"Correct message.");
});
});

Просмотреть файл

@ -0,0 +1,70 @@
/* import-globals-from ../head.js */
"use strict";
const TEST_PLUGIN_NAME = "Test Plug-in";
const HIDDEN_CTP_PLUGIN_PREF = "plugins.navigator.hidden_ctp_plugin";
/**
* If a plugin is click-to-play and named in HIDDEN_CTP_PLUGIN_PREF,
* then the plugin should be hidden in the navigator.plugins list by default
* when iterating.
*/
add_task(async function setup() {
// We'll make the Test Plugin click-to-play.
let originalPluginState = getTestPluginEnabledState();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
registerCleanupFunction(() => {
setTestPluginEnabledState(originalPluginState);
});
// And then make the plugin hidden.
await SpecialPowers.pushPrefEnv({
set: [
[HIDDEN_CTP_PLUGIN_PREF, TEST_PLUGIN_NAME],
["plugins.show_infobar", true],
],
});
});
/**
* Tests that if a plugin is click-to-play and in the
* HIDDEN_CTP_PLUGIN_PREF list, then it shouldn't be visible
* when iterating navigator.plugins.
*/
add_task(async function test_plugin_is_hidden_on_iteration() {
// The plugin should not be visible when we iterate
// navigator.plugins.
await BrowserTestUtils.withNewTab({
gBrowser,
url: "http://example.com",
}, async function(browser) {
await ContentTask.spawn(browser, TEST_PLUGIN_NAME, async function(pluginName) {
let plugins = Array.from(content.navigator.plugins);
Assert.ok(plugins.every(p => p.name != pluginName),
"Should not find Test Plugin");
});
});
// Now clear the HIDDEN_CTP_PLUGIN_PREF temporarily and
// make sure we can see the plugin again.
await SpecialPowers.pushPrefEnv({
set: [[HIDDEN_CTP_PLUGIN_PREF, ""]],
});
// Note that I have to do this in a new tab since navigator
// caches navigator.plugins after an initial read.
await BrowserTestUtils.withNewTab({
gBrowser,
url: "http://example.com",
}, async function(browser) {
await ContentTask.spawn(browser, TEST_PLUGIN_NAME, async function(pluginName) {
let plugins = Array.from(content.navigator.plugins);
Assert.ok(plugins.some(p => p.name == pluginName),
"Should have found the Test Plugin");
});
});
await SpecialPowers.popPrefEnv();
});

Просмотреть файл

@ -0,0 +1,249 @@
/* import-globals-from ../head.js */
/* global gBrowser */
ChromeUtils.import("resource://gre/modules/CrashSubmit.jsm", this);
const SERVER_URL = "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs";
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
var config = {};
add_task(async function() {
// The test harness sets MOZ_CRASHREPORTER_NO_REPORT, which disables plugin
// crash reports. This test needs them enabled. The test also needs a mock
// report server, and fortunately one is already set up by toolkit/
// crashreporter/test/Makefile.in. Assign its URL to MOZ_CRASHREPORTER_URL,
// which CrashSubmit.jsm uses as a server override.
let env = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment);
let noReport = env.get("MOZ_CRASHREPORTER_NO_REPORT");
let serverUrl = env.get("MOZ_CRASHREPORTER_URL");
env.set("MOZ_CRASHREPORTER_NO_REPORT", "");
env.set("MOZ_CRASHREPORTER_URL", SERVER_URL);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
// Crash immediately
Services.prefs.setIntPref("dom.ipc.plugins.timeoutSecs", 0);
registerCleanupFunction(async function() {
Services.prefs.clearUserPref("dom.ipc.plugins.timeoutSecs");
env.set("MOZ_CRASHREPORTER_NO_REPORT", noReport);
env.set("MOZ_CRASHREPORTER_URL", serverUrl);
env = null;
config = null;
gTestBrowser = null;
gBrowser.removeCurrentTab();
window.focus();
});
});
add_task(async function() {
config = {
shouldSubmissionUIBeVisible: true,
comment: "",
urlOptIn: false,
};
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED);
let pluginCrashed = promisePluginCrashed();
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_crashCommentAndURL.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
// Wait for the plugin to crash
await pluginCrashed;
let crashReportStatus = TestUtils.topicObserved("crash-report-status", onSubmitStatus);
// Test that the crash submission UI is actually visible and submit the crash report.
await ContentTask.spawn(gTestBrowser, config, async function(aConfig) {
let doc = content.document;
let plugin = doc.getElementById("plugin");
let pleaseSubmit = doc.getAnonymousElementByAttribute(plugin, "anonid", "pleaseSubmit");
let submitButton = doc.getAnonymousElementByAttribute(plugin, "anonid", "submitButton");
// Test that we don't send the URL when urlOptIn is false.
doc.getAnonymousElementByAttribute(plugin, "anonid", "submitURLOptIn").checked = aConfig.urlOptIn;
submitButton.click();
Assert.equal(content.getComputedStyle(pleaseSubmit).display == "block",
aConfig.shouldSubmissionUIBeVisible, "The crash UI should be visible");
});
await crashReportStatus;
});
add_task(async function() {
config = {
shouldSubmissionUIBeVisible: true,
comment: "a test comment",
urlOptIn: true,
};
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED);
let pluginCrashed = promisePluginCrashed();
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_crashCommentAndURL.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
// Wait for the plugin to crash
await pluginCrashed;
let crashReportStatus = TestUtils.topicObserved("crash-report-status", onSubmitStatus);
// Test that the crash submission UI is actually visible and submit the crash report.
await ContentTask.spawn(gTestBrowser, config, async function(aConfig) {
let doc = content.document;
let plugin = doc.getElementById("plugin");
let pleaseSubmit = doc.getAnonymousElementByAttribute(plugin, "anonid", "pleaseSubmit");
let submitButton = doc.getAnonymousElementByAttribute(plugin, "anonid", "submitButton");
// Test that we send the URL when urlOptIn is true.
doc.getAnonymousElementByAttribute(plugin, "anonid", "submitURLOptIn").checked = aConfig.urlOptIn;
doc.getAnonymousElementByAttribute(plugin, "anonid", "submitComment").value = aConfig.comment;
submitButton.click();
Assert.equal(content.getComputedStyle(pleaseSubmit).display == "block",
aConfig.shouldSubmissionUIBeVisible, "The crash UI should be visible");
});
await crashReportStatus;
});
add_task(async function() {
config = {
shouldSubmissionUIBeVisible: false,
comment: "",
urlOptIn: true,
};
// Deferred promise object used by the test to wait for the crash handler
let crashDeferred = PromiseUtils.defer();
// Clear out any minidumps we create from plugin crashes, this is needed
// because we do not submit the crash otherwise the submission process would
// have deleted the crash dump files for us.
let crashObserver = (subject, topic, data) => {
if (topic != "plugin-crashed") {
return;
}
let propBag = subject.QueryInterface(Ci.nsIPropertyBag2);
let minidumpID = propBag.getPropertyAsAString("pluginDumpID");
Services.crashmanager.ensureCrashIsPresent(minidumpID).then(() => {
let minidumpDir = Services.dirsvc.get("UAppData", Ci.nsIFile);
minidumpDir.append("Crash Reports");
minidumpDir.append("pending");
let pluginDumpFile = minidumpDir.clone();
pluginDumpFile.append(minidumpID + ".dmp");
let extraFile = minidumpDir.clone();
extraFile.append(minidumpID + ".extra");
pluginDumpFile.remove(false);
extraFile.remove(false);
crashDeferred.resolve();
});
};
Services.obs.addObserver(crashObserver, "plugin-crashed");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED);
let pluginCrashed = promisePluginCrashed();
// Make sure that the plugin container is too small to display the crash submission UI
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_crashCommentAndURL.html?" +
encodeURIComponent(JSON.stringify({width: 300, height: 300})));
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
// Wait for the plugin to crash
await pluginCrashed;
// Test that the crash submission UI is not visible and do not submit a crash report.
await ContentTask.spawn(gTestBrowser, config, async function(aConfig) {
let doc = content.document;
let plugin = doc.getElementById("plugin");
let pleaseSubmit = doc.getAnonymousElementByAttribute(plugin, "anonid", "pleaseSubmit");
Assert.equal(!!pleaseSubmit && content.getComputedStyle(pleaseSubmit).display == "block",
aConfig.shouldSubmissionUIBeVisible, "Plugin crash UI should not be visible");
});
await crashDeferred.promise;
Services.obs.removeObserver(crashObserver, "plugin-crashed");
});
function promisePluginCrashed() {
return new ContentTask.spawn(gTestBrowser, {}, async function() {
await new Promise((resolve) => {
addEventListener("PluginCrashReporterDisplayed", function onPluginCrashed() {
removeEventListener("PluginCrashReporterDisplayed", onPluginCrashed);
resolve();
});
});
});
}
function onSubmitStatus(aSubject, aData) {
if (aData === "submitting") {
return false;
}
is(aData, "success", "The crash report should be submitted successfully");
let propBag = aSubject.QueryInterface(Ci.nsIPropertyBag);
if (aData == "success") {
let remoteID = getPropertyBagValue(propBag, "serverCrashID");
ok(!!remoteID, "serverCrashID should be set");
// Remove the submitted report file.
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
file.initWithPath(Services.crashmanager._submittedDumpsDir);
file.append(remoteID + ".txt");
ok(file.exists(), "Submitted report file should exist");
file.remove(false);
}
let extra = getPropertyBagValue(propBag, "extra");
ok(extra instanceof Ci.nsIPropertyBag, "Extra data should be property bag");
let val = getPropertyBagValue(extra, "PluginUserComment");
if (config.comment) {
is(val, config.comment,
"Comment in extra data should match comment in textbox");
} else {
ok(val === undefined,
"Comment should be absent from extra data when textbox is empty");
}
val = getPropertyBagValue(extra, "PluginContentURL");
if (config.urlOptIn) {
is(val, gBrowser.currentURI.spec,
"URL in extra data should match browser URL when opt-in checked");
} else {
ok(val === undefined,
"URL should be absent from extra data when opt-in not checked");
}
return true;
}
function getPropertyBagValue(bag, key) {
try {
var val = bag.getProperty(key);
} catch (e) {
if (e.result != Cr.NS_ERROR_FAILURE) {
throw e;
}
}
return val;
}

Просмотреть файл

@ -0,0 +1,270 @@
/* import-globals-from ../head.js */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
/**
* With e10s, plugins must run in their own process. This means we have
* three processes at a minimum when we're running a plugin:
*
* 1) The main browser, or "chrome" process
* 2) The content process hosting the plugin instance
* 3) The plugin process
*
* If the plugin process crashes, we cannot be sure if the chrome process
* will hear about it first, or the content process will hear about it
* first. Because of how IPC works, that's really up to the operating system,
* and we assume any guarantees about it, so we have to account for both
* possibilities.
*
* This test exercises the browser's reaction to both possibilities.
*/
const CRASH_URL = "http://example.com/browser/browser/base/content/test/plugins/plugin_crashCommentAndURL.html";
const CRASHED_MESSAGE = "BrowserPlugins:NPAPIPluginProcessCrashed";
/**
* In order for our test to work, we need to be able to put a plugin
* in a very specific state. Specifically, we need it to match the
* :-moz-handler-crashed pseudoselector. The only way I can find to
* do that is by actually crashing the plugin. So we wait for the
* plugin to crash and show the "please" state (since that will
* only show if both the message from the parent has been received
* AND the PluginCrashed event has fired).
*
* Once in that state, we try to rewind the clock a little bit - we clear
* out the crashData cache in the PluginContent with a message, and we also
* override the pluginFallbackState of the <object> to fool PluginContent
* into believing that the plugin is in a particular state.
*
* @param browser
* The browser that has loaded the CRASH_URL that we need to
* prepare to be in the special state.
* @param pluginFallbackState
* The value we should override the <object>'s pluginFallbackState
* with.
* @return Promise
* The Promise resolves when the plugin has officially been put into
* the crash reporter state, and then "rewound" to have the "status"
* attribute of the statusDiv removed. The resolved Promise returns
* 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.ownerDocument
.getAnonymousElementByAttribute(plugin, "anonid",
"submitStatus");
return statusDiv && statusDiv.getAttribute("status") == "please";
}, "Timed out waiting for plugin to be in crash report state");
// "Rewind", by wiping out the status attribute...
statusDiv.removeAttribute("status");
// Somehow, I'm able to get away with overriding the getter for
// this XPCOM object. Probably because I've got chrome privledges.
Object.defineProperty(plugin, "pluginFallbackType", {
get() {
return contentPluginFallbackState;
},
});
return plugin.runID;
}).then((runID) => {
browser.messageManager.sendAsyncMessage("BrowserPlugins:Test:ClearCrashData");
return runID;
});
}
// Bypass click-to-play
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED);
// Deferred promise object used by the test to wait for the crash handler
let crashDeferred = null;
// Clear out any minidumps we create from plugins - we really don't care
// about them.
let crashObserver = (subject, topic, data) => {
if (topic != "plugin-crashed") {
return;
}
let propBag = subject.QueryInterface(Ci.nsIPropertyBag2);
let minidumpID = propBag.getPropertyAsAString("pluginDumpID");
Services.crashmanager.ensureCrashIsPresent(minidumpID).then(() => {
let minidumpDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
minidumpDir.append("minidumps");
let pluginDumpFile = minidumpDir.clone();
pluginDumpFile.append(minidumpID + ".dmp");
let extraFile = minidumpDir.clone();
extraFile.append(minidumpID + ".extra");
ok(pluginDumpFile.exists(), "Found minidump");
ok(extraFile.exists(), "Found extra file");
pluginDumpFile.remove(false);
extraFile.remove(false);
crashDeferred.resolve();
});
};
Services.obs.addObserver(crashObserver, "plugin-crashed");
// plugins.testmode will make BrowserPlugins:Test:ClearCrashData work.
Services.prefs.setBoolPref("plugins.testmode", true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("plugins.testmode");
Services.obs.removeObserver(crashObserver, "plugin-crashed");
});
/**
* In this case, the chrome process hears about the crash first.
*/
add_task(async function testChromeHearsPluginCrashFirst() {
// Setup the crash observer promise
crashDeferred = PromiseUtils.defer();
// Open a remote window so that we can run this test even if e10s is not
// enabled by default.
let win = await BrowserTestUtils.openNewBrowserWindow({remote: true});
let browser = win.gBrowser.selectedBrowser;
BrowserTestUtils.loadURI(browser, CRASH_URL);
await BrowserTestUtils.browserLoaded(browser);
// In this case, we want the <object> to match the -moz-handler-crashed
// pseudoselector, but we want it to seem still active, because the
// content process is not yet supposed to know that the plugin has
// crashed.
let runID = await preparePlugin(browser,
Ci.nsIObjectLoadingContent.PLUGIN_ACTIVE);
// Send the message down to PluginContent.jsm saying that the plugin has
// crashed, and that we have a crash report.
let mm = browser.messageManager;
mm.sendAsyncMessage(CRASHED_MESSAGE,
{ pluginName: "", runID, state: "please" });
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.ownerDocument
.getAnonymousElementByAttribute(plugin, "anonid",
"submitStatus");
if (statusDiv.getAttribute("status") == "please") {
Assert.ok(false, "Did not expect plugin to be in crash report mode yet.");
return;
}
// Now we need the plugin to seem crashed to PluginContent.jsm, without
// actually crashing the plugin again. We hack around this by overriding
// the pluginFallbackType again.
Object.defineProperty(plugin, "pluginFallbackType", {
get() {
return Ci.nsIObjectLoadingContent.PLUGIN_CRASHED;
},
});
let event = new content.PluginCrashedEvent("PluginCrashed", {
pluginName: "",
pluginDumpID: "",
browserDumpID: "",
submittedCrashReport: false,
bubbles: true,
cancelable: true,
});
plugin.dispatchEvent(event);
Assert.equal(statusDiv.getAttribute("status"), "please",
"Should have been showing crash report UI");
});
await BrowserTestUtils.closeWindow(win);
await crashDeferred.promise;
});
/**
* In this case, the content process hears about the crash first.
*/
add_task(async function testContentHearsCrashFirst() {
// Setup the crash observer promise
crashDeferred = PromiseUtils.defer();
// Open a remote window so that we can run this test even if e10s is not
// enabled by default.
let win = await BrowserTestUtils.openNewBrowserWindow({remote: true});
let browser = win.gBrowser.selectedBrowser;
BrowserTestUtils.loadURI(browser, CRASH_URL);
await BrowserTestUtils.browserLoaded(browser);
// In this case, we want the <object> to match the -moz-handler-crashed
// pseudoselector, and we want the plugin to seem crashed, since the
// content process in this case has heard about the crash first.
let runID = await preparePlugin(browser,
Ci.nsIObjectLoadingContent.PLUGIN_CRASHED);
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.ownerDocument
.getAnonymousElementByAttribute(plugin, "anonid",
"submitStatus");
if (statusDiv.getAttribute("status") == "please") {
Assert.ok(false, "Did not expect plugin to be in crash report mode yet.");
}
let event = new content.PluginCrashedEvent("PluginCrashed", {
pluginName: "",
pluginDumpID: "",
browserDumpID: "",
submittedCrashReport: false,
bubbles: true,
cancelable: true,
});
plugin.dispatchEvent(event);
Assert.notEqual(statusDiv.getAttribute("status"), "please",
"Should not yet be showing crash report UI");
});
// Now send the message down to PluginContent.jsm that the plugin has
// crashed...
let mm = browser.messageManager;
mm.sendAsyncMessage(CRASHED_MESSAGE,
{ pluginName: "", runID, state: "please"});
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.ownerDocument
.getAnonymousElementByAttribute(plugin, "anonid",
"submitStatus");
Assert.equal(statusDiv.getAttribute("status"), "please",
"Should have been showing crash report UI");
});
await BrowserTestUtils.closeWindow(win);
await crashDeferred.promise;
});

Просмотреть файл

@ -0,0 +1,86 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
var gTestBrowser = null;
function updateAllTestPlugins(aState) {
setTestPluginEnabledState(aState, "Test Plug-in");
setTestPluginEnabledState(aState, "Second Test Plug-in");
}
add_task(async function() {
registerCleanupFunction(async function() {
clearAllPluginPermissions();
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
resetBlocklist();
gTestBrowser = null;
gBrowser.removeCurrentTab();
window.focus();
});
});
add_task(async function() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
Services.prefs.setBoolPref("plugins.click_to_play", true);
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
});
// Tests that a click-to-play plugin retains its activated state upon reloading
add_task(async function() {
clearAllPluginPermissions();
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 1, Should have a click-to-play notification");
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
"Test 2, plugin fallback type should be PLUGIN_CLICK_TO_PLAY");
// run the plugin
await promisePlayObject("test");
await promiseUpdatePluginBindings(gTestBrowser);
pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.displayedType, Ci.nsIObjectLoadingContent.TYPE_PLUGIN, "Test 3, plugin should have started");
ok(pluginInfo.activated, "Test 4, plugin node should not be activated");
await ContentTask.spawn(gTestBrowser, null, async function() {
let plugin = content.document.getElementById("test");
let npobj1 = Cu.waiveXrays(plugin).getObjectValue();
// eslint-disable-next-line no-self-assign
plugin.src = plugin.src;
let pluginsDiffer = false;
try {
Cu.waiveXrays(plugin).checkObjectValue(npobj1);
} catch (e) {
pluginsDiffer = true;
}
Assert.ok(pluginsDiffer, "Test 5, plugins differ.");
});
pluginInfo = await promiseForPluginInfo("test");
ok(pluginInfo.activated, "Test 6, Plugin should have retained activated state.");
is(pluginInfo.displayedType, Ci.nsIObjectLoadingContent.TYPE_PLUGIN, "Test 7, plugin should have started");
});

Просмотреть файл

@ -0,0 +1,480 @@
/* import-globals-from ../head.js */
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
var gTestBrowser = null;
function updateAllTestPlugins(aState) {
setTestPluginEnabledState(aState, "Test Plug-in");
setTestPluginEnabledState(aState, "Second Test Plug-in");
}
add_task(async function() {
registerCleanupFunction(async function() {
clearAllPluginPermissions();
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
resetBlocklist();
gTestBrowser = null;
gBrowser.removeCurrentTab();
window.focus();
});
});
add_task(async function() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
Services.prefs.setBoolPref("plugins.click_to_play", true);
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
});
// Tests a page with an unknown plugin in it.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_unknown.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let pluginInfo = await promiseForPluginInfo("unknown");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_UNSUPPORTED,
"Test 1a, plugin fallback type should be PLUGIN_UNSUPPORTED");
});
// Test that the doorhanger is shown when the user clicks on the overlay
// after having previously blocked the plugin.
add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await promisePopupNotification("click-to-play-plugins");
let pluginInfo = await promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Plugin should not be activated");
// Simulate clicking the "Allow" button.
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
await promiseForNotificationShown(notification);
PopupNotifications.panel.firstElementChild.button.click();
pluginInfo = await promiseForPluginInfo("test");
ok(pluginInfo.activated, "Plugin should be activated");
// Simulate clicking the "Block" button.
await promiseForNotificationShown(notification);
PopupNotifications.panel.firstElementChild.secondaryButton.click();
pluginInfo = await promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Plugin should not be activated");
let browserLoaded = BrowserTestUtils.browserLoaded(gTestBrowser);
gTestBrowser.reload();
await browserLoaded;
notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
// Simulate clicking the overlay
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let bounds = doc.getAnonymousElementByAttribute(plugin, "anonid", "main").getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
});
ok(!notification.dismissed, "A plugin notification should be shown.");
clearAllPluginPermissions();
});
// Tests that going back will reshow the notification for click-to-play plugins
add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await promisePopupNotification("click-to-play-plugins");
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>hi</html>");
// make sure the notification is gone
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!notification, "Test 11b, Should not have a click-to-play notification");
gTestBrowser.webNavigation.goBack();
await promisePopupNotification("click-to-play-plugins");
});
// Tests that the "Allow Always" permission works for click-to-play plugins
add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await promisePopupNotification("click-to-play-plugins");
let pluginInfo = await promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Test 12a, Plugin should not be activated");
// Simulate clicking the "Allow" button.
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
await promiseForNotificationShown(notification);
PopupNotifications.panel.firstElementChild.button.click();
pluginInfo = await promiseForPluginInfo("test");
ok(pluginInfo.activated, "Test 12a, Plugin should be activated");
});
// Test that the "Always" permission, when set for just the Test plugin,
// does not also allow the Second Test plugin.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_two_types.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
await promisePopupNotification("click-to-play-plugins");
await ContentTask.spawn(gTestBrowser, null, async function() {
let test = content.document.getElementById("test");
let secondtestA = content.document.getElementById("secondtestA");
let secondtestB = content.document.getElementById("secondtestB");
Assert.ok(test.activated && !secondtestA.activated && !secondtestB.activated,
"Content plugins are set up");
});
clearAllPluginPermissions();
});
// Tests that the plugin's "activated" property is true for working plugins
// with click-to-play disabled.
add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_ENABLED);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test2.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let pluginInfo = await promiseForPluginInfo("test1");
ok(pluginInfo.activated, "Test 14, Plugin should be activated");
});
// Tests that the overlay is shown instead of alternate content when
// plugins are click to play.
add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_alternate_content.html");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let mainBox = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(!!mainBox, "Test 15, Plugin overlay should exist");
});
});
// Tests that mContentType is used for click-to-play plugins, and not the
// inspected type.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_bug749455.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 17, Should have a click-to-play notification");
});
// Tests that clicking the icon of the overlay activates the doorhanger
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let pluginInfo = await promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Test 18g, Plugin should not be activated");
ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed,
"Test 19a, Doorhanger should start out dismissed");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let icon = doc.getAnonymousElementByAttribute(plugin, "class", "icon");
let bounds = icon.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
});
let condition = () => !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed;
await promiseForCondition(condition);
});
// Tests that clicking the text of the overlay activates the plugin
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let pluginInfo = await promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Test 18g, Plugin should not be activated");
ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed,
"Test 19c, Doorhanger should start out dismissed");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let text = doc.getAnonymousElementByAttribute(plugin, "class", "msg msgClickToPlay");
let bounds = text.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
});
let condition = () => !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed;
await promiseForCondition(condition);
});
// Tests that clicking the box of the overlay activates the doorhanger
// (just to be thorough)
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let pluginInfo = await promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Test 18g, Plugin should not be activated");
ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed,
"Test 19e, Doorhanger should start out dismissed");
await ContentTask.spawn(gTestBrowser, null, async function() {
let utils = content.windowUtils;
utils.sendMouseEvent("mousedown", 50, 50, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", 50, 50, 0, 1, 0, false, 0, 0);
});
let condition = () => !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed &&
PopupNotifications.panel.firstElementChild;
await promiseForCondition(condition);
PopupNotifications.panel.firstElementChild.button.click();
pluginInfo = await promiseForPluginInfo("test");
ok(pluginInfo.activated, "Test 19e, Plugin should not be activated");
clearAllPluginPermissions();
});
// Tests that a plugin in a div that goes from style="display: none" to
// "display: block" can be clicked to activate.
add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_hidden_to_visible.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 20a, Should have a click-to-play notification");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(!!overlay, "Test 20a, Plugin overlay should exist");
});
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let mainBox = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlayRect = mainBox.getBoundingClientRect();
Assert.ok(overlayRect.width == 0 && overlayRect.height == 0,
"Test 20a, plugin should have an overlay with 0px width and height");
});
let pluginInfo = await promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Test 20b, plugin should not be activated");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let div = doc.getElementById("container");
Assert.equal(div.style.display, "none",
"Test 20b, container div should be display: none");
});
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let div = doc.getElementById("container");
div.style.display = "block";
});
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let mainBox = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let overlayRect = mainBox.getBoundingClientRect();
Assert.ok(overlayRect.width == 200 && overlayRect.height == 200,
"Test 20c, plugin should have overlay dims of 200px");
});
pluginInfo = await promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Test 20b, plugin should not be activated");
ok(notification.dismissed, "Test 20c, Doorhanger should start out dismissed");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let bounds = plugin.getBoundingClientRect();
let left = (bounds.left + bounds.right) / 2;
let top = (bounds.top + bounds.bottom) / 2;
let utils = content.windowUtils;
utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
});
let condition = () => !notification.dismissed && !!PopupNotifications.panel.firstElementChild;
await promiseForCondition(condition);
PopupNotifications.panel.firstElementChild.button.click();
pluginInfo = await promiseForPluginInfo("test");
ok(pluginInfo.activated, "Test 20c, plugin should be activated");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlayRect = doc.getAnonymousElementByAttribute(plugin, "anonid", "main").getBoundingClientRect();
Assert.ok(overlayRect.width == 0 && overlayRect.height == 0,
"Test 20c, plugin should have overlay dims of 0px");
});
clearAllPluginPermissions();
});
// Tests that a click-to-play plugin resets its activated state when changing types
add_task(async function() {
clearAllPluginPermissions();
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 22, Should have a click-to-play notification");
// Plugin should start as CTP
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
"Test 23, plugin fallback type should be PLUGIN_CLICK_TO_PLAY");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
plugin.type = null;
// We currently don't properly change state just on type change,
// so rebind the plugin to tree. bug 767631
plugin.parentNode.appendChild(plugin);
});
pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.displayedType, Ci.nsIObjectLoadingContent.TYPE_NULL, "Test 23, plugin should be TYPE_NULL");
await ContentTask.spawn(gTestBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("test");
plugin.type = "application/x-test";
plugin.parentNode.appendChild(plugin);
});
pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.displayedType, Ci.nsIObjectLoadingContent.TYPE_NULL, "Test 23, plugin should be TYPE_NULL");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
"Test 23, plugin fallback type should be PLUGIN_CLICK_TO_PLAY");
ok(!pluginInfo.activated, "Test 23, plugin node should not be activated");
});
// Plugin sync removal test. Note this test produces a notification drop down since
// the plugin we add has zero dims.
add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_syncRemoved.html");
// Maybe there some better trick here, we need to wait for the page load, then
// wait for the js to execute in the page.
await waitForMs(500);
let notification = PopupNotifications.getNotification("click-to-play-plugins");
ok(notification, "Test 25: There should be a plugin notification even if the plugin was immediately removed");
ok(notification.dismissed, "Test 25: The notification should be dismissed by default");
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>hi</html>");
});
// Tests a page with a blocked plugin in it and make sure the infoURL property
// the blocklist file gets used.
add_task(async function() {
clearAllPluginPermissions();
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginInfoURL.xml", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins");
// Since the plugin notification is dismissed by default, reshow it.
await promiseForNotificationShown(notification);
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_BLOCKLISTED,
"Test 26, plugin fallback type should be PLUGIN_BLOCKLISTED");
ok(!pluginInfo.activated, "Plugin should be activated.");
});

Просмотреть файл

@ -0,0 +1,44 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* This test ensures that navigator.requestMediaKeySystemAccess() requests
* to run EME with persistent state are rejected in private browsing windows.
* Bug 1334111.
*/
const TEST_URL =
getRootDirectory(gTestPath).replace("chrome://mochitests/content",
"https://example.com") + "empty_file.html";
async function isEmePersistentStateSupported(mode) {
let win = await BrowserTestUtils.openNewBrowserWindow(mode);
let tab = await BrowserTestUtils.openNewForegroundTab(win.gBrowser, TEST_URL);
let persistentStateSupported = await ContentTask.spawn(tab.linkedBrowser, {}, async function() {
try {
let config = [{
initDataTypes: ["webm"],
videoCapabilities: [{contentType: 'video/webm; codecs="vp9"'}],
persistentState: "required",
}];
await content.navigator.requestMediaKeySystemAccess("org.w3.clearkey", config);
} catch (ex) {
return false;
}
return true;
});
await BrowserTestUtils.closeWindow(win);
return persistentStateSupported;
}
add_task(async function test() {
is(await isEmePersistentStateSupported({private: true}),
false,
"EME persistentState should *NOT* be supported in private browsing window.");
is(await isEmePersistentStateSupported({private: false}),
true,
"EME persistentState *SHOULD* be supported in non private browsing window.");
});

Просмотреть файл

@ -0,0 +1,230 @@
/* import-globals-from ../head.js */
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir;
const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
var gNextTest = null;
var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
ChromeUtils.import("resource://gre/modules/Services.jsm");
var gPrivateWindow = null;
var gPrivateBrowser = null;
function finishTest() {
clearAllPluginPermissions();
gBrowser.removeCurrentTab();
if (gPrivateWindow) {
gPrivateWindow.close();
}
window.focus();
}
let createPrivateWindow = async function createPrivateWindow(url) {
gPrivateWindow = await BrowserTestUtils.openNewBrowserWindow({private: true});
ok(!!gPrivateWindow, "should have created a private window.");
gPrivateBrowser = gPrivateWindow.getBrowser().selectedBrowser;
BrowserTestUtils.loadURI(gPrivateBrowser, url);
await BrowserTestUtils.browserLoaded(gPrivateBrowser, false, url);
info("loaded " + url);
};
add_task(async function test() {
registerCleanupFunction(function() {
clearAllPluginPermissions();
getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_ENABLED;
getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_ENABLED;
});
let newTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
let promise = BrowserTestUtils.browserLoaded(gTestBrowser);
Services.prefs.setBoolPref("plugins.click_to_play", true);
getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
await promise;
});
add_task(async function test1a() {
await createPrivateWindow(gHttpTestRoot + "plugin_test.html");
});
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");
});
// Check the button status
let promiseShown = BrowserTestUtils.waitForEvent(gPrivateWindow.PopupNotifications.panel,
"Shown");
popupNotification.reshow();
await promiseShown;
is(gPrivateWindow.PopupNotifications.panel.firstElementChild.checkbox.hidden, true, "'Remember' checkbox should be hidden in private windows");
let promises = [
BrowserTestUtils.browserLoaded(gTestBrowser, false, gHttpTestRoot + "plugin_test.html"),
BrowserTestUtils.waitForEvent(window, "activate"),
];
gPrivateWindow.close();
BrowserTestUtils.loadURI(gTestBrowser, gHttpTestRoot + "plugin_test.html");
await Promise.all(promises);
await SimpleTest.promiseFocus(window);
});
add_task(async function test2a() {
// enable test plugin on this site
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");
});
// 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;
await ContentTaskUtils.waitForCondition(condition, "Test 2a, Waited too long for plugin to activate");
});
});
add_task(async function test2c() {
let topicObserved = TestUtils.topicObserved("PopupNotifications-updateNotShowing");
await createPrivateWindow(gHttpTestRoot + "plugin_test.html");
await topicObserved;
let popupNotification = gPrivateWindow.PopupNotifications.getNotification("click-to-play-plugins", gPrivateBrowser);
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");
});
// Check the button status
let promiseShown = BrowserTestUtils.waitForEvent(gPrivateWindow.PopupNotifications.panel,
"Shown");
popupNotification.reshow();
await promiseShown;
is(gPrivateWindow.PopupNotifications.panel.firstElementChild.secondaryButton.hidden, true,
"Test 2c, Activated plugin in a private window should not have visible 'Block' button.");
is(gPrivateWindow.PopupNotifications.panel.firstElementChild.checkbox.hidden, true,
"Test 2c, Activated plugin in a private window should not have visible 'Remember' checkbox.");
clearAllPluginPermissions();
let promises = [
BrowserTestUtils.browserLoaded(gTestBrowser, false, gHttpTestRoot + "plugin_test.html"),
BrowserTestUtils.waitForEvent(window, "activate"),
];
gPrivateWindow.close();
BrowserTestUtils.loadURI(gTestBrowser, gHttpTestRoot + "plugin_test.html");
await Promise.all(promises);
await SimpleTest.promiseFocus(window);
});
add_task(async function test3a() {
// enable test plugin on this site
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");
});
// 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;
await ContentTaskUtils.waitForCondition(condition, "Test 3a, Waited too long for plugin to activate");
});
});
add_task(async function test3c() {
let topicObserved = TestUtils.topicObserved("PopupNotifications-updateNotShowing");
await createPrivateWindow(gHttpTestRoot + "plugin_test.html");
await topicObserved;
let popupNotification = gPrivateWindow.PopupNotifications.getNotification("click-to-play-plugins", gPrivateBrowser);
ok(popupNotification, "Test 3c, Should have a click-to-play notification");
// Check the button status
let promiseShown = BrowserTestUtils.waitForEvent(gPrivateWindow.PopupNotifications.panel,
"Shown");
popupNotification.reshow();
await promiseShown;
is(gPrivateWindow.PopupNotifications.panel.firstElementChild.secondaryButton.hidden, true,
"Test 2c, Activated plugin in a private window should not have visible 'Block' button.");
is(gPrivateWindow.PopupNotifications.panel.firstElementChild.checkbox.hidden, true,
"Test 2c, Activated plugin in a private window should not have visible 'Remember' checkbox.");
BrowserTestUtils.loadURI(gPrivateBrowser, gHttpTestRoot + "plugin_two_types.html");
await BrowserTestUtils.browserLoaded(gPrivateBrowser);
});
add_task(async function test3d() {
let popupNotification = gPrivateWindow.PopupNotifications.getNotification("click-to-play-plugins", gPrivateBrowser);
ok(popupNotification, "Test 3d, Should have a click-to-play notification");
// Check the list item status
let promiseShown = BrowserTestUtils.waitForEvent(gPrivateWindow.PopupNotifications.panel,
"Shown");
popupNotification.reshow();
await promiseShown;
let doc = gPrivateWindow.document;
for (let item of gPrivateWindow.PopupNotifications.panel.firstElementChild.children) {
let allowalways = doc.getAnonymousElementByAttribute(item, "anonid", "allowalways");
ok(allowalways, "Test 3d, should have list item for allow always");
let allownow = doc.getAnonymousElementByAttribute(item, "anonid", "allownow");
ok(allownow, "Test 3d, should have list item for allow now");
let block = doc.getAnonymousElementByAttribute(item, "anonid", "block");
ok(block, "Test 3d, should have list item for block");
if (item.action.pluginName === "Test") {
is(item.value, "allowalways", "Test 3d, Plugin should bet set to 'allow always'");
ok(!allowalways.hidden, "Test 3d, Plugin set to 'always allow' should have a visible 'always allow' action.");
ok(allownow.hidden, "Test 3d, Plugin set to 'always allow' should have an invisible 'allow now' action.");
ok(block.hidden, "Test 3d, Plugin set to 'always allow' should have an invisible 'block' action.");
} else if (item.action.pluginName === "Second Test") {
is(item.value, "block", "Test 3d, Second plugin should bet set to 'block'");
ok(allowalways.hidden, "Test 3d, Plugin set to 'block' should have a visible 'always allow' action.");
ok(!allownow.hidden, "Test 3d, Plugin set to 'block' should have a visible 'allow now' action.");
ok(!block.hidden, "Test 3d, Plugin set to 'block' should have a visible 'block' action.");
} else {
ok(false, "Test 3d, Unexpected plugin '" + item.action.pluginName + "'");
}
}
finishTest();
});

Просмотреть файл

@ -0,0 +1,74 @@
/* import-globals-from ../head.js */
"use strict";
const TEST_PLUGIN_NAME = "Test Plug-in";
const HIDDEN_CTP_PLUGIN_PREF = "plugins.navigator.hidden_ctp_plugin";
const DOMAIN_1 = "http://example.com";
const DOMAIN_2 = "http://mochi.test:8888";
/**
* If a plugin is click-to-play and named in HIDDEN_CTP_PLUGIN_PREF,
* then the plugin should be hidden in the navigator.plugins list by
* default. However, if a plugin has been allowed on a top-level
* document, we should let subframes of that document access
* navigator.plugins.
*/
add_task(async function setup() {
// We'll make the Test Plugin click-to-play.
let originalPluginState = getTestPluginEnabledState();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
registerCleanupFunction(() => {
setTestPluginEnabledState(originalPluginState);
clearAllPluginPermissions();
});
// And then make the plugin hidden.
await SpecialPowers.pushPrefEnv({
set: [[HIDDEN_CTP_PLUGIN_PREF, TEST_PLUGIN_NAME]],
});
});
add_task(async function test_plugin_accessible_in_subframe() {
// Let's make it so that DOMAIN_1 allows the test plugin to
// be activated. This permission will be cleaned up inside
// our registerCleanupFunction when the test ends.
let ssm = Services.scriptSecurityManager;
let principal = ssm.createCodebasePrincipalFromOrigin(DOMAIN_1);
let pluginHost = Cc["@mozilla.org/plugin/host;1"]
.getService(Ci.nsIPluginHost);
let permString = pluginHost.getPermissionStringForType("application/x-test");
Services.perms.addFromPrincipal(principal, permString,
Ci.nsIPermissionManager.ALLOW_ACTION,
Ci.nsIPermissionManager.EXPIRE_NEVER,
0 /* expireTime */);
await BrowserTestUtils.withNewTab({
gBrowser,
url: DOMAIN_1,
}, async function(browser) {
await ContentTask.spawn(browser, [TEST_PLUGIN_NAME, DOMAIN_2],
async function([pluginName, domain2]) {
Assert.ok(content.navigator.plugins[pluginName],
"Top-level document should find Test Plugin");
// Now manually create a subframe hosted at domain2...
let subframe = content.document.createElement("iframe");
subframe.src = domain2;
let loadedPromise = ContentTaskUtils.waitForEvent(subframe, "load");
content.document.body.appendChild(subframe);
await loadedPromise;
// Make sure that the HiddenPlugin event never fires in content.
let sawEvent = false;
addEventListener("HiddenPlugin", function onHiddenPlugin(e) {
sawEvent = true;
removeEventListener("HiddenPlugin", onHiddenPlugin, true);
}, true);
Assert.ok(subframe.contentWindow.navigator.plugins[pluginName],
"Subframe should find Test Plugin");
Assert.ok(!sawEvent, "Should not have seen the HiddenPlugin event.");
});
});
});

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
This page is intentionally left blank.
</body>
</html>

Просмотреть файл

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
function addPlugin(aId, aType = "application/x-test") {
var embed = document.createElement("embed");
embed.setAttribute("id", aId);
embed.style.width = "200px";
embed.style.height = "200px";
embed.setAttribute("type", aType);
return document.body.appendChild(embed);
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,9 @@
<!-- bug 739575 -->
<html>
<head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<object id="test" type="application/x-test" style="height: 200px; width:200px">
<p><a href="about:blank">you should not see this link when plugins are click-to-play</a></p>
</object>
</body></html>

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 500px; height: 500px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="unknown" style="width: 100px; height: 100px" type="application/x-unknown">
<embed id="test" style="width: 100px; height: 100px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 100px; height: 100px" type="application/x-test">
<embed id="unknown" style="width: 100px; height: 100px" type="application/x-unknown">
</body>
</html>

Просмотреть файл

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"/></head>
<body>
<style>
.x {
opacity: 0 !important;
}
</style>
<object id="test" class="x" type="application/x-test" width=200 height=200></object>
</body>
</html>

Просмотреть файл

@ -0,0 +1,8 @@
<!-- bug 749455 -->
<html>
<head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<embed src="plugin_bug749455.html" type="application/x-test" width="100px" height="100px"></embed>
</body>
</html>

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"/></head>
<body>
<a id="wrapper">
<embed id="plugin" style="width: 200px; height: 200px" type="application/x-test">
</a>
</body>
</html>

Просмотреть файл

@ -0,0 +1,5 @@
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"/></head>
<body><embed id="plugin" type="9000"></embed></body>
</html>

Просмотреть файл

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"/></head>
<body>
<object id="test" type="application/x-test" width=200 height=200></object>
<script>
function addSecondPlugin() {
var object = document.createElement("object");
object.type = "application/x-second-test";
object.width = 200;
object.height = 200;
object.id = "secondtest";
document.body.appendChild(object);
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 200px; height: 200px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 200px; height: 200px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function crash() {
var plugin = document.getElementById("plugin");
var argStr = decodeURIComponent(window.location.search.substr(1));
if (argStr) {
var args = JSON.parse(argStr);
for (var key in args)
plugin.setAttribute(key, args[key]);
}
try {
plugin.crash();
} catch (err) {}
}
</script>
</head>
<body onload="crash();">
<embed id="plugin" type="application/x-test"
width="400" height="400"
drawmode="solid" color="FF00FFFF">
</embed>
</body>
</html>

Просмотреть файл

@ -0,0 +1,96 @@
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"/></head>
<body>
<style>
.testcase {
display: none;
}
object {
width: 200px;
height: 200px;
}
</style>
<!-- Tests that a <video> tag in the fallback content favors the fallback content -->
<div id="testcase_video" class="testcase">
<object class="expected_ctp" type="application/x-shockwave-flash-test">
Unexpected fallback
</object>
<object class="expected_fallback" type="application/x-shockwave-flash-test">
<video></video>
Expected fallback
</object>
</div>
<!-- Tests that an object with no src specified (no data="") favors the fallback content -->
<div id="testcase_nosrc" class="testcase">
<!-- We must use an existing and valid file here because otherwise the failed load
triggers the plugin's alternate content, indepedent of the favor-fallback code path -->
<object class="expected_ctp" type="application/x-shockwave-flash-test" data="plugin_simple_blank.swf">
Unexpected fallback
</object>
<object class="expected_fallback" type="application/x-shockwave-flash-test">
Expected fallback
</object>
</div>
<!-- Tests that an <embed> tag in the fallback content forces the plugin content,
when fallback is defaulting to true -->
<div id="testcase_embed" class="testcase">
<object class="expected_ctp" type="application/x-shockwave-flash-test">
<embed></embed>
Unexpected fallback
</object>
<object class="expected_fallback" type="application/x-shockwave-flash-test">
Expected fallback
</object>
</div>
<!-- Tests that links to adobe.com inside the fallback content forces the plugin content,
when fallback is defaulting to true -->
<div id="testcase_adobelink" class="testcase">
<object class="expected_ctp" type="application/x-shockwave-flash-test">
<a href="https://www.adobe.com">Go to adobe.com</a>
Unexpected fallback
</object>
<object class="expected_ctp" type="application/x-shockwave-flash-test">
<a href="https://adobe.com">Go to adobe.com</a>
Unexpected fallback
</object>
<object class="expected_fallback" type="application/x-shockwave-flash-test">
Expected fallback
</object>
</div>
<!-- Tests that instructions to download or install flash inside the fallback content
forces the plugin content, when fallback is defaulting to true -->
<div id="testcase_installinstructions" class="testcase">
<object class="expected_ctp" type="application/x-shockwave-flash-test">
Install -- Unexpected fallback
</object>
<object class="expected_ctp" type="application/x-shockwave-flash-test">
Flash -- Unexpected fallback
</object>
<object class="expected_ctp" type="application/x-shockwave-flash-test">
Download -- Unexpected fallback
</object>
<object class="expected_fallback" type="application/x-shockwave-flash-test">
<!-- Tests that the words Install, Flash or Download do not trigger
this behavior if it's just inside a comment, and not part of
the text content -->
Expected Fallback
</object>
<object class="expected_fallback" type="application/x-shockwave-flash-test">
Expected fallback
</object>
</div>
<script>
let queryString = location.search;
let match = /^\?testcase=([a-z]+)$/.exec(queryString);
let testcase = match[1];
document.getElementById(`testcase_${testcase}`).style.display = "block";
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="container" style="display: none">
<object id="test" type="application/x-test" style="width: 200px; height: 200px;"></object>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<iframe id="frame" with="400" height="400" src="plugin_test.html">
</body>
</html>

Просмотреть файл

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
#container {
position: fixed;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
background: blue;
}
#test {
width: 400px;
height: 400px;
position: absolute;
}
</style>
</head>
<body>
<div id="container"></div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="testcase1" class="testcase">
<object width="10" height="10" type="application/x-test"></object>
</div>
<div id="testcase2" class="testcase">
<object width="40" height="40" type="application/x-test"></object>
</div>
<div id="testcase3" class="testcase">
<object width="100" height="70" type="application/x-test"></object>
</div>
<div id="testcase4" class="testcase">
<object width="200" height="200" type="application/x-test"></object>
</div>
<div id="testcase5" class="testcase">
<object width="300" height="300" type="application/x-test"></object>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,116 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
object {
width: 200px;
height: 200px;
}
.testcase {
position: relative;
margin-bottom: 5px;
}
.cover {
position: absolute;
width: 20px;
height: 20px;
background-color: green;
}
</style>
</head>
<body>
<div id="testcase1" class="testcase" shouldshow="true"
style="top: -100px">
<!-- Should show overlay even though the top part is outside
of the page. -->
<object type="application/x-test"></object>
</div>
<div id="testcase2" class="testcase" shouldshow="true"
style="left: -100px">
<!-- Should show overlay even though the left part is outside
of the page. -->
<object type="application/x-test"></object>
</div>
<div id="testcase3" class="testcase" shouldshow="false"
style="left: -210px">
<!-- The object is entirely outside of the page, so the overlay
should NOT show. -->
<object type="application/x-test"></object>
</div>
<div id="testcase4" class="testcase" shouldshow="true">
<!-- Should show overlay even though the top-left corner is covered. -->
<div class="cover" style="top: 0; left: 0"></div>
<object type="application/x-test"></object>
</div>
<div id="testcase5" class="testcase" shouldshow="true">
<!-- Should show overlay even though the top-right corner is covered. -->
<div class="cover" style="top: 0; left: 180px"></div>
<object type="application/x-test"></object>
</div>
<div id="testcase6" class="testcase" shouldshow="true">
<!-- Should show overlay even though the bottom-left corner is covered. -->
<div class="cover" style="top: 180px; left: 0"></div>
<object type="application/x-test"></object>
</div>
<div id="testcase7" class="testcase" shouldshow="true">
<!-- Should show overlay even though the bottom-right corner is covered. -->
<div class="cover" style="top: 180px; left: 180px"></div>
<object type="application/x-test"></object>
</div>
<div id="testcase8" class="testcase" shouldshow="true">
<!-- Should show overlay even though the center is covered. -->
<div class="cover" style="top: 90px; left: 90px"></div>
<object type="application/x-test"></object>
</div>
<div id="testcase9" class="testcase" shouldshow="true">
<!-- Should show overlay even though multiple points are covered,
but not all of them. -->
<div class="cover" style="top: 0; left: 0"></div>
<div class="cover" style="top: 0; left: 180px"></div>
<div class="cover" style="top: 180px; left: 0"></div>
<div class="cover" style="top: 180px; left: 180px"></div>
<object type="application/x-test"></object>
</div>
<div id="testcase10" class="testcase" shouldshow="true">
<!-- Another case where 4 are covered, but not all. -->
<div class="cover" style="top: 90px; left: 90px"></div>
<div class="cover" style="top: 0; left: 180px"></div>
<div class="cover" style="top: 180px; left: 0"></div>
<div class="cover" style="top: 180px; left: 180px"></div>
<object type="application/x-test"></object>
</div>
<div id="testcase11" class="testcase" shouldshow="false">
<!-- All corners and center are covered here, so in this
case the overlay should NOT show. -->
<div class="cover" style="top: 0; left: 0"></div>
<div class="cover" style="top: 0; left: 180px"></div>
<div class="cover" style="top: 180px; left: 0"></div>
<div class="cover" style="top: 180px; left: 180px"></div>
<div class="cover" style="top: 90px; left: 90px"></div>
<object type="application/x-test"></object>
</div>
<div id="testcase12" class="testcase" shouldshow="false">
<!-- All corners and center are covered here, by a single
element. In this case the overlay should NOT show. -->
<div class="cover" style="width: 200px; height:200px"></div>
<object type="application/x-test"></object>
</div>
</body>
</html>

Двоичные данные
browser/base/content/test/plugins/xbl/plugin_simple_blank.swf Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 10px; height: 10px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 10px; height: 10px" type="application/x-second-test">
</body>
</html>

Просмотреть файл

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<body>
<script type="text/javascript">
// create an embed, insert it in the doc and immediately remove it
var embed = document.createElement("embed");
embed.setAttribute("id", "test");
embed.setAttribute("type", "application/x-test");
embed.setAttribute("style", "width: 0px; height: 0px;");
document.body.appendChild(embed);
window.getComputedStyle(embed).top;
document.body.remove(embed);
</script>

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 300px; height: 300px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test1" style="width: 200px; height: 200px" type="application/x-test">
<embed id="test2" style="width: 200px; height: 200px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 0px; height: 0px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"/></head>
<body>
<embed id="test" style="width: 200px; height: 200px" type="application/x-test"/>
<embed id="secondtestA" style="width: 200px; height: 200px" type="application/x-second-test"/>
<embed id="secondtestB" style="width: 200px; height: 200px" type="application/x-second-test"/>
</body>
</html>

Просмотреть файл

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="unknown" style="width: 100px; height: 100px" type="application/x-unknown">
</body>
</html>

Просмотреть файл

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<!-- The odd width and height are here to trigger bug 972237. -->
<embed id="test" style="width: 99.789%; height: 99.123%" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -37,6 +37,7 @@ BROWSER_CHROME_MANIFESTS += [
'content/test/performance/lowdpi/browser.ini',
'content/test/permissions/browser.ini',
'content/test/plugins/browser.ini',
'content/test/plugins/xbl/browser.ini',
'content/test/popupNotifications/browser.ini',
'content/test/popups/browser.ini',
'content/test/referrer/browser.ini',

Просмотреть файл

@ -605,6 +605,7 @@ nsObjectLoadingContent::BindToTree(nsIDocument* aDocument,
if (aDocument) {
aDocument->AddPlugin(this);
}
return NS_OK;
}
@ -634,6 +635,21 @@ nsObjectLoadingContent::UnbindFromTree(bool aDeep, bool aNullParent)
/// would keep the docshell around, but trash the frameloader
UnloadObject();
}
// Unattach plugin problem UIWidget if any.
if (thisElement->IsInComposedDoc() && thisElement->GetShadowRoot()) {
nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
"nsObjectLoadingContent::UnbindFromTree::UAWidgetUnbindFromTree",
[thisElement]() {
nsContentUtils::DispatchChromeEvent(
thisElement->OwnerDoc(), thisElement,
NS_LITERAL_STRING("UAWidgetUnbindFromTree"),
CanBubble::eYes, Cancelable::eNo);
thisElement->UnattachShadow();
})
);
}
if (mType == eType_Plugin) {
nsIDocument* doc = thisElement->GetComposedDoc();
if (doc && doc->IsActive()) {
@ -2632,25 +2648,23 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
" (sync %i, notify %i)", this, aOldType, aOldState.GetInternalValue(),
mType, ObjectState().GetInternalValue(), aSync, aNotify));
nsCOMPtr<nsIContent> thisContent =
nsCOMPtr<dom::Element> thisEl =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
NS_ASSERTION(thisContent, "must be a content");
NS_ASSERTION(thisContent->IsElement(), "Not an element?");
MOZ_ASSERT(thisEl, "must be an element");
// XXX(johns): A good bit of the code below replicates UpdateState(true)
// Unfortunately, we do some state changes without notifying
// (e.g. in Fallback when canceling image requests), so we have to
// manually notify object state changes.
thisContent->AsElement()->UpdateState(false);
thisEl->UpdateState(false);
if (!aNotify) {
// We're done here
return;
}
nsIDocument* doc = thisContent->GetComposedDoc();
nsIDocument* doc = thisEl->GetComposedDoc();
if (!doc) {
return; // Nothing to do
}
@ -2662,24 +2676,59 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
}
if (newState != aOldState) {
NS_ASSERTION(thisContent->IsInComposedDoc(), "Something is confused");
MOZ_ASSERT(thisEl->IsInComposedDoc(), "Something is confused");
// This will trigger frame construction
EventStates changedBits = aOldState ^ newState;
{
nsAutoScriptBlocker scriptBlocker;
doc->ContentStateChanged(thisContent, changedBits);
doc->ContentStateChanged(thisEl, changedBits);
}
// Create/destroy plugin problem UAWidget if needed.
if (nsContentUtils::IsUAWidgetEnabled()) {
const EventStates pluginProblemState =
NS_EVENT_STATE_HANDLER_BLOCKED |
NS_EVENT_STATE_HANDLER_CRASHED |
NS_EVENT_STATE_TYPE_CLICK_TO_PLAY |
NS_EVENT_STATE_VULNERABLE_UPDATABLE |
NS_EVENT_STATE_VULNERABLE_NO_UPDATE;
bool hadProblemState = !(aOldState & pluginProblemState).IsEmpty();
bool hasProblemState = !(newState & pluginProblemState).IsEmpty();
if (hadProblemState && !hasProblemState) {
nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
"nsObjectLoadingContent::UnbindFromTree::UAWidgetUnbindFromTree",
[thisEl]() {
nsContentUtils::DispatchChromeEvent(
thisEl->OwnerDoc(), thisEl,
NS_LITERAL_STRING("UAWidgetUnbindFromTree"),
CanBubble::eYes, Cancelable::eNo);
thisEl->UnattachShadow();
})
);
} else if (!hadProblemState && hasProblemState) {
nsGenericHTMLElement::FromNode(thisEl)->AttachAndSetUAShadowRoot();
AsyncEventDispatcher* dispatcher =
new AsyncEventDispatcher(thisEl,
NS_LITERAL_STRING("UAWidgetBindToTree"),
CanBubble::eYes,
ChromeOnlyDispatch::eYes);
dispatcher->RunDOMEventWhenSafe();
}
}
} else if (aOldType != mType) {
// If our state changed, then we already recreated frames
// Otherwise, need to do that here
nsCOMPtr<nsIPresShell> shell = doc->GetShell();
if (shell) {
shell->PostRecreateFramesFor(thisContent->AsElement());
shell->PostRecreateFramesFor(thisEl);
}
}
if (aSync) {
NS_ASSERTION(InActiveDocument(thisContent), "Something is confused");
MOZ_ASSERT(InActiveDocument(thisEl), "Something is confused");
// Make sure that frames are actually constructed immediately.
doc->FlushPendingNotifications(FlushType::Frames);
}

Просмотреть файл

@ -117,7 +117,8 @@ function onPluginCrashed(aEvent) {
let submitButton = document.getAnonymousElementByAttribute(aEvent.target,
"class",
"submitButton");
"submitButton") ||
aEvent.target.openOrClosedShadowRoot.getElementById("submitButton");
// try to submit this report
sendMouseEvent({type:'click'}, submitButton, window);
}

Просмотреть файл

@ -121,7 +121,8 @@ function onPluginCrashed(aEvent) {
let submitButton = document.getAnonymousElementByAttribute(aEvent.target,
"class",
"submitButton");
"submitButton") ||
aEvent.target.openOrClosedShadowRoot.getElementById("submitButton");
// try to submit this report
sendMouseEvent({type:'click'}, submitButton, window);
}

Просмотреть файл

@ -56,10 +56,10 @@ class UAWidgetsChild extends ActorChild {
uri = "chrome://global/content/elements/datetimebox.js";
widgetName = "DateTimeBoxWidget";
break;
case "applet":
case "embed":
case "object":
// TODO (pluginProblems)
uri = "chrome://global/content/elements/pluginProblem.js";
widgetName = "PluginProblemWidget";
break;
case "marquee":
uri = "chrome://global/content/elements/marquee.js";

Просмотреть файл

@ -97,6 +97,7 @@ toolkit.jar:
content/global/elements/editor.js (widgets/editor.js)
content/global/elements/general.js (widgets/general.js)
content/global/elements/notificationbox.js (widgets/notificationbox.js)
content/global/elements/pluginProblem.js (widgets/pluginProblem.js)
content/global/elements/radio.js (widgets/radio.js)
content/global/elements/marquee.css (widgets/marquee.css)
content/global/elements/marquee.js (widgets/marquee.js)

Просмотреть файл

@ -0,0 +1,80 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// This is a UA Widget. It runs in per-origin UA widget scope,
// to be loaded by UAWidgetsChild.jsm.
this.PluginProblemWidget = class {
constructor(shadowRoot) {
this.shadowRoot = shadowRoot;
this.element = shadowRoot.host;
// ownerGlobal is chrome-only, not accessible to UA Widget script here.
this.window = this.element.ownerDocument.defaultView; // eslint-disable-line mozilla/use-ownerGlobal
const parser = new this.window.DOMParser();
let parserDoc = parser.parseFromString(`
<!DOCTYPE bindings [
<!ENTITY % pluginproblemDTD SYSTEM "chrome://pluginproblem/locale/pluginproblem.dtd">
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%pluginproblemDTD;
%globalDTD;
%brandDTD;
]>
<div xmlns="http://www.w3.org/1999/xhtml" class="mainBox" id="main" chromedir="&locale.dir;">
<link rel="stylesheet" type="text/css" href="chrome://pluginproblem/content/pluginProblemContent.css" />
<link rel="stylesheet" type="text/css" href="chrome://global/skin/plugins/pluginProblem.css" />
<div class="hoverBox">
<label>
<button class="icon" id="icon"/>
<div class="msg msgVulnerabilityStatus" id="vulnerabilityStatus"><!-- set at runtime --></div>
<div class="msg msgTapToPlay">&tapToPlayPlugin;</div>
<div class="msg msgClickToPlay" id="clickToPlay">&clickToActivatePlugin;</div>
</label>
<div class="msg msgBlocked">&blockedPlugin.label;</div>
<div class="msg msgCrashed">
<div class="msgCrashedText" id="crashedText"><!-- set at runtime --></div>
<!-- link href set at runtime -->
<div class="msgReload">&reloadPlugin.pre;<a class="reloadLink" id="reloadLink" href="">&reloadPlugin.middle;</a>&reloadPlugin.post;</div>
</div>
<div class="msg msgManagePlugins"><a class="action-link" id="managePluginsLink" href="">&managePlugins;</a></div>
<div class="submitStatus" id="submitStatus">
<div class="msg msgPleaseSubmit" id="pleaseSubmit">
<textarea class="submitComment"
id="submitComment"
placeholder="&report.comment;"/>
<div class="submitURLOptInBox">
<label><input class="submitURLOptIn" id="submitURLOptIn" type="checkbox"/> &report.pageURL;</label>
</div>
<div class="submitButtonBox">
<span class="helpIcon" id="helpIcon" role="link"/>
<input class="submitButton" type="button"
id="submitButton"
value="&report.please;"/>
</div>
</div>
<div class="msg msgSubmitting">&report.submitting;<span class="throbber"> </span></div>
<div class="msg msgSubmitted">&report.submitted;</div>
<div class="msg msgNotSubmitted">&report.disabled;</div>
<div class="msg msgSubmitFailed">&report.failed;</div>
<div class="msg msgNoCrashReport">&report.unavailable;</div>
</div>
<div class="msg msgCheckForUpdates"><a class="action-link" id="checkForUpdatesLink" href="">&checkForUpdates;</a></div>
</div>
<button class="closeIcon" id="closeIcon" title="&hidePluginBtn.label;"/>
</div>
`, "application/xml");
this.shadowRoot.importNodeAndAppendChildAt(this.shadowRoot,
parserDoc.documentElement, true);
// Notify browser-plugins.js that we were attached, on a delay because
// this binding doesn't complete layout until the constructor
// completes.
this.element.dispatchEvent(new this.window.CustomEvent("PluginBindingAttached"));
}
};

Просмотреть файл

@ -24,6 +24,15 @@ function resetBlocklist(aCallback) {
Services.prefs.setCharPref("extensions.blocklist.url", _originalBlocklistURL);
}
function getPluginUI(plugin, anonid) {
if (plugin.openOrClosedShadowRoot &&
plugin.openOrClosedShadowRoot.isUAWidget()) {
return plugin.openOrClosedShadowRoot.getElementById(anonid);
}
return plugin.ownerDocument.
getAnonymousElementByAttribute(plugin, "anonid", anonid);
}
add_task(async function() {
SpecialPowers.pushPrefEnv({"set": [
["plugins.click_to_play", true],
@ -58,13 +67,13 @@ add_task(async function() {
let pluginEl = get_addon_element(managerWindow, testPluginId);
pluginEl.parentNode.ensureElementIsVisible(pluginEl);
let enableButton = managerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "enable-btn");
let enableButton = getPluginUI(pluginEl, "enable-btn");
is_element_hidden(enableButton, "part3: enable button should not be visible");
let disableButton = managerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "disable-btn");
let disableButton = getPluginUI(pluginEl, "disable-btn");
is_element_hidden(disableButton, "part3: disable button should not be visible");
let menu = managerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "state-menulist");
let menu = getPluginUI(pluginEl, "state-menulist");
is_element_visible(menu, "part3: state menu should be visible");
let askToActivateItem = managerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "ask-to-activate-menuitem");
let askToActivateItem = getPluginUI(pluginEl, "ask-to-activate-menuitem");
is(menu.selectedItem, askToActivateItem, "part3: state menu should have 'Ask To Activate' selected");
let pluginTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, gHttpTestRoot + "plugin_test.html");
@ -75,7 +84,7 @@ add_task(async function() {
BrowserTestUtils.removeTab(pluginTab);
let alwaysActivateItem = managerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "always-activate-menuitem");
let alwaysActivateItem = getPluginUI(pluginEl, "always-activate-menuitem");
menu.selectedItem = alwaysActivateItem;
alwaysActivateItem.doCommand();
@ -92,7 +101,7 @@ add_task(async function() {
BrowserTestUtils.removeTab(pluginTab);
let neverActivateItem = managerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "never-activate-menuitem");
let neverActivateItem = getPluginUI(pluginEl, "never-activate-menuitem");
menu.selectedItem = neverActivateItem;
neverActivateItem.doCommand();
@ -156,7 +165,7 @@ add_task(async function() {
pluginEl = get_addon_element(managerWindow, testPluginId);
pluginEl.parentNode.ensureElementIsVisible(pluginEl);
menu = managerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "state-menulist");
menu = getPluginUI(pluginEl, "state-menulist");
is(menu.disabled, true, "part12: state menu should be disabled");
EventUtils.synthesizeMouseAtCenter(pluginEl, {}, managerWindow);

Просмотреть файл

@ -9,11 +9,6 @@ embed:-moz-handler-crashed,
embed:-moz-handler-clicktoplay,
embed:-moz-handler-vulnerable-updatable,
embed:-moz-handler-vulnerable-no-update,
applet:-moz-handler-blocked,
applet:-moz-handler-crashed,
applet:-moz-handler-clicktoplay,
applet:-moz-handler-vulnerable-updatable,
applet:-moz-handler-vulnerable-no-update,
object:-moz-handler-blocked,
object:-moz-handler-crashed,
object:-moz-handler-clicktoplay,
@ -22,5 +17,21 @@ object:-moz-handler-vulnerable-no-update {
display: inline-block;
overflow: hidden;
opacity: 1 !important;
-moz-binding: url('chrome://pluginproblem/content/pluginProblem.xml#pluginProblem') !important;
}
@supports not -moz-bool-pref("dom.ua_widget.enabled") {
embed:-moz-handler-blocked,
embed:-moz-handler-crashed,
embed:-moz-handler-clicktoplay,
embed:-moz-handler-vulnerable-updatable,
embed:-moz-handler-vulnerable-no-update,
object:-moz-handler-blocked,
object:-moz-handler-crashed,
object:-moz-handler-clicktoplay,
object:-moz-handler-vulnerable-updatable,
object:-moz-handler-vulnerable-no-update {
-moz-binding: url('chrome://pluginproblem/content/pluginProblem.xml#pluginProblem') !important;
}
}

Просмотреть файл

@ -8,7 +8,8 @@
* browser-plugins.js (near where this file is mentioned). */
html|object:not([width]), html|object[width=""],
html|embed:not([width]), html|embed[width=""],
html|applet:not([width]), html|applet[width=""] {
html|applet:not([width]), html|applet[width=""],
:host(:not([width])), :host([width=""]) {
width: 240px;
}
@ -16,20 +17,29 @@ html|applet:not([width]), html|applet[width=""] {
* browser-plugins.js (near where this file is mentioned). */
html|object:not([height]), html|object[height=""],
html|embed:not([height]), html|embed[height=""],
html|applet:not([height]), html|applet[height=""] {
html|applet:not([height]), html|applet[height=""],
:host(:not([width])), :host([width=""]) {
height: 200px;
}
:-moz-handler-clicktoplay .mainBox,
:-moz-handler-vulnerable-updatable .mainBox,
:-moz-handler-vulnerable-no-update .mainBox,
:-moz-handler-blocked .mainBox {
:-moz-handler-blocked .mainBox,
:host(:-moz-handler-clicktoplay) .mainBox,
:host(:-moz-handler-vulnerable-updatable) .mainBox,
:host(:-moz-handler-vulnerable-no-update) .mainBox,
:host(:-moz-handler-blocked) .mainBox {
-moz-user-focus: normal;
}
:-moz-handler-clicktoplay .mainBox:focus,
:-moz-handler-vulnerable-updatable .mainBox:focus,
:-moz-handler-vulnerable-no-update .mainBox:focus,
:-moz-handler-blocked .mainBox:focus {
:-moz-handler-blocked .mainBox:focus,
:host(:-moz-handler-clicktoplay) .mainBox:focus,
:host(:-moz-handler-vulnerable-updatable) .mainBox:focus,
:host(:-moz-handler-vulnerable-no-update) .mainBox:focus,
:host(:-moz-handler-blocked) .mainBox:focus {
outline: 1px dotted;
}
@ -72,7 +82,10 @@ html|applet:not([height]), html|applet[height=""] {
:-moz-handler-clicktoplay .hoverBox,
:-moz-handler-vulnerable-updatable .hoverBox,
:-moz-handler-vulnerable-no-update .hoverBox {
:-moz-handler-vulnerable-no-update .hoverBox,
:host(:-moz-handler-clicktoplay) .hoverBox,
:host(:-moz-handler-vulnerable-updatable) .hoverBox,
:host(:-moz-handler-vulnerable-no-update) .hoverBox {
cursor: pointer;
}
@ -94,7 +107,15 @@ html|applet:not([height]), html|applet[height=""] {
:-moz-handler-vulnerable-no-update .msgVulnerabilityStatus,
:-moz-handler-vulnerable-no-update .msgClickToPlay,
:-moz-handler-blocked .msgBlocked,
:-moz-handler-crashed .msgCrashed {
:-moz-handler-crashed .msgCrashed,
:host(:-moz-handler-clicktoplay) .msgClickToPlay,
:host(:-moz-handler-vulnerable-updatable) .msgVulnerabilityStatus,
:host(:-moz-handler-vulnerable-updatable) .msgCheckForUpdates,
:host(:-moz-handler-vulnerable-updatable) .msgClickToPlay,
:host(:-moz-handler-vulnerable-no-update) .msgVulnerabilityStatus,
:host(:-moz-handler-vulnerable-no-update) .msgClickToPlay,
:host(:-moz-handler-blocked) .msgBlocked,
:host(:-moz-handler-crashed) .msgCrashed {
display: block;
}

Просмотреть файл

@ -32,19 +32,27 @@
height: 100%;
}
:-moz-handler-vulnerable-updatable .hoverBox:active,
:-moz-handler-vulnerable-no-update .hoverBox:active {
:-moz-handler-vulnerable-no-update .hoverBox:active,
:host(:-moz-handler-vulnerable-updatable) .hoverBox:active,
:host(:-moz-handler-vulnerable-no-update) .hoverBox:active {
background-color: rgb(65, 65, 65);
}
:-moz-handler-vulnerable-updatable .hoverBox:active .msgClickToPlay,
:-moz-handler-vulnerable-no-update .hoverBox:active .msgClickToPlay {
:-moz-handler-vulnerable-no-update .hoverBox:active .msgClickToPlay,
:host(:-moz-handler-vulnerable-updatable) .hoverBox:active .msgClickToPlay,
:host(:-moz-handler-vulnerable-no-update) .hoverBox:active .msgClickToPlay {
color: red;
}
:-moz-handler-vulnerable-updatable .hoverBox,
:-moz-handler-vulnerable-no-update .hoverBox,
:-moz-handler-blocked .hoverBox,
:-moz-handler-crashed .hoverBox {
:-moz-handler-crashed .hoverBox,
:host(:-moz-handler-vulnerable-updatable) .hoverBox,
:host(:-moz-handler-vulnerable-no-update) .hoverBox,
:host(:-moz-handler-blocked) .hoverBox,
:host(:-moz-handler-crashed) .hoverBox {
background-image: url(chrome://global/skin/plugins/contentPluginStripe.png);
}
@ -66,19 +74,24 @@ html|a {
}
:-moz-handler-vulnerable-updatable .icon,
:-moz-handler-vulnerable-no-update .icon {
:-moz-handler-vulnerable-no-update .icon,
:host(:-moz-handler-vulnerable-updatable) .icon,
:host(:-moz-handler-vulnerable-no-update) .icon {
background-image: url(chrome://global/skin/plugins/contentPluginBlocked.png);
-moz-user-focus: normal;
}
:-moz-handler-blocked .icon {
:-moz-handler-blocked .icon,
:host(:-moz-handler-blocked) .icon {
background-image: url(chrome://global/skin/plugins/contentPluginBlocked.png);
}
:-moz-handler-clicktoplay .icon {
:-moz-handler-clicktoplay .icon,
:host(:-moz-handler-clicktoplay) .icon {
background-image: url(chrome://global/skin/plugins/plugin.svg);
fill: var(--grey-10);
-moz-user-focus: normal;
}
:-moz-handler-crashed .icon {
:-moz-handler-crashed .icon,
:host(:-moz-handler-crashed) .icon {
background-image: url(chrome://global/skin/plugins/contentPluginCrashed.png);
}
@ -96,7 +109,8 @@ html|a {
}
/* on desktop, don't ever show the tap-to-play UI: that is for mobile only */
:-moz-handler-clicktoplay .msgTapToPlay {
:-moz-handler-clicktoplay .msgTapToPlay,
:host(:-moz-handler-clicktoplay) .msgTapToPlay {
display: none;
}
@ -190,10 +204,12 @@ html|a {
background-color: rgb(20, 20, 20);
}
:-moz-handler-vulnerable-updatable .action-link {
:-moz-handler-vulnerable-updatable .action-link,
:host(:-moz-handler-vulnerable-updatable) .action-link {
background-color: #a81b0c;
}
:-moz-handler-vulnerable-updatable .action-link:active {
:-moz-handler-vulnerable-updatable .action-link:active,
:host(:-moz-handler-vulnerable-updatable) .action-link:active {
background-color: #801409;
}
@ -204,39 +220,49 @@ html|a {
* redesign for all cases, we can change the CSS directly
* above instead of writing these super-specific rules.
*/
:-moz-handler-clicktoplay .mainBox {
:-moz-handler-clicktoplay .mainBox,
:host(:-moz-handler-clicktoplay) .mainBox {
background-color: var(--grey-70);
}
:-moz-handler-clicktoplay .msgClickToPlay {
:-moz-handler-clicktoplay .msgClickToPlay,
:host(:-moz-handler-clicktoplay) .msgClickToPlay {
font-size: 13px;
}
:-moz-handler-clicktoplay .mainBox[sizing=blank] .hoverBox {
:-moz-handler-clicktoplay .mainBox[sizing=blank] .hoverBox,
:host(:-moz-handler-clicktoplay) .mainBox[sizing=blank] .hoverBox {
visibility: hidden;
}
:-moz-handler-clicktoplay .mainBox[sizing=tiny] .icon {
:-moz-handler-clicktoplay .mainBox[sizing=tiny] .icon,
:host(:-moz-handler-clicktoplay) .mainBox[sizing=tiny] .icon {
width: 16px;
height: 16px;
}
:-moz-handler-clicktoplay .mainBox[sizing=reduced] .icon {
:-moz-handler-clicktoplay .mainBox[sizing=reduced] .icon,
:host(:-moz-handler-clicktoplay) .mainBox[sizing=reduced] .icon {
width: 32px;
height: 32px;
}
:-moz-handler-clicktoplay .mainBox[sizing=blank] .closeIcon,
:-moz-handler-clicktoplay .mainBox[sizing=tiny] .closeIcon,
:-moz-handler-clicktoplay .mainBox[sizing=reduced] .closeIcon {
:-moz-handler-clicktoplay .mainBox[sizing=reduced] .closeIcon,
:host(:-moz-handler-clicktoplay) .mainBox[sizing=blank] .closeIcon,
:host(:-moz-handler-clicktoplay) .mainBox[sizing=tiny] .closeIcon,
:host(:-moz-handler-clicktoplay) .mainBox[sizing=reduced] .closeIcon {
display: none;
}
:-moz-handler-clicktoplay .mainBox[notext] .msgClickToPlay {
:-moz-handler-clicktoplay .mainBox[notext] .msgClickToPlay,
:host(:-moz-handler-clicktoplay) .mainBox[notext] .msgClickToPlay {
display: none;
}
:-moz-handler-clicktoplay .mainBox[notext] .icon {
:-moz-handler-clicktoplay .mainBox[notext] .icon,
:host(:-moz-handler-clicktoplay) .mainBox[notext] .icon {
/* Override a `margin-bottom: 6px` now that .msgClickToPlay
* below the icon is no longer shown, in order to achieve
* a perfect vertical centering of the icon.