Bug 1153894 - Regression test. r=felipe.

This commit is contained in:
Mike Conley 2015-04-13 12:10:33 -04:00
parent 0620c84472
commit ee14423b5c

View File

@ -4,6 +4,7 @@
const SERVER_URL = "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs";
const PLUGIN_PAGE = getRootDirectory(gTestPath) + "plugin_big.html";
const PLUGIN_SMALL_PAGE = getRootDirectory(gTestPath) + "plugin_small.html";
/**
* Takes an nsIPropertyBag and converts it into a JavaScript Object. It
@ -35,11 +36,7 @@ function promisePopupNotificationShown(notificationID) {
});
}
/**
* Test that plugin crash submissions still work properly after
* click-to-play activation.
*/
add_task(function*() {
add_task(function* setup() {
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
// The test harness sets MOZ_CRASHREPORTER_NO_REPORT, which disables plugin
@ -58,7 +55,13 @@ add_task(function*() {
env.set("MOZ_CRASHREPORTER_NO_REPORT", noReport);
env.set("MOZ_CRASHREPORTER_URL", serverURL);
});
});
/**
* Test that plugin crash submissions still work properly after
* click-to-play activation.
*/
add_task(function*() {
yield BrowserTestUtils.withNewTab({
gBrowser,
url: PLUGIN_PAGE,
@ -164,3 +167,81 @@ add_task(function*() {
"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(function*() {
yield BrowserTestUtils.withNewTab({
gBrowser,
url: PLUGIN_SMALL_PAGE,
}, function* (browser) {
let activated = yield ContentTask.spawn(browser, null, function*() {
let plugin = content.document.getElementById("test");
return plugin.QueryInterface(Ci.nsIObjectLoadingContent).activated;
});
ok(!activated, "Plugin should not be activated");
// Open up the click-to-play notification popup...
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins",
browser);
ok(popupNotification, "Should have a click-to-play notification");
yield promisePopupNotificationShown(popupNotification);
// The primary button in the popup should activate the plugin.
PopupNotifications.panel.firstChild._primaryButton.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);
yield ContentTask.spawn(browser, null, function*() {
let plugin = content.document.getElementById("test");
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
yield ContentTaskUtils.waitForCondition(() => {
return plugin.activated;
}, "Waited too long for plugin to activate.");
try {
plugin.crash();
} catch(e) {}
});
// Wait for the notification bar to be displayed.
let notification = yield 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, data] = yield 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.nsILocalFile);
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");
});
});