[tbb-commits] [tor-browser/tor-browser-38.1.0esr-5.0-1] Bug #16315: Test spoofed media queries in picture elements
gk at torproject.org
gk at torproject.org
Mon Jun 29 19:34:09 UTC 2015
commit 452f870c8dff8089f759c9052960ad7fc73866a0
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date: Sat Jun 20 16:10:34 2015 -0700
Bug #16315: Test spoofed media queries in picture elements
---
tbb-tests/match.png | Bin 0 -> 1210 bytes
tbb-tests/mismatch.png | Bin 0 -> 1573 bytes
tbb-tests/mochitest.ini | 3 +++
tbb-tests/test_tor_bug2875.html | 38 ++++++++++++++++++++++++++++++++------
4 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/tbb-tests/match.png b/tbb-tests/match.png
new file mode 100644
index 0000000..d3f299b
Binary files /dev/null and b/tbb-tests/match.png differ
diff --git a/tbb-tests/mismatch.png b/tbb-tests/mismatch.png
new file mode 100644
index 0000000..8f9da3f
Binary files /dev/null and b/tbb-tests/mismatch.png differ
diff --git a/tbb-tests/mochitest.ini b/tbb-tests/mochitest.ini
index 1434f89..2dc049a 100644
--- a/tbb-tests/mochitest.ini
+++ b/tbb-tests/mochitest.ini
@@ -1,4 +1,7 @@
[DEFAULT]
+support-files =
+ match.png
+ mismatch.png
[test_tor_bug2874.html]
[test_tor_bug2875.html]
diff --git a/tbb-tests/test_tor_bug2875.html b/tbb-tests/test_tor_bug2875.html
index 3c34f3b..5eb3370 100644
--- a/tbb-tests/test_tor_bug2875.html
+++ b/tbb-tests/test_tor_bug2875.html
@@ -9,7 +9,11 @@ https://trac.torproject.org/projects/tor/ticket/2875
<title>Test for Tor Bug #2875: Limit device and system specific CSS Media Queries</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
- <script type="application/javascript">
+ <script type="application/javascript;version=1.7">
+let test = function () {
+
+ SimpleTest.waitForExplicitFinish();
+
var keyValMatches = ([key, val]) => matchMedia("(" + key + ":" + val +")").matches;
// Default spoofed values by Tor Browser:
@@ -51,23 +55,45 @@ https://trac.torproject.org/projects/tor/ticket/2875
];
tor_suppressed_toggles.map(key => ok(!keyValMatches([key, 0]) && !keyValMatches([key, 1]),
- key + " should not exist."));
+ key + " should not exist."));
var foundOSVersion = false;
["windows-xp", "windows-vista", "windows-win7", "windows-win8"].map(function (val) {
foundOSVersion = foundOSVersion || keyValMatches(["-moz-os-version", val]);
});
ok(!foundOSVersion, "-moz-os-version should have no match");
-
+
+ // Test media queries in picture elements (Tor Bug #16315)
+ let lines = "";
+ for (let [query, expected] of tor_defaults) {
+ lines += "<picture>\n";
+ lines += " <source srcset='match.png' media='(" + query + ": " + expected + ")'>\n";
+ lines += " <img class='testImage' src='mismatch.png' alt='" + query + "'>\n";
+ lines += "</picture><br>\n";
+ }
+ document.getElementById("content").innerHTML += lines;
+ var testImages = document.getElementsByClassName("testImage");
+ window.setTimeout(function () {
+ for (let testImage of testImages) {
+ ok(testImage.currentSrc.endsWith("/match.png"), "Media query in picture should match.");
+ }
+ SimpleTest.finish();
+ }, 0);
+
+};
+
</script>
</head>
<body>
<a target="_blank" href="https://trac.torproject.org/projects/tor/ticket/2875">Tor Bug 2875</a>
<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
+<div id="content"></div>
<pre id="test">
</pre>
+<script>
+ window.onload = function () {
+ test();
+ }
+</script>
</body>
</html>
More information about the tbb-commits
mailing list