mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1229177 - Show the tracking protection shield for fetch and XHR requests. r=jduell
This commit is contained in:
parent
e45a470cb1
commit
1240a56d34
@ -451,6 +451,12 @@ support-files =
|
||||
tags = trackingprotection
|
||||
support-files =
|
||||
trackingPage.html
|
||||
[browser_trackingUI_6.js]
|
||||
tags = trackingprotection
|
||||
support-files =
|
||||
file_trackingUI_6.html
|
||||
file_trackingUI_6.js
|
||||
file_trackingUI_6.js^headers^
|
||||
[browser_trackingUI_telemetry.js]
|
||||
tags = trackingprotection
|
||||
support-files =
|
||||
|
46
browser/base/content/test/general/browser_trackingUI_6.js
Normal file
46
browser/base/content/test/general/browser_trackingUI_6.js
Normal file
@ -0,0 +1,46 @@
|
||||
const URL = "http://mochi.test:8888/browser/browser/base/content/test/general/file_trackingUI_6.html";
|
||||
|
||||
function waitForSecurityChange(numChanges = 1) {
|
||||
return new Promise(resolve => {
|
||||
let n = 0;
|
||||
let listener = {
|
||||
onSecurityChange: function() {
|
||||
n = n + 1;
|
||||
info ("Received onSecurityChange event " + n + " of " + numChanges);
|
||||
if (n >= numChanges) {
|
||||
gBrowser.removeProgressListener(listener);
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
};
|
||||
gBrowser.addProgressListener(listener);
|
||||
});
|
||||
}
|
||||
|
||||
add_task(function* test_fetch() {
|
||||
yield new Promise(resolve => {
|
||||
SpecialPowers.pushPrefEnv({ set: [['privacy.trackingprotection.enabled', true]] },
|
||||
resolve);
|
||||
});
|
||||
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: URL }, function* (newTabBrowser) {
|
||||
let securityChange = waitForSecurityChange();
|
||||
yield ContentTask.spawn(newTabBrowser, null, function* () {
|
||||
yield content.wrappedJSObject.test_fetch()
|
||||
.then((response) => { ok(false, "should have denied the request"); })
|
||||
.catch((e) => { ok(true, `Caught exception: ${e}`); });
|
||||
});
|
||||
yield securityChange;
|
||||
|
||||
var TrackingProtection = newTabBrowser.ownerGlobal.TrackingProtection;
|
||||
ok(TrackingProtection, "got TP object");
|
||||
ok(TrackingProtection.enabled, "TP is enabled");
|
||||
|
||||
is(TrackingProtection.content.getAttribute("state"), "blocked-tracking-content",
|
||||
'content: state="blocked-tracking-content"');
|
||||
is(TrackingProtection.icon.getAttribute("state"), "blocked-tracking-content",
|
||||
'icon: state="blocked-tracking-content"');
|
||||
is(TrackingProtection.icon.getAttribute("tooltiptext"),
|
||||
gNavigatorBundle.getString("trackingProtection.icon.activeTooltip"), "correct tooltip");
|
||||
});
|
||||
});
|
16
browser/base/content/test/general/file_trackingUI_6.html
Normal file
16
browser/base/content/test/general/file_trackingUI_6.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Testing the shield from fetch and XHR</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Hello there!</p>
|
||||
<script type="application/javascript; version=1.8">
|
||||
function test_fetch() {
|
||||
let url = "http://trackertest.org/browser/browser/base/content/test/general/file_trackingUI_6.js";
|
||||
return fetch(url);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
2
browser/base/content/test/general/file_trackingUI_6.js
Normal file
2
browser/base/content/test/general/file_trackingUI_6.js
Normal file
@ -0,0 +1,2 @@
|
||||
/* Some code goes here! */
|
||||
void 0;
|
@ -0,0 +1 @@
|
||||
Access-Control-Allow-Origin: *
|
@ -154,7 +154,7 @@ InterceptStreamListener::OnStopRequest(nsIRequest* aRequest, nsISupports* aConte
|
||||
{
|
||||
if (mOwner) {
|
||||
mOwner->DoPreOnStopRequest(aStatusCode);
|
||||
mOwner->DoOnStopRequest(mOwner, mContext);
|
||||
mOwner->DoOnStopRequest(mOwner, aStatusCode, mContext);
|
||||
}
|
||||
Cleanup();
|
||||
return NS_OK;
|
||||
@ -873,7 +873,7 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus,
|
||||
// so make sure this goes out of scope before then.
|
||||
AutoEventEnqueuer ensureSerialDispatch(mEventQ);
|
||||
|
||||
DoOnStopRequest(this, mListenerContext);
|
||||
DoOnStopRequest(this, channelStatus, mListenerContext);
|
||||
}
|
||||
|
||||
ReleaseListeners();
|
||||
@ -902,12 +902,15 @@ HttpChannelChild::DoPreOnStopRequest(nsresult aStatus)
|
||||
}
|
||||
|
||||
void
|
||||
HttpChannelChild::DoOnStopRequest(nsIRequest* aRequest, nsISupports* aContext)
|
||||
HttpChannelChild::DoOnStopRequest(nsIRequest* aRequest, nsresult aChannelStatus, nsISupports* aContext)
|
||||
{
|
||||
LOG(("HttpChannelChild::DoOnStopRequest [this=%p]\n", this));
|
||||
MOZ_ASSERT(!mIsPending);
|
||||
|
||||
if (mStatus == NS_ERROR_TRACKING_URI) {
|
||||
// NB: We use aChannelStatus here instead of mStatus because if there was an
|
||||
// nsCORSListenerProxy on this request, it will override the tracking
|
||||
// protection's return value.
|
||||
if (aChannelStatus == NS_ERROR_TRACKING_URI) {
|
||||
nsChannelClassifier::SetBlockedTrackingContent(this);
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ private:
|
||||
void DoOnDataAvailable(nsIRequest* aRequest, nsISupports* aContext, nsIInputStream* aStream,
|
||||
uint64_t offset, uint32_t count);
|
||||
void DoPreOnStopRequest(nsresult aStatus);
|
||||
void DoOnStopRequest(nsIRequest* aRequest, nsISupports* aContext);
|
||||
void DoOnStopRequest(nsIRequest* aRequest, nsresult aChannelStatus, nsISupports* aContext);
|
||||
|
||||
// Discard the prior interception and continue with the original network request.
|
||||
void ResetInterception();
|
||||
|
Loading…
Reference in New Issue
Block a user