mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1245723 - Make crashreporter browser-chrome tests e10s compatible. r=felipe
This commit is contained in:
parent
eb30538c24
commit
f51c08046b
@ -3,8 +3,6 @@ support-files =
|
||||
head.js
|
||||
crashreport.sjs
|
||||
|
||||
skip-if = e10s # Bug 929045 - [tracking] e10s support for Crash Reporting
|
||||
|
||||
[browser_aboutCrashes.js]
|
||||
[browser_aboutCrashesResubmit.js]
|
||||
[browser_bug471404.js]
|
||||
|
@ -3,8 +3,7 @@ function cleanup_and_finish() {
|
||||
cleanup_fake_appdir();
|
||||
} catch(ex) {}
|
||||
Services.prefs.clearUserPref("breakpad.reportURL");
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
finish();
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab).then(finish);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -12,9 +11,11 @@ function cleanup_and_finish() {
|
||||
*
|
||||
* Check that the list of crashes displayed by about:crashes matches
|
||||
* the list of crashes that we placed in the pending+submitted directories.
|
||||
*
|
||||
* NB: This function is run in the child process via ContentTask.spawn.
|
||||
*/
|
||||
function check_crash_list(tab, crashes) {
|
||||
let doc = gBrowser.getBrowserForTab(tab).contentDocument;
|
||||
function check_crash_list(crashes) {
|
||||
let doc = content.document;
|
||||
let crashlinks = doc.getElementById("tbody").getElementsByTagName("a");
|
||||
is(crashlinks.length, crashes.length,
|
||||
"about:crashes lists correct number of crash reports");
|
||||
@ -46,27 +47,33 @@ function check_submit_pending(tab, crashes) {
|
||||
let CrashID = null;
|
||||
let CrashURL = null;
|
||||
function csp_onload() {
|
||||
if (browser.contentWindow.location != 'about:crashes') {
|
||||
browser.removeEventListener("load", csp_onload, true);
|
||||
// loaded the crash report page
|
||||
ok(true, 'got submission onload');
|
||||
// loaded the crash report page
|
||||
ok(true, 'got submission onload');
|
||||
|
||||
ContentTask.spawn(browser, null, function() {
|
||||
// grab the Crash ID here to verify later
|
||||
CrashID = browser.contentWindow.location.search.split("=")[1];
|
||||
CrashURL = browser.contentWindow.location.toString();
|
||||
let CrashID = content.location.search.split("=")[1];
|
||||
let CrashURL = content.location.toString();
|
||||
|
||||
// check the JSON content vs. what we submitted
|
||||
let result = JSON.parse(browser.contentDocument.documentElement.textContent);
|
||||
let result = JSON.parse(content.document.documentElement.textContent);
|
||||
is(result.upload_file_minidump, "MDMP", "minidump file sent properly");
|
||||
is(result.memory_report, "Let's pretend this is a memory report",
|
||||
"memory report sent properly");
|
||||
is(result.Throttleable, 0, "correctly sent as non-throttleable");
|
||||
is(+result.Throttleable, 0, "correctly sent as non-throttleable");
|
||||
// we checked these, they're set by the submission process,
|
||||
// so they won't be in the "extra" data.
|
||||
delete result.upload_file_minidump;
|
||||
delete result.memory_report;
|
||||
delete result.Throttleable;
|
||||
|
||||
return { id: CrashID, url: CrashURL, result };
|
||||
}).then(({ id, url, result }) => {
|
||||
// Likewise, this is discarded before it gets to the server
|
||||
delete SubmittedCrash.extra.ServerURL;
|
||||
|
||||
CrashID = id;
|
||||
CrashURL = url;
|
||||
for(let x in result) {
|
||||
if (x in SubmittedCrash.extra)
|
||||
is(result[x], SubmittedCrash.extra[x],
|
||||
@ -78,12 +85,13 @@ function check_submit_pending(tab, crashes) {
|
||||
if (!(y in result))
|
||||
ok(false, "property " + y + " missing from result data!");
|
||||
}
|
||||
executeSoon(function() {
|
||||
browser.addEventListener("pageshow", csp_pageshow, true);
|
||||
// now navigate back
|
||||
browser.goBack();
|
||||
});
|
||||
}
|
||||
|
||||
// NB: Despite appearances, this doesn't use a CPOW.
|
||||
BrowserTestUtils.waitForEvent(browser, "pageshow", true).then(csp_pageshow);
|
||||
|
||||
// now navigate back
|
||||
browser.goBack();
|
||||
});
|
||||
}
|
||||
function csp_fail() {
|
||||
browser.removeEventListener("CrashSubmitFailed", csp_fail, true);
|
||||
@ -91,17 +99,15 @@ function check_submit_pending(tab, crashes) {
|
||||
cleanup_and_finish();
|
||||
}
|
||||
browser.addEventListener("CrashSubmitFailed", csp_fail, true);
|
||||
browser.addEventListener("load", csp_onload, true);
|
||||
BrowserTestUtils.browserLoaded(browser, false, (url) => url !== "about:crashes").then(csp_onload);
|
||||
function csp_pageshow() {
|
||||
browser.removeEventListener("pageshow", csp_pageshow, true);
|
||||
executeSoon(function () {
|
||||
is(browser.contentWindow.location, "about:crashes", "navigated back successfully");
|
||||
let link = browser.contentDocument.getElementById(CrashID);
|
||||
ContentTask.spawn(browser, { CrashID, CrashURL }, function({ CrashID, CrashURL }) {
|
||||
is(content.location.href, "about:crashes", "navigated back successfully");
|
||||
let link = content.document.getElementById(CrashID);
|
||||
isnot(link, null, "crash report link changed correctly");
|
||||
if (link)
|
||||
is(link.href, CrashURL, "crash report link points to correct href");
|
||||
cleanup_and_finish();
|
||||
});
|
||||
}).then(cleanup_and_finish);
|
||||
}
|
||||
|
||||
// try submitting the pending report
|
||||
@ -111,8 +117,11 @@ function check_submit_pending(tab, crashes) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
EventUtils.sendMouseEvent({type:'click'}, SubmittedCrash.id,
|
||||
browser.contentWindow);
|
||||
|
||||
ContentTask.spawn(browser, SubmittedCrash.id, function(id) {
|
||||
let link = content.document.getElementById(id);
|
||||
link.click();
|
||||
});
|
||||
}
|
||||
|
||||
function test() {
|
||||
@ -136,14 +145,8 @@ function test() {
|
||||
Services.prefs.setCharPref("breakpad.reportURL",
|
||||
"http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs?id=");
|
||||
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
browser.addEventListener("load", function test_load() {
|
||||
browser.removeEventListener("load", test_load, true);
|
||||
executeSoon(function () {
|
||||
check_crash_list(tab, crashes);
|
||||
check_submit_pending(tab, crashes);
|
||||
});
|
||||
}, true);
|
||||
browser.loadURI("about:crashes", null, null);
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, "about:crashes").then((tab) => {
|
||||
ContentTask.spawn(tab.linkedBrowser, crashes, check_crash_list)
|
||||
.then(() => check_submit_pending(tab, crashes));
|
||||
});
|
||||
}
|
||||
|
@ -1,67 +1,41 @@
|
||||
function check_clear_visible(tab, aVisible) {
|
||||
let doc = gBrowser.getBrowserForTab(tab).contentDocument;
|
||||
let visible = false;
|
||||
let button = doc.getElementById("clear-reports");
|
||||
if (button) {
|
||||
let style = doc.defaultView.getComputedStyle(button, "");
|
||||
if (style.display != "none" &&
|
||||
style.visibility == "visible")
|
||||
visible = true;
|
||||
}
|
||||
is(visible, aVisible,
|
||||
"clear reports button is " + (aVisible ? "visible" : "hidden"));
|
||||
function check_clear_visible(browser, aVisible) {
|
||||
return ContentTask.spawn(browser, aVisible, function (aVisible) {
|
||||
let doc = content.document;
|
||||
let visible = false;
|
||||
let button = doc.getElementById("clear-reports");
|
||||
if (button) {
|
||||
let style = doc.defaultView.getComputedStyle(button, "");
|
||||
if (style.display != "none" &&
|
||||
style.visibility == "visible")
|
||||
visible = true;
|
||||
}
|
||||
is(visible, aVisible,
|
||||
"clear reports button is " + (aVisible ? "visible" : "hidden"));
|
||||
});
|
||||
}
|
||||
|
||||
// each test here has a setup (run before loading about:crashes) and onload (run after about:crashes loads)
|
||||
var _tests = [{setup: null, onload: function(tab) { check_clear_visible(tab, false); }},
|
||||
{setup: function(crD) { add_fake_crashes(crD, 1); },
|
||||
onload: function(tab) { check_clear_visible(tab, true); }}
|
||||
var _tests = [{setup: null, onload: function(browser) { return check_clear_visible(browser, false); }},
|
||||
{setup: function(crD) { return add_fake_crashes(crD, 1); },
|
||||
onload: function(browser) { return check_clear_visible(browser, true); }}
|
||||
];
|
||||
var _current_test = 0;
|
||||
|
||||
function run_test_setup(crD) {
|
||||
if (_tests[_current_test].setup) {
|
||||
_tests[_current_test].setup(crD);
|
||||
}
|
||||
}
|
||||
|
||||
function run_test_onload(tab) {
|
||||
if (_tests[_current_test].onload) {
|
||||
_tests[_current_test].onload(tab);
|
||||
}
|
||||
_current_test++;
|
||||
|
||||
if (_current_test == _tests.length) {
|
||||
cleanup_fake_appdir();
|
||||
gBrowser.removeTab(tab);
|
||||
finish();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
add_task(function* test() {
|
||||
let appD = make_fake_appdir();
|
||||
let crD = appD.clone();
|
||||
crD.append("Crash Reports");
|
||||
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
let onLoad = function () {
|
||||
executeSoon(function() {
|
||||
if (run_test_onload(tab)) {
|
||||
// prep and run the next test
|
||||
run_test_setup(crD);
|
||||
executeSoon(function() { browser.loadURI("about:crashes", null, null); });
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function* (browser) {
|
||||
for (let test of _tests) {
|
||||
// Run setup before loading about:crashes.
|
||||
if (test.setup) {
|
||||
yield test.setup(crD);
|
||||
}
|
||||
});
|
||||
};
|
||||
browser.addEventListener("load", onLoad, true);
|
||||
registerCleanupFunction(function () {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
|
||||
BrowserTestUtils.loadURI(browser, "about:crashes");
|
||||
yield BrowserTestUtils.browserLoaded(browser).then(() => test.onload(browser));
|
||||
}
|
||||
});
|
||||
// kick things off
|
||||
run_test_setup(crD);
|
||||
browser.loadURI("about:crashes", null, null);
|
||||
}
|
||||
|
||||
cleanup_fake_appdir();
|
||||
});
|
||||
|
@ -2,28 +2,29 @@
|
||||
* 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/. */
|
||||
|
||||
function clickClearReports(tab, cb) {
|
||||
let doc = gBrowser.getBrowserForTab(tab).contentDocument;
|
||||
function clickClearReports(browser) {
|
||||
let doc = content.document;
|
||||
|
||||
let button = doc.getElementById("clear-reports");
|
||||
|
||||
if (!button) {
|
||||
ok(false, "Button not found");
|
||||
cb();
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
let style = doc.defaultView.getComputedStyle(button, "");
|
||||
|
||||
isnot(style.display, "none", "Clear reports button visible");
|
||||
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
let deferred = {};
|
||||
deferred.promise = new Promise(resolve => deferred.resolve = resolve);
|
||||
var observer = new content.MutationObserver(function(mutations) {
|
||||
for (let mutation of mutations) {
|
||||
if (mutation.type == "attributes" &&
|
||||
mutation.attributeName == "style") {
|
||||
observer.disconnect();
|
||||
is(style.display, "none", "Clear reports button hidden");
|
||||
cb();
|
||||
deferred.resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -35,6 +36,7 @@ function clickClearReports(tab, cb) {
|
||||
});
|
||||
|
||||
button.click();
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
var promptShown = false;
|
||||
@ -51,9 +53,7 @@ registerCleanupFunction(function () {
|
||||
Services.prompt = oldPrompt;
|
||||
});
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
add_task(function* test() {
|
||||
let appD = make_fake_appdir();
|
||||
let crD = appD.clone();
|
||||
crD.append("Crash Reports");
|
||||
@ -93,44 +93,32 @@ function test() {
|
||||
report4.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
|
||||
report4.lastModifiedTime = Date.now() - 63172000000;
|
||||
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
cleanup_fake_appdir();
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
|
||||
executeSoon(function() {
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:crashes" },
|
||||
function* (browser) {
|
||||
let dirs = [ submitdir, pendingdir, crD ];
|
||||
let existing = [ file1.path, file2.path, report1.path, report2.path,
|
||||
report3.path, submitdir.path, pendingdir.path ];
|
||||
|
||||
clickClearReports(tab, function() {
|
||||
for (let dir of dirs) {
|
||||
let entries = dir.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let file = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let index = existing.indexOf(file.path);
|
||||
isnot(index, -1, file.leafName + " exists");
|
||||
yield ContentTask.spawn(browser, null, clickClearReports);
|
||||
|
||||
if (index != -1) {
|
||||
existing.splice(index, 1);
|
||||
}
|
||||
for (let dir of dirs) {
|
||||
let entries = dir.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let file = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let index = existing.indexOf(file.path);
|
||||
isnot(index, -1, file.leafName + " exists");
|
||||
|
||||
if (index != -1) {
|
||||
existing.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is(existing.length, 0, "All the files that should still exist exist");
|
||||
ok(promptShown, "Prompt shown");
|
||||
|
||||
finish();
|
||||
});
|
||||
is(existing.length, 0, "All the files that should still exist exist");
|
||||
ok(promptShown, "Prompt shown");
|
||||
});
|
||||
}, true);
|
||||
|
||||
browser.loadURI("about:crashes", null, null);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user