function cleanup_and_finish() { try { cleanup_fake_appdir(); } catch (ex) {} Services.prefs.clearUserPref("breakpad.reportURL"); BrowserTestUtils.removeTab(gBrowser.selectedTab).then(finish); } /* * check_crash_list * * 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(crashes) { let doc = content.document; let crashlinks = doc.getElementsByClassName("crashReport"); Assert.equal(crashlinks.length, crashes.length, "about:crashes lists correct number of crash reports"); // no point in checking this if the lists aren't the same length if (crashlinks.length == crashes.length) { for (let i=0; i { // 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], "submitted value for " + x + " matches expected"); else ok(false, "property " + x + " missing from submitted data!"); } for (let y in SubmittedCrash.extra) { if (!(y in result)) ok(false, "property " + y + " missing from result data!"); } // 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); ok(false, "failed to submit crash report!"); cleanup_and_finish(); } browser.addEventListener("CrashSubmitFailed", csp_fail, true); BrowserTestUtils.browserLoaded(browser, false, (url) => url !== "about:crashes").then(csp_onload); function csp_pageshow() { ContentTask.spawn(browser, { CrashID, CrashURL }, function({ CrashID, CrashURL }) { Assert.equal(content.location.href, "about:crashes", "navigated back successfully"); let link = content.document.getElementById(CrashID); Assert.notEqual(link, null, "crash report link changed correctly"); if (link) Assert.equal(link.href, CrashURL, "crash report link points to correct href"); }).then(cleanup_and_finish); } // try submitting the pending report for (let crash of crashes) { if (crash.pending) { SubmittedCrash = crash; break; } } ContentTask.spawn(browser, SubmittedCrash.id, function(id) { let link = content.document.getElementById(id); link.click(); }); } function test() { waitForExplicitFinish(); let appD = make_fake_appdir(); let crD = appD.clone(); crD.append("Crash Reports"); let crashes = add_fake_crashes(crD, 1); // we don't need much data here, it's not going to a real Socorro crashes.push(addPendingCrashreport(crD, crashes[crashes.length - 1].date + 60000, {'ServerURL': 'http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs', 'ProductName': 'Test App', // test that we don't truncate // at = (bug 512853) 'Foo': 'ABC=XYZ' })); crashes.sort((a, b) => b.date - a.date); // set this pref so we can link to our test server Services.prefs.setCharPref("breakpad.reportURL", "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs?id="); BrowserTestUtils.openNewForegroundTab(gBrowser, "about:crashes").then((tab) => { ContentTask.spawn(tab.linkedBrowser, crashes, check_crash_list) .then(() => check_submit_pending(tab, crashes)); }); }