Bug 1177195 - Include a 'learn more' link on the blocked tracking protection message in the web console;r=fitzgen

This commit is contained in:
Brian Grinstead 2015-07-29 17:33:29 -07:00
parent c78f7ee6e5
commit 2191c3c6f3
4 changed files with 68 additions and 0 deletions

View File

@ -111,6 +111,7 @@ support-files =
test-property-provider.html
test-repeated-messages.html
test-result-format-as-string.html
test-trackingprotection-securityerrors.html
test-webconsole-error-observer.html
test_bug_770099_violation.html
test_bug_770099_violation.html^headers^
@ -350,6 +351,8 @@ skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_split_focus.js]
[browser_webconsole_split_persist.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
[browser_webconsole_trackingprotection_errors.js]
tags = trackingprotection
[browser_webconsole_view_source.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
[browser_webconsole_reflow.js]

View File

@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Load a page with tracking elements that get blocked and make sure that a
// 'learn more' link shows up in the webconsole.
"use strict";
const TEST_URI = "http://tracking.example.org/browser/browser/devtools/webconsole/test/test-trackingprotection-securityerrors.html";
const LEARN_MORE_URI = "https://developer.mozilla.org/Firefox/Privacy/Tracking_Protection";
const PREF = "privacy.trackingprotection.enabled";
const {UrlClassifierTestUtils} = Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF);
UrlClassifierTestUtils.cleanupTestTrackers();
});
add_task(function* testMessagesAppear() {
yield UrlClassifierTestUtils.addTestTrackers();
Services.prefs.setBoolPref(PREF, true);
let { browser } = yield loadTab(TEST_URI);
let hud = yield openConsole();
let results = yield waitForMessages({
webconsole: hud,
messages: [
{
name: "Was blocked because tracking protection is enabled",
text: "The resource at \"http://tracking.example.com/\" was blocked because tracking protection is enabled",
category: CATEGORY_SECURITY,
severity: SEVERITY_WARNING,
objects: true,
},
],
});
yield testClickOpenNewTab(hud, results[0]);
});
function testClickOpenNewTab(hud, match) {
let warningNode = match.clickableElements[0];
ok(warningNode, "link element");
ok(warningNode.classList.contains("learn-more-link"), "link class name");
return simulateMessageLinkClick(warningNode, LEARN_MORE_URI);
}

View File

@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<meta charset="utf8">
</head>
<body>
<iframe src="http://tracking.example.com/"></iframe>
</body>
</html>

View File

@ -42,6 +42,8 @@ const XHTML_NS = "http://www.w3.org/1999/xhtml";
const MIXED_CONTENT_LEARN_MORE = "https://developer.mozilla.org/docs/Security/MixedContent";
const TRACKING_PROTECTION_LEARN_MORE = "https://developer.mozilla.org/Firefox/Privacy/Tracking_Protection";
const INSECURE_PASSWORDS_LEARN_MORE = "https://developer.mozilla.org/docs/Security/InsecurePasswords";
const STRICT_TRANSPORT_SECURITY_LEARN_MORE = "https://developer.mozilla.org/docs/Security/HTTP_Strict_Transport_Security";
@ -1679,6 +1681,9 @@ WebConsoleFrame.prototype = {
case "SHA-1 Signature":
url = WEAK_SIGNATURE_ALGORITHM_LEARN_MORE;
break;
case "Tracking Protection":
url = TRACKING_PROTECTION_LEARN_MORE;
break;
default:
// Unknown category. Return without adding more info node.
return;