mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1485673 - Allow tracking channels being redirected from http-on-modify-request observer notifications when tracking protection is turned on; r=mayhemer
This commit is contained in:
parent
1f9d6d9b78
commit
5306437473
@ -6062,6 +6062,12 @@ nsHttpChannel::CancelForTrackingProtection()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Check to see if we should redirect this channel elsewhere by
|
||||
// nsIHttpChannel.redirectTo API request
|
||||
if (mAPIRedirectToURI) {
|
||||
return AsyncCall(&nsHttpChannel::HandleAsyncAPIRedirect);
|
||||
}
|
||||
|
||||
return CancelInternal(NS_ERROR_TRACKING_URI);
|
||||
}
|
||||
|
||||
@ -6079,6 +6085,13 @@ nsHttpChannel::ContinueCancelledByTrackingProtection()
|
||||
return;
|
||||
}
|
||||
|
||||
// Check to see if we should redirect this channel elsewhere by
|
||||
// nsIHttpChannel.redirectTo API request
|
||||
if (mAPIRedirectToURI) {
|
||||
Unused << AsyncCall(&nsHttpChannel::HandleAsyncAPIRedirect);
|
||||
return;
|
||||
}
|
||||
|
||||
Unused << CancelInternal(NS_ERROR_TRACKING_URI);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
* canceled.
|
||||
*/
|
||||
|
||||
let gExpectedResourcesSeen = 0;
|
||||
async function onModifyRequest() {
|
||||
return new Promise((resolve, reject) => {
|
||||
Services.obs.addObserver(function observer(subject, topic, data) {
|
||||
@ -18,10 +19,25 @@ async function onModifyRequest() {
|
||||
if (httpChannel.URI.prePath + "/" != TEST_3RD_PARTY_DOMAIN_TP) {
|
||||
return;
|
||||
}
|
||||
ok(spec.endsWith("empty.js"), "Correct resource observed");
|
||||
Services.obs.removeObserver(observer, "http-on-modify-request");
|
||||
resolve();
|
||||
}, "http-on-modify-request");
|
||||
if (spec.endsWith("empty.js")) {
|
||||
ok(true, "Correct resource observed");
|
||||
++gExpectedResourcesSeen;
|
||||
} else if (spec.endsWith("empty.js?redirect")) {
|
||||
httpChannel.redirectTo(Services.io.newURI(spec.replace("empty.js?redirect", "head.js")));
|
||||
} else if (spec.endsWith("empty.js?redirect2")) {
|
||||
httpChannel.suspend();
|
||||
setTimeout(() => {
|
||||
httpChannel.redirectTo(Services.io.newURI(spec.replace("empty.js?redirect2", "head.js")));
|
||||
httpChannel.resume();
|
||||
}, 100);
|
||||
} else if (spec.endsWith("head.js")) {
|
||||
++gExpectedResourcesSeen;
|
||||
}
|
||||
if (gExpectedResourcesSeen == 3) {
|
||||
Services.obs.removeObserver(observer, "http-on-modify-request");
|
||||
resolve();
|
||||
}
|
||||
}, "http-on-modify-request", false);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="https://tracking.example.com/browser/toolkit/components/antitracking/test/browser/empty.js"></script>
|
||||
<script src="https://tracking.example.com/browser/toolkit/components/antitracking/test/browser/empty.js?redirect"></script>
|
||||
<script src="https://tracking.example.com/browser/toolkit/components/antitracking/test/browser/empty.js?redirect2"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user