mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1189494 - Pass tracking information to BrowserElement's mozbrowsersecuritychange event. r=fabrice
This commit is contained in:
parent
92de31f61f
commit
d907439140
@ -1663,30 +1663,54 @@ BrowserElementChild.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
var stateDesc;
|
||||
var securityStateDesc;
|
||||
if (state & Ci.nsIWebProgressListener.STATE_IS_SECURE) {
|
||||
stateDesc = 'secure';
|
||||
securityStateDesc = 'secure';
|
||||
}
|
||||
else if (state & Ci.nsIWebProgressListener.STATE_IS_BROKEN) {
|
||||
stateDesc = 'broken';
|
||||
securityStateDesc = 'broken';
|
||||
}
|
||||
else if (state & Ci.nsIWebProgressListener.STATE_IS_INSECURE) {
|
||||
stateDesc = 'insecure';
|
||||
}
|
||||
else if (state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT) {
|
||||
stateDesc = 'loaded_tracking_content';
|
||||
}
|
||||
else if (state & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT) {
|
||||
stateDesc = 'blocked_tracking_content';
|
||||
securityStateDesc = 'insecure';
|
||||
}
|
||||
else {
|
||||
debug("Unexpected securitychange state!");
|
||||
stateDesc = '???';
|
||||
securityStateDesc = '???';
|
||||
}
|
||||
|
||||
var trackingStateDesc;
|
||||
if (state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT) {
|
||||
trackingStateDesc = 'loaded_tracking_content';
|
||||
}
|
||||
else if (state & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT) {
|
||||
trackingStateDesc = 'blocked_tracking_content';
|
||||
}
|
||||
|
||||
var mixedStateDesc;
|
||||
if (state & Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT) {
|
||||
mixedStateDesc = 'blocked_mixed_active_content';
|
||||
}
|
||||
else if (state & Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT) {
|
||||
// Note that STATE_LOADED_MIXED_ACTIVE_CONTENT implies STATE_IS_BROKEN
|
||||
mixedStateDesc = 'loaded_mixed_active_content';
|
||||
}
|
||||
|
||||
var isEV = !!(state & Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL);
|
||||
var isTrackingContent = !!(state &
|
||||
(Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT |
|
||||
Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT));
|
||||
var isMixedContent = !!(state &
|
||||
(Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT |
|
||||
Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT));
|
||||
|
||||
sendAsyncMsg('securitychange', { state: stateDesc, extendedValidation: isEV });
|
||||
sendAsyncMsg('securitychange', {
|
||||
state: securityStateDesc,
|
||||
trackingState: trackingStateDesc,
|
||||
mixedState: mixedStateDesc,
|
||||
extendedValidation: isEV,
|
||||
trackingContent: isTrackingContent,
|
||||
mixedContent: isMixedContent,
|
||||
});
|
||||
},
|
||||
|
||||
onStatusChange: function(webProgress, request, status, message) {},
|
||||
|
@ -9,6 +9,9 @@ SimpleTest.waitForExplicitFinish();
|
||||
browserElementTestHelpers.setEnabledPref(true);
|
||||
browserElementTestHelpers.addPermission();
|
||||
|
||||
const { Services } = SpecialPowers.Cu.import('resource://gre/modules/Services.jsm');
|
||||
const { UrlClassifierTestUtils } = SpecialPowers.Cu.import('resource://testing-common/UrlClassifierTestUtils.jsm', {});
|
||||
|
||||
function runTest() {
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.setAttribute('mozbrowser', 'true');
|
||||
@ -23,21 +26,37 @@ function runTest() {
|
||||
var count = 0;
|
||||
iframe.addEventListener('mozbrowserloadend', function(e) {
|
||||
count++;
|
||||
var nextURL;
|
||||
switch (count) {
|
||||
case 1:
|
||||
is(lastSecurityState.state, 'secure');
|
||||
is(lastSecurityState.extendedValidation, false);
|
||||
is(lastSecurityState.trackingContent, false);
|
||||
is(lastSecurityState.mixedContent, false);
|
||||
iframe.src = "http://example.com/" + filepath;
|
||||
break;
|
||||
case 2:
|
||||
is(lastSecurityState.state, 'insecure');
|
||||
is(lastSecurityState.extendedValidation, false);
|
||||
is(lastSecurityState.trackingContent, false);
|
||||
is(lastSecurityState.mixedContent, false);
|
||||
iframe.src = 'https://example.com:443/' + filepath + '?broken';
|
||||
break;
|
||||
case 3:
|
||||
is(lastSecurityState.state, 'broken');
|
||||
is(lastSecurityState.extendedValidation, false);
|
||||
is(lastSecurityState.trackingContent, false);
|
||||
is(lastSecurityState.mixedContent, true);
|
||||
iframe.src = "http://example.com/" + filepath + '?tracking';
|
||||
break;
|
||||
case 4:
|
||||
is(lastSecurityState.state, 'insecure');
|
||||
is(lastSecurityState.extendedValidation, false);
|
||||
// TODO: I'm having trouble getting the tracking protection
|
||||
// test changes to be enabled in the child process, so this
|
||||
// isn't currently blocked in tests, but it works when
|
||||
// manually testing.
|
||||
// is(lastSecurityState.trackingContent, true);
|
||||
is(lastSecurityState.mixedContent, false);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
});
|
||||
@ -46,4 +65,18 @@ function runTest() {
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
addEventListener('testready', runTest);
|
||||
addEventListener('testready', function() {
|
||||
SimpleTest.registerCleanupFunction(UrlClassifierTestUtils.cleanupTestTrackers);
|
||||
SpecialPowers.pushPrefEnv({"set" : [
|
||||
["privacy.trackingprotection.enabled", true],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
["browser.safebrowsing.enabled", false],
|
||||
["browser.safebrowsing.malware.enabled", false],
|
||||
]}, () => {
|
||||
SimpleTest.registerCleanupFunction(UrlClassifierTestUtils.cleanupTestTrackers);
|
||||
UrlClassifierTestUtils.addTestTrackers().then(() => {
|
||||
runTest();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,11 +1,16 @@
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<script>
|
||||
if (location.search == '?broken') {
|
||||
if (location.search === '?broken') {
|
||||
// Load something non-https.
|
||||
var s = document.createElement('script');
|
||||
s.src = 'http://example.com/dom/browser-element/mochitest/file_empty_script.js';
|
||||
document.head.appendChild(s);
|
||||
} else if (location.search === '?tracking') {
|
||||
var img = document.createElement('img');
|
||||
img.src = 'http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/raptor.jpg';
|
||||
document.body.appendChild(img);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
Loading…
Reference in New Issue
Block a user