diff options
author | WPT Sync Bot <josh+wptsync@joshmatthews.net> | 2021-02-26 08:19:22 +0000 |
---|---|---|
committer | WPT Sync Bot <josh+wptsync@joshmatthews.net> | 2021-02-26 09:58:30 +0000 |
commit | 6b8f08a1404d997db83cc998539f7c6759bd48e1 (patch) | |
tree | 7811508c7eb1d2c4d393c879675ced5772891049 /tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/serve-json-then-js.py | |
parent | 45f5d84d1b198f0879e75810fc5b5fe28ae98ed5 (diff) | |
download | servo-6b8f08a1404d997db83cc998539f7c6759bd48e1.tar.gz servo-6b8f08a1404d997db83cc998539f7c6759bd48e1.zip |
Update web-platform-tests to revision b'fef1c092193085ce2fa64fd116484ba0f3c0dbb1'
Diffstat (limited to 'tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/serve-json-then-js.py')
-rw-r--r-- | tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/serve-json-then-js.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/serve-json-then-js.py b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/serve-json-then-js.py new file mode 100644 index 00000000000..9610734d444 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/serve-json-then-js.py @@ -0,0 +1,21 @@ +# Respond with valid JSON to the first request with the given key, +# and with valid JavaScript to the second. Used for testing scenarios where +# the same request URL results in different responses on subsequent requests. +def main(request, response): + try: + stash_key = request.GET.first(b"key") + + run_count = request.server.stash.take(stash_key) + if not run_count: + run_count = 0 + + if run_count == 0: + response.headers.set(b"Content-Type", b"text/json") + response.content = '{"hello": "world"}' + else: + response.headers.set(b"Content-Type", b"application/javascript") + response.content = "export default 'hello';" + + request.server.stash.put(stash_key, run_count + 1) + except: + response.set_error(400, u"Not enough parameters") |