Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | function cleanup_and_finish() { |
michael@0 | 2 | try { |
michael@0 | 3 | cleanup_fake_appdir(); |
michael@0 | 4 | } catch(ex) {} |
michael@0 | 5 | Services.prefs.clearUserPref("breakpad.reportURL"); |
michael@0 | 6 | gBrowser.removeTab(gBrowser.selectedTab); |
michael@0 | 7 | finish(); |
michael@0 | 8 | } |
michael@0 | 9 | |
michael@0 | 10 | /* |
michael@0 | 11 | * check_crash_list |
michael@0 | 12 | * |
michael@0 | 13 | * Check that the list of crashes displayed by about:crashes matches |
michael@0 | 14 | * the list of crashes that we placed in the pending+submitted directories. |
michael@0 | 15 | */ |
michael@0 | 16 | function check_crash_list(tab, crashes) { |
michael@0 | 17 | let doc = gBrowser.getBrowserForTab(tab).contentDocument; |
michael@0 | 18 | let crashlinks = doc.getElementById("tbody").getElementsByTagName("a"); |
michael@0 | 19 | is(crashlinks.length, crashes.length, |
michael@0 | 20 | "about:crashes lists correct number of crash reports"); |
michael@0 | 21 | // no point in checking this if the lists aren't the same length |
michael@0 | 22 | if (crashlinks.length == crashes.length) { |
michael@0 | 23 | for(let i=0; i<crashes.length; i++) { |
michael@0 | 24 | is(crashlinks[i].id, crashes[i].id, i + ": crash ID is correct"); |
michael@0 | 25 | if (crashes[i].pending) { |
michael@0 | 26 | // we set the breakpad.reportURL pref in test() |
michael@0 | 27 | is(crashlinks[i].getAttribute("href"), |
michael@0 | 28 | "http://example.com/browser/toolkit/crashreporter/about/throttling", |
michael@0 | 29 | "pending URL links to the correct static page"); |
michael@0 | 30 | } |
michael@0 | 31 | } |
michael@0 | 32 | } |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | /* |
michael@0 | 36 | * check_submit_pending |
michael@0 | 37 | * |
michael@0 | 38 | * Click on a pending crash in about:crashes, wait for it to be submitted (which |
michael@0 | 39 | * should redirect us to the crash report page). Verify that the data provided |
michael@0 | 40 | * by our test crash report server matches the data we submitted. |
michael@0 | 41 | * Additionally, click "back" and verify that the link now points to our new |
michael@0 | 42 | */ |
michael@0 | 43 | function check_submit_pending(tab, crashes) { |
michael@0 | 44 | let browser = gBrowser.getBrowserForTab(tab); |
michael@0 | 45 | let SubmittedCrash = null; |
michael@0 | 46 | let CrashID = null; |
michael@0 | 47 | let CrashURL = null; |
michael@0 | 48 | function csp_onload() { |
michael@0 | 49 | if (browser.contentWindow.location != 'about:crashes') { |
michael@0 | 50 | browser.removeEventListener("load", csp_onload, true); |
michael@0 | 51 | // loaded the crash report page |
michael@0 | 52 | ok(true, 'got submission onload'); |
michael@0 | 53 | // grab the Crash ID here to verify later |
michael@0 | 54 | CrashID = browser.contentWindow.location.search.split("=")[1]; |
michael@0 | 55 | CrashURL = browser.contentWindow.location.toString(); |
michael@0 | 56 | // check the JSON content vs. what we submitted |
michael@0 | 57 | let result = JSON.parse(browser.contentDocument.documentElement.textContent); |
michael@0 | 58 | is(result.upload_file_minidump, "MDMP", "minidump file sent properly"); |
michael@0 | 59 | is(result.Throttleable, 0, "correctly sent as non-throttleable"); |
michael@0 | 60 | // we checked these, they're set by the submission process, |
michael@0 | 61 | // so they won't be in the "extra" data. |
michael@0 | 62 | delete result.upload_file_minidump; |
michael@0 | 63 | delete result.Throttleable; |
michael@0 | 64 | // Likewise, this is discarded before it gets to the server |
michael@0 | 65 | delete SubmittedCrash.extra.ServerURL; |
michael@0 | 66 | |
michael@0 | 67 | for(let x in result) { |
michael@0 | 68 | if (x in SubmittedCrash.extra) |
michael@0 | 69 | is(result[x], SubmittedCrash.extra[x], |
michael@0 | 70 | "submitted value for " + x + " matches expected"); |
michael@0 | 71 | else |
michael@0 | 72 | ok(false, "property " + x + " missing from submitted data!"); |
michael@0 | 73 | } |
michael@0 | 74 | for(let y in SubmittedCrash.extra) { |
michael@0 | 75 | if (!(y in result)) |
michael@0 | 76 | ok(false, "property " + y + " missing from result data!"); |
michael@0 | 77 | } |
michael@0 | 78 | executeSoon(function() { |
michael@0 | 79 | browser.addEventListener("pageshow", csp_pageshow, true); |
michael@0 | 80 | // now navigate back |
michael@0 | 81 | browser.goBack(); |
michael@0 | 82 | }); |
michael@0 | 83 | } |
michael@0 | 84 | } |
michael@0 | 85 | function csp_fail() { |
michael@0 | 86 | browser.removeEventListener("CrashSubmitFailed", csp_fail, true); |
michael@0 | 87 | ok(false, "failed to submit crash report!"); |
michael@0 | 88 | cleanup_and_finish(); |
michael@0 | 89 | } |
michael@0 | 90 | browser.addEventListener("CrashSubmitFailed", csp_fail, true); |
michael@0 | 91 | browser.addEventListener("load", csp_onload, true); |
michael@0 | 92 | function csp_pageshow() { |
michael@0 | 93 | browser.removeEventListener("pageshow", csp_pageshow, true); |
michael@0 | 94 | executeSoon(function () { |
michael@0 | 95 | is(browser.contentWindow.location, "about:crashes", "navigated back successfully"); |
michael@0 | 96 | let link = browser.contentDocument.getElementById(CrashID); |
michael@0 | 97 | isnot(link, null, "crash report link changed correctly"); |
michael@0 | 98 | if (link) |
michael@0 | 99 | is(link.href, CrashURL, "crash report link points to correct href"); |
michael@0 | 100 | cleanup_and_finish(); |
michael@0 | 101 | }); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | // try submitting the pending report |
michael@0 | 105 | for each(let crash in crashes) { |
michael@0 | 106 | if (crash.pending) { |
michael@0 | 107 | SubmittedCrash = crash; |
michael@0 | 108 | break; |
michael@0 | 109 | } |
michael@0 | 110 | } |
michael@0 | 111 | EventUtils.sendMouseEvent({type:'click'}, SubmittedCrash.id, |
michael@0 | 112 | browser.contentWindow); |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | function test() { |
michael@0 | 116 | waitForExplicitFinish(); |
michael@0 | 117 | let appD = make_fake_appdir(); |
michael@0 | 118 | let crD = appD.clone(); |
michael@0 | 119 | crD.append("Crash Reports"); |
michael@0 | 120 | let crashes = add_fake_crashes(crD, 1); |
michael@0 | 121 | // we don't need much data here, it's not going to a real Socorro |
michael@0 | 122 | crashes.push(addPendingCrashreport(crD, |
michael@0 | 123 | crashes[crashes.length - 1].date + 60000, |
michael@0 | 124 | {'ServerURL': 'http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs', |
michael@0 | 125 | 'ProductName': 'Test App', |
michael@0 | 126 | // test that we don't truncate |
michael@0 | 127 | // at = (bug 512853) |
michael@0 | 128 | 'Foo': 'ABC=XYZ' |
michael@0 | 129 | })); |
michael@0 | 130 | crashes.sort(function(a,b) b.date - a.date); |
michael@0 | 131 | |
michael@0 | 132 | // set this pref so we can link to our test server |
michael@0 | 133 | Services.prefs.setCharPref("breakpad.reportURL", |
michael@0 | 134 | "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs?id="); |
michael@0 | 135 | |
michael@0 | 136 | let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank"); |
michael@0 | 137 | let browser = gBrowser.getBrowserForTab(tab); |
michael@0 | 138 | browser.addEventListener("load", function test_load() { |
michael@0 | 139 | browser.removeEventListener("load", test_load, true); |
michael@0 | 140 | executeSoon(function () { |
michael@0 | 141 | check_crash_list(tab, crashes); |
michael@0 | 142 | check_submit_pending(tab, crashes); |
michael@0 | 143 | }); |
michael@0 | 144 | }, true); |
michael@0 | 145 | browser.loadURI("about:crashes", null, null); |
michael@0 | 146 | } |