forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1519302 - Add pref to restrict BinAST feature to specific hosts. …
…r=baku To reduce the attack surface in early test for BinAST, add a preference to restrict the hosts that Firefox accepts BinAST file from. The preference is turned on by default (BinAST itself is turned off by default for now), and the list contains hosts which is going to be used in early test. For hosts not listed in the list, Firefox doesn't send BinAST MIME-Type in Accept field, and doesn't handle BinAST file in case the server returns BinAST file. Differential Revision: https://phabricator.services.mozilla.com/D16517
- Loading branch information
Showing
13 changed files
with
171 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
testing/web-platform/mozilla/meta/binast/domain-restrict-excluded.https.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[domain-restrict-excluded.https.html] | ||
prefs: [dom.script_loader.binast_encoding.domain.restrict:true, | ||
dom.script_loader.binast_encoding.domain.restrict.list:] |
7 changes: 7 additions & 0 deletions
7
testing/web-platform/mozilla/meta/binast/domain-restrict-included.https.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[domain-restrict-included.https.html] | ||
prefs: [dom.script_loader.binast_encoding.domain.restrict:true, | ||
dom.script_loader.binast_encoding.domain.restrict.list:web-platform.test] | ||
[Check we can load BinAST if the host is included in the list] | ||
expected: | ||
if release_or_beta or (os == "android") or ((os == "win") and (processor == "x86")): FAIL | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[not-secure.html] | ||
prefs: [dom.script_loader.binast_encoding.domain.restrict:false] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
testing/web-platform/mozilla/tests/binast/domain-restrict-excluded.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<title>Check we can't load BinAST if the host is excluded in the list</title> | ||
|
||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
setup({allow_uncaught_exception: true}); | ||
|
||
var hadScriptLoadError = false; | ||
function setLoadError() { | ||
// Load error happens if the server side throws an exception, | ||
// for 'expect_accept' check on server side. | ||
hadScriptLoadError = true; | ||
} | ||
|
||
var hadSyntaxError = false; | ||
var hadOtherError = false; | ||
function checkSyntaxError(event) { | ||
// Server returns BinAST and the browser parses it as plain JS. | ||
if (event.message.startsWith("SyntaxError:")) { | ||
hadSyntaxError = true; | ||
} else { | ||
hadOtherError = true; | ||
} | ||
} | ||
|
||
window.addEventListener("error", checkSyntaxError); | ||
|
||
const test_load = async_test("Check we can't load BinAST if the host is excluded in the list"); | ||
window.addEventListener("load", test_load.step_func_done(ev => { | ||
assert_equals(hadScriptLoadError, false, "Didn't expect a load error event"); | ||
assert_equals(hadSyntaxError, true, "Expect a syntax error event for receiving binast"); | ||
assert_equals(hadOtherError, false, "Didn't expect other error event"); | ||
assert_equals(typeof binASTLoaded, "undefined", "Expected not to load either version"); | ||
})); | ||
|
||
</script> | ||
<script src="./serve.py?name=small&expect_accept=false&force_binast=true" onerror="setLoadError()"></script> |
31 changes: 31 additions & 0 deletions
31
testing/web-platform/mozilla/tests/binast/domain-restrict-included.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<title>Check we can load BinAST if the host is included in the list</title> | ||
|
||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
setup({allow_uncaught_exception: true}); | ||
|
||
var hadScriptLoadError = false; | ||
function setLoadError() { | ||
// Load error happens if the server side throws an exception, | ||
// for 'expect_accept' check on server side. | ||
hadScriptLoadError = true; | ||
} | ||
|
||
var hadOtherError = false; | ||
function setOtherError() { | ||
hadOtherError = true; | ||
} | ||
|
||
window.addEventListener("error", setOtherError); | ||
|
||
const test_load = async_test("Check we can load BinAST if the host is included in the list"); | ||
window.addEventListener("load", test_load.step_func_done(ev => { | ||
assert_equals(hadScriptLoadError, false, "Didn't expect a load error event"); | ||
assert_equals(hadOtherError, false, "Didn't expect other error event"); | ||
assert_equals(binASTLoaded, true, "Expected to load BinAST version"); | ||
})); | ||
|
||
</script> | ||
<script src="./serve.py?name=small&expect_accept=true" onerror="setLoadError()"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<title>Check we can't load BinAST over HTTP</title> | ||
|
||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
setup({allow_uncaught_exception: true}); | ||
|
||
var hadScriptLoadError = false; | ||
function setLoadError() { | ||
// Load error happens if the server side throws an exception, | ||
// for 'expect_accept' check on server side. | ||
hadScriptLoadError = true; | ||
} | ||
|
||
var hadSyntaxError = false; | ||
var hadOtherError = false; | ||
function checkSyntaxError(event) { | ||
// Server returns BinAST and the browser parses it as plain JS. | ||
if (event.message.startsWith("SyntaxError:")) { | ||
hadSyntaxError = true; | ||
} else { | ||
hadOtherError = true; | ||
} | ||
} | ||
|
||
window.addEventListener("error", checkSyntaxError); | ||
|
||
const test_load = async_test("Check we can't load BinAST over HTTP"); | ||
window.addEventListener("load", test_load.step_func_done(ev => { | ||
assert_equals(hadScriptLoadError, false, "Didn't expect a load error event"); | ||
assert_equals(hadSyntaxError, true, "Expect a syntax error event for receiving binast"); | ||
assert_equals(hadOtherError, false, "Didn't expect other error event"); | ||
assert_equals(typeof binASTLoaded, "undefined", "Expected not to load either version"); | ||
})); | ||
|
||
</script> | ||
<script src="./serve.py?name=small&expect_accept=false&force_binast=true" onerror="setLoadError()"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters