forked from mirrors/gecko-dev
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
247 lines
8.6 KiB
JavaScript
247 lines
8.6 KiB
JavaScript
/* 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 = plugin.openOrClosedShadowRoot.getElementById("pleaseSubmit");
|
|
let submitButton = plugin.openOrClosedShadowRoot.getElementById("submitButton");
|
|
// Test that we don't send the URL when urlOptIn is false.
|
|
plugin.openOrClosedShadowRoot.getElementById("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 = plugin.openOrClosedShadowRoot.getElementById("pleaseSubmit");
|
|
let submitButton = plugin.openOrClosedShadowRoot.getElementById("submitButton");
|
|
// Test that we send the URL when urlOptIn is true.
|
|
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");
|
|
});
|
|
|
|
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 = plugin.openOrClosedShadowRoot.getElementById("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;
|
|
}
|