зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1628605: Test SecFetch Headers and websockets. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D70366 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ae9fc8a3c6
Коммит
91485d8871
|
@ -0,0 +1,7 @@
|
|||
|
||||
def web_socket_do_extra_handshake(request):
|
||||
pass
|
||||
|
||||
|
||||
def web_socket_transfer_data(request):
|
||||
pass
|
|
@ -54,3 +54,6 @@ skip-if = !debug
|
|||
[test_same_site_cookies_laxByDefault.html]
|
||||
skip-if = debug
|
||||
support-files = closeWindow.sjs
|
||||
[test_sec_fetch_websocket.html]
|
||||
skip-if = toolkit == 'android' # no websocket support Bug 982828
|
||||
support-files = file_sec_fetch_websocket_wsh.py
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1628605: Test Sec-Fetch-* header for websockets</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var script = SpecialPowers.loadChromeScript(() => {
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
Services.obs.addObserver(function onExamResp(subject, topic, data) {
|
||||
let channel = subject.QueryInterface(Ci.nsIHttpChannel);
|
||||
if (!channel.URI.spec.startsWith("https://example.com/tests/dom/security/test/general/file_sec_fetch_websocket")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Sec-Fetch-* Headers should be present for Dest, Mode, Site
|
||||
try {
|
||||
let secFetchDest = channel.getRequestHeader("Sec-Fetch-Dest");
|
||||
is(secFetchDest, "websocket", "testing sec-fetch-dest");
|
||||
|
||||
let secFetchMode = channel.getRequestHeader("Sec-Fetch-Mode");
|
||||
is(secFetchMode, "websocket", "testing sec-fetch-mode");
|
||||
|
||||
let secFetchSite = channel.getRequestHeader("Sec-Fetch-Site");
|
||||
is(secFetchSite, "cross-site", "testing sec-fetch-site");
|
||||
}
|
||||
catch (e) {
|
||||
ok(false, "testing sec-fetch-*");
|
||||
}
|
||||
|
||||
// Sec-Fetch-User should not be present
|
||||
try {
|
||||
let secFetchSite = channel.getRequestHeader("Sec-Fetch-User");
|
||||
ok(false, "testing sec-fetch-user");
|
||||
}
|
||||
catch (e) {
|
||||
ok(true, "testing sec-fetch-user");
|
||||
}
|
||||
Services.obs.removeObserver(onExamResp, "http-on-stop-request");
|
||||
|
||||
sendAsyncMessage("test-end");
|
||||
}, "http-on-stop-request");
|
||||
});
|
||||
|
||||
script.addMessageListener("test-end", () => {
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
function test_sec_fetch_websocket() {
|
||||
var wssSocket = new WebSocket("wss://example.com/tests/dom/security/test/general/file_sec_fetch_websocket");
|
||||
wssSocket.onopen = function(e) {
|
||||
ok(true, "sanity: wssSocket onopen");
|
||||
};
|
||||
wssSocket.onerror = function(e) {
|
||||
ok(false, "fanity: wssSocket onerror");
|
||||
};
|
||||
}
|
||||
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["dom.security.secFetch.enabled", true]]
|
||||
}, test_sec_fetch_websocket);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче