Skip to content

Test identity encoding for range requests - #11291

Merged
annevk merged 3 commits into
web-platform-tests:masterfrom
jakearchibald:accept-encoding-range
Jun 6, 2018
Merged

annevk merged 3 commits into
web-platform-tests:masterfrom
jakearchibald:accept-encoding-range

Conversation

@jakearchibald

Copy link
Copy Markdown
Contributor

Tests for whatwg/fetch#751.

promise_test(async t => {
await loadScript('resources/partial-script.py?pretend-offset=90000');
assert_true(self.scriptExecuted);
}, `Script executed from partial response`);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test already existed, but I renamed the file and git didn't realise.

await fetch(event.request);
const response = await fetch('stash-take.py?key=' + key);
assert_equals(await response.json(), '"range-header-received"');
assert_equals(await response.json(), 'range-header-received');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug-fixing an existing test.

audio.preload = true;
document.body.appendChild(audio);
}
const BASE_SCOPE = 'resources/basic.html?';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm now generating a unique scope for each test, it avoid the old service worker coming back from the dead in Safari.

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything that I know to be wrong, but I have a couple minor questions.

request.server.stash.take(
accept_encoding_key,
'/fetch/range/'
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safari appears to make two requests in quick succession. Without this, an error is thrown, since it tries to put something in the stash when that key already exists.

response.headers.set("Cache-Control", "no-cache")

range_header = request.headers.get('Range', '')
range_header_match = range_header and re.search(r'^bytes=(\d*)-(\d*)$', range_header)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is either None (or False?) or a regular expression result?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

@annevk
annevk merged commit 1421a4a into web-platform-tests:master Jun 6, 2018
annevk pushed a commit to whatwg/fetch that referenced this pull request Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants