зеркало из https://github.com/mozilla/gecko-dev.git
Bug 583181 - Part 1: Add test for current navigator.buildID behavior. r=hsivonen
The incorrect LEGACY_BUILD_ID will be fixed in a subsequent changeset. We must add https://www.mozilla.org/ to server-locations.txt and regenerate the mochitest certificates [1] because the new navigator.buildID test pretends to load content from https://www.mozilla.org/. [1] https://searchfox.org/mozilla-central/source/build/pgo/certs/README Differential Revision: https://phabricator.services.mozilla.com/D7982 --HG-- rename : dom/tests/mochitest/bugs/test_bug351601.html => dom/tests/mochitest/bugs/test_navigator_buildID.html extra : rebase_source : 1deb142930f1a7a570cf719c4cb2bed8adfeabe2 extra : source : 408bff32f9623513a271cdf043d11ba6d1318e03
This commit is contained in:
Родитель
f9672fb3f4
Коммит
908795a253
Двоичные данные
build/pgo/certs/cert9.db
Двоичные данные
build/pgo/certs/cert9.db
Двоичный файл не отображается.
Двоичные данные
build/pgo/certs/key4.db
Двоичные данные
build/pgo/certs/key4.db
Двоичный файл не отображается.
Двоичные данные
build/pgo/certs/mochitest.client
Двоичные данные
build/pgo/certs/mochitest.client
Двоичный файл не отображается.
|
@ -286,3 +286,6 @@ https://mochitest.youtube.com:443
|
|||
|
||||
# Host for U2F localhost tests
|
||||
https://localhost:443
|
||||
|
||||
# Host for testing APIs whitelisted for mozilla.org
|
||||
https://www.mozilla.org:443
|
||||
|
|
|
@ -57,7 +57,6 @@ skip-if = toolkit == 'android'
|
|||
[test_bug342448.html]
|
||||
[test_bug345521.html]
|
||||
[test_bug346659.html]
|
||||
[test_bug351601.html]
|
||||
[test_bug369306.html]
|
||||
skip-if = toolkit == 'android' #TIMED_OUT
|
||||
[test_bug370098.html]
|
||||
|
@ -136,6 +135,7 @@ skip-if = toolkit == 'android'
|
|||
skip-if = toolkit == 'android' #bug 775227
|
||||
[test_domparser_after_blank.html]
|
||||
[test_errorReporting.html]
|
||||
[test_navigator_buildID.html]
|
||||
[test_onerror_message.html]
|
||||
[test_protochains.html]
|
||||
[test_resize_move_windows.html]
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=351601
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 351601</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=351601">Mozilla Bug 351601</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 351601 **/
|
||||
|
||||
var isOK = false;
|
||||
try {
|
||||
var foo = navigator.buildID;
|
||||
isOK = true;
|
||||
} catch (ex) {
|
||||
}
|
||||
ok(isOK, "navigator.buildID should never throw");
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=583181
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 583181</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=583181">Mozilla Bug 583181</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const LEGACY_BUILD_ID = 20100101; // Resist Fingerprinting's build ID
|
||||
|
||||
//
|
||||
// Access navigator.buildID from unprivileged web content.
|
||||
//
|
||||
var isOK = false;
|
||||
try {
|
||||
var contentBuildID = navigator.buildID;
|
||||
isOK = true;
|
||||
} catch (ex) {
|
||||
}
|
||||
ok(isOK, "navigator.buildID should never throw");
|
||||
is(typeof(contentBuildID), "string", "navigator.buildID should be a string");
|
||||
ok(+contentBuildID > LEGACY_BUILD_ID,
|
||||
`navigator.buildID should be exposed in content - got "${contentBuildID}"`);
|
||||
|
||||
//
|
||||
// Access navigator.buildID from chrome.
|
||||
//
|
||||
let chromeScript = SpecialPowers.loadChromeScript(() => {
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
addMessageListener("test:getBuildID", nav => {
|
||||
let browser = Services.wm.getMostRecentWindow('navigator:browser');
|
||||
return browser.navigator.buildID;
|
||||
});
|
||||
});
|
||||
|
||||
let chromeBuildID = chromeScript.sendSyncMessage("test:getBuildID")[0][0];
|
||||
chromeScript.destroy();
|
||||
|
||||
ok(+chromeBuildID > LEGACY_BUILD_ID,
|
||||
`navigator.buildID should be exposed in chrome - got "${chromeBuildID}"`);
|
||||
|
||||
function onMozillaIFrameLoaded() {
|
||||
//
|
||||
// Access navigator.buildID from mozilla.org.
|
||||
//
|
||||
let mozillaBuildID = getMozillaBuildID();
|
||||
|
||||
ok(+mozillaBuildID > LEGACY_BUILD_ID,
|
||||
`navigator.buildID should be exposed on mozilla.org ` +
|
||||
`- got "${mozillaBuildID}"`);
|
||||
is(chromeBuildID, mozillaBuildID,
|
||||
"navigator.buildID should be the same in chrome and on mozilla.org");
|
||||
|
||||
//
|
||||
// Access navigator.buildID from mozilla.org when resisting fingerprinting.
|
||||
//
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{"set": [["privacy.resistFingerprinting", true]]},
|
||||
() => {
|
||||
let resistBuildID = getMozillaBuildID();
|
||||
|
||||
is(+resistBuildID, LEGACY_BUILD_ID,
|
||||
"navigator.buildID should be spoofed on mozilla.org when " +
|
||||
"resisting fingerprinting");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function getMozillaBuildID() {
|
||||
let Cu = SpecialPowers.Cu;
|
||||
let mozillaIFrame = document.getElementById("mozillaIFrame").contentWindow;
|
||||
let mozillaSandbox = Cu.Sandbox(mozillaIFrame,
|
||||
{sandboxPrototype: mozillaIFrame});
|
||||
let mozillaBuildID = Cu.evalInSandbox("window.navigator.buildID",
|
||||
mozillaSandbox);
|
||||
Cu.nukeSandbox(mozillaSandbox);
|
||||
return mozillaBuildID;
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
<iframe id="mozillaIFrame" onload="onMozillaIFrameLoaded();" src="https://www.mozilla.org/" />
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче