Bug 1044181: test elements are now actually loaded when tracking protection is disabled/broken. added style loader test. r=mmc

This commit is contained in:
Georgios Kontaxis 2014-08-08 15:17:28 -07:00
parent 0cccc3d307
commit d1929b7bc7
2 changed files with 37 additions and 18 deletions

View File

@ -5,13 +5,12 @@
<script type="text/javascript">
"use strict";
var scriptItem;
var scriptItem = "untouched";
var scriptItem1 = "untouched";
var imageItem1 = "untouched";
var frameItem1 = "untouched";
var scriptItem2 = "untouched";
var imageItem1 = "untouched";
var imageItem2 = "untouched";
var frameItem1 = "untouched";
var frameItem2 = "untouched";
var badids = [
@ -20,18 +19,30 @@ var badids = [
"badimage1",
"badimage2",
"badframe1",
"badframe2"
"badframe2",
"badcss"
];
function checkLoads() {
window.parent.is(scriptItem1, "untouched", "Should block tracking js 1");
window.parent.is(scriptItem2, "untouched", "Should block tracking js 2");
window.parent.is(
scriptItem1, "untouched", "Should not load tracking javascript");
window.parent.is(
scriptItem2, "untouched", "Should not load tracking javascript (2)");
window.parent.is(imageItem1, "untouched", "Should block tracking image 1");
window.parent.is(imageItem2, "untouched", "Should block tracking image 2");
window.parent.is(
imageItem1, "untouched", "Should not load tracking images");
window.parent.is(
imageItem2, "untouched", "Should not load tracking images (2)");
window.parent.is(frameItem1, "untouched", "Should block tracking iframe 1");
window.parent.is(frameItem2, "untouched", "Should block tracking iframe 2");
window.parent.is(
frameItem1, "untouched", "Should not load tracking iframes");
window.parent.is(
frameItem2, "untouched", "Should not load tracking iframes (2)");
var elt = document.getElementById("styleCheck");
var style = document.defaultView.getComputedStyle(elt, "");
window.parent.isnot(
style.visibility, "hidden", "Should not load tracking css");
window.parent.is(window.document.blockedTrackingNodeCount, badids.length,
"Should identify all tracking elements");
@ -76,40 +87,47 @@ function checkLoads() {
</script>
<!-- Try loading from a tracking CSS URI -->
<link id="badcss" rel="stylesheet" type="text/css" href="http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.css"></link>
</head>
<body onload="checkLoads()">
<!-- Try loading from a tracking script URI (1) -->
<script id="badscript1" src="http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.js" onload="scriptItem1='spoiled';"></script>
<!-- Try loading from a tracking script URI (1): evil.js onload will have updated the scriptItem variable -->
<script id="badscript1" src="http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.js" onload="scriptItem1 = scriptItem;"></script>
<!-- Try loading from a tracking image URI (1) -->
<img id="badimage1" src="http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/raptor.jpg?reload=true" onload="imageItem1='spoiled';"/>
<img id="badimage1" src="http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/raptor.jpg?reload=true" onload="imageItem1 = 'spoiled';"/>
<!-- Try loading from a tracking frame URI (1) -->
<iframe id="badframe1" src="http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/track.html" onload="frameItem1='spoiled';"></iframe>
<iframe id="badframe1" src="http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/track.html" onload="frameItem1 = 'spoiled';"></iframe>
<script>
// Try loading from a tracking script URI (2) - The loader may follow a different path depending on whether the resource is loaded from JS or HTML.
var newScript = document.createElement("script");
newScript.id = "badscript2";
newScript.src = "http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.js";
newScript.addEventListener("load", function onload() {scriptItem2 = 'spoiled';});
newScript.addEventListener("load", function() {scriptItem2 = scriptItem;});
document.body.appendChild(newScript);
/// Try loading from a tracking image URI (2)
var newImage = document.createElement("img");
newImage.id = "badimage2";
newImage.src = "http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/raptor.jpg?reload=true";
newImage.addEventListener("load", function onload() {imageItem2 = 'spoiled'});
newImage.addEventListener("load", function() {imageItem2 = 'spoiled'});
document.body.appendChild(newImage);
// Try loading from a tracking iframe URI (2)
var newFrame = document.createElement("iframe");
newFrame.id = "badframe2";
newFrame.src = "http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/track.html"
newFrame.addEventListener("load", function onload() {frameItem2 = 'spoiled'});
newFrame.addEventListener("load", function() {frameItem2 = 'spoiled'});
document.body.appendChild(newFrame);
</script>
The following should not be hidden:
<div id="styleCheck">STYLE TEST</div>
</body>
</html>

View File

@ -6,6 +6,7 @@
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>