-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e34bb1
commit 0e4a090
Showing
11 changed files
with
227 additions
and
101 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
// META: script=resources/utils.js | ||
|
||
// It's weird that browsers do this, but it should continue to work. | ||
promise_test(async t => { | ||
await loadScript('resources/partial-script.py?pretend-offset=90000'); | ||
assert_true(self.scriptExecuted); | ||
}, `Script executed from partial response`); |
File renamed without changes.
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,30 @@ | ||
""" | ||
This generates a partial response containing valid JavaScript. | ||
""" | ||
|
||
|
||
def main(request, response): | ||
require_range = request.GET.first('require-range', '') | ||
pretend_offset = int(request.GET.first('pretend-offset', '0')) | ||
range_header = request.headers.get('Range', '') | ||
|
||
if require_range and not range_header: | ||
response.set_error(412, "Range header required") | ||
response.write() | ||
return | ||
|
||
response.headers.set("Content-Type", "text/plain") | ||
response.headers.set("Accept-Ranges", "bytes") | ||
response.headers.set("Cache-Control", "no-cache") | ||
response.status = 206 | ||
|
||
to_send = 'self.scriptExecuted = true;' | ||
length = len(to_send) | ||
|
||
content_range = "bytes {}-{}/{}".format( | ||
pretend_offset, pretend_offset + length - 1, pretend_offset + length) | ||
|
||
response.headers.set("Content-Range", content_range) | ||
response.headers.set("Content-Length", length) | ||
|
||
response.content = to_send |
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
File renamed without changes.
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,9 @@ | ||
function loadScript(url, { doc = document }={}) { | ||
return new Promise((resolve, reject) => { | ||
const script = doc.createElement('script'); | ||
script.onload = () => resolve(); | ||
script.onerror = () => reject(Error("Script load failed")); | ||
script.src = url; | ||
doc.body.appendChild(script); | ||
}) | ||
} |
Oops, something went wrong.