diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/netmonitor/test/xpcshell/test_request-utils-js-getFormattedProtocol.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/netmonitor/test/xpcshell/test_request-utils-js-getFormattedProtocol.js')
-rw-r--r-- | devtools/client/netmonitor/test/xpcshell/test_request-utils-js-getFormattedProtocol.js | 235 |
1 files changed, 235 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/test/xpcshell/test_request-utils-js-getFormattedProtocol.js b/devtools/client/netmonitor/test/xpcshell/test_request-utils-js-getFormattedProtocol.js new file mode 100644 index 0000000000..07ead52893 --- /dev/null +++ b/devtools/client/netmonitor/test/xpcshell/test_request-utils-js-getFormattedProtocol.js @@ -0,0 +1,235 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test devtools/client/netmonitor/src/utils/request-utils.js function +// |getFormattedProtocol| + +"use strict"; + +const { require } = ChromeUtils.importESModule( + "resource://devtools/shared/loader/Loader.sys.mjs" +); +const { + getFormattedProtocol, +} = require("resource://devtools/client/netmonitor/src/utils/request-utils.js"); + +function run_test() { + const http_1p1_value_http1p1 = { + httpVersion: "HTTP/1.1", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "http/1.1", + }, + ], + }, + }; + + const http_1p1_value_http_no_slash_1p1 = { + httpVersion: "HTTP/1.1", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "http1.1", + }, + ], + }, + }; + + const http_1p1_value_http1p11 = { + httpVersion: "HTTP/1.1", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "http/1.11", + }, + ], + }, + }; + + const http_2p0_value_h2 = { + httpVersion: "HTTP/2.0", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "h2", + }, + ], + }, + }; + + const http_1p1_value_h1 = { + httpVersion: "HTTP/1.1", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "h1", + }, + ], + }, + }; + + const http_1p1_value_h2 = { + httpVersion: "HTTP/1.1", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "h2", + }, + ], + }, + }; + + const http_1p1_value_empty_string = { + httpVersion: "HTTP/1.1", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "", + }, + ], + }, + }; + + const http_2p0_value_empty_string = { + httpVersion: "HTTP/2.0", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "", + }, + ], + }, + }; + + const http_2p0_value_2p0 = { + httpVersion: "HTTP/2.0", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "HTTP/2.0", + }, + ], + }, + }; + + const http_3p0_value_h3 = { + httpVersion: "HTTP/3.0", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "h3", + }, + ], + }, + }; + + const http_3p0_value_h3p0 = { + httpVersion: "HTTP/3.0", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "h3.0", + }, + ], + }, + }; + + const http_3p0_value_http_3p0 = { + httpVersion: "HTTP/3.0", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "http/3.0", + }, + ], + }, + }; + + const http_3p0_value_3p0 = { + httpVersion: "HTTP/3.0", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "3.0", + }, + ], + }, + }; + + const http_4p0_value_h4 = { + httpVersion: "HTTP/4.0", + responseHeaders: { + headers: [ + { + name: "X-Firefox-Spdy", + value: "h4", + }, + ], + }, + }; + + info("Testing httpValue:HTTP/1.1, value:http/1.1"); + equal(getFormattedProtocol(http_1p1_value_http1p1), "HTTP/1.1"); + + info("Testing httpValue:HTTP/1.1, value:http1.1"); + equal( + getFormattedProtocol(http_1p1_value_http_no_slash_1p1), + "HTTP/1.1+http1.1" + ); + + info("Testing httpValue:HTTP/1.1, value:http/1.11"); + equal(getFormattedProtocol(http_1p1_value_http1p11), "HTTP/1.1+http/1.11"); + + info("Testing httpValue:HTTP/2.0, value:h2"); + equal(getFormattedProtocol(http_2p0_value_h2), "HTTP/2.0"); + + info("Testing httpValue:HTTP/1.1, value:h1"); + equal(getFormattedProtocol(http_1p1_value_h1), "HTTP/1.1+h1"); + + info("Testing httpValue:HTTP/1.1, value:h2"); + equal(getFormattedProtocol(http_1p1_value_h2), "HTTP/1.1+h2"); + + info("Testing httpValue:HTTP/1.1, value:http1.1"); + equal( + getFormattedProtocol(http_1p1_value_http_no_slash_1p1), + "HTTP/1.1+http1.1" + ); + + info("Testing httpValue:HTTP/1.1, value:''"); + equal(getFormattedProtocol(http_1p1_value_empty_string), "HTTP/1.1"); + + info("Testing httpValue:HTTP/2.0, value:''"); + equal(getFormattedProtocol(http_2p0_value_empty_string), "HTTP/2.0"); + + info("Testing httpValue:HTTP/2.0, value:HTTP/2.0"); + equal(getFormattedProtocol(http_2p0_value_2p0), "HTTP/2.0+HTTP/2.0"); + + info("Testing httpValue:HTTP/3.0, value:h3"); + equal(getFormattedProtocol(http_3p0_value_h3), "HTTP/3.0"); + + info("Testing httpValue:HTTP/3.0, value:h3.0"); + equal(getFormattedProtocol(http_3p0_value_h3p0), "HTTP/3.0"); + + info("Testing httpValue:HTTP/3.0, value:http/3.0"); + equal(getFormattedProtocol(http_3p0_value_http_3p0), "HTTP/3.0+http/3.0"); + + info("Testing httpValue:HTTP/3.0, value:3.0"); + equal(getFormattedProtocol(http_3p0_value_3p0), "HTTP/3.0+3.0"); + + info("Testing httpValue:HTTP/4.0, value:h4"); + equal(getFormattedProtocol(http_4p0_value_h4), "HTTP/4.0"); +} |