Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional fetch abort tests #6736

Merged
merged 9 commits into from
Aug 14, 2017

Conversation

jakearchibald
Copy link
Contributor

@jakearchibald jakearchibald commented Aug 3, 2017

This ensures that the readable stream and the fetch promise are rejected with the same error instance.

It also ensures that things thrown by the request constructor happen before rejecting with AbortError.

The above involved abstracting some of the request constructor tests.

@w3c-bots
Copy link

w3c-bots commented Aug 3, 2017

Build PASSED

Started: 2017-08-14 11:20:23
Finished: 2017-08-14 11:33:46

View more information about this build on:

@w3c-bots
Copy link

w3c-bots commented Aug 3, 2017

View the complete job log.

Sauce (safari)

Testing web-platform-tests at revision 1438494
Using binary None
Starting tests
All results were stable

All results

5 tests ran
/fetch/api/abort/general-serviceworker.https.html
Subtest Results Messages
OK
General fetch abort tests in a service worker FAIL SyntaxError: Unexpected keyword 'function'. Expected ')' to end a compound expression.
/fetch/api/abort/general-sharedworker.html
Subtest Results Messages
OK
General fetch abort tests - shared worker FAIL ReferenceError: Can't find variable: SharedWorker
/fetch/api/abort/general.any.html
Subtest Results Messages
OK
Untitled FAIL SyntaxError: Unexpected identifier 't'. Expected ')' to end an argument list.
/fetch/api/abort/general.any.worker.html
Subtest Results Messages
OK
Untitled FAIL SyntaxError: Unexpected identifier 't'. Expected ')' to end an argument list.
/fetch/api/request/request-error.html
Subtest Results Messages
OK
RequestInit's window is not null FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
Input URL is not valid FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
Input URL has credentials FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
RequestInit's mode is navigate FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
RequestInit's referrer is invalid FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
RequestInit's method is invalid FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
RequestInit's method is forbidden FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
RequestInit's mode is no-cors and method is not simple FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
RequestInit's mode is no-cors and integrity is not empty FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
RequestInit's cache mode is only-if-cached and mode is not same-origin FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
Request with cache mode: only-if-cached and fetch mode cors FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
Request with cache mode: only-if-cached and fetch mode no-cors FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
Bad referrerPolicy init parameter value FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
Bad mode init parameter value FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
Bad credentials init parameter value FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
Bad cache init parameter value FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
Bad redirect init parameter value FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "ReferenceError: Can't find variable: Request" ("ReferenceError") expected object "TypeError" ("TypeError")
Request should get its content-type from the init request FAIL Can't find variable: Headers
Request should not get its content-type from the init request if init headers are provided FAIL Can't find variable: Headers
Request should get its content-type from the body if none is provided FAIL Can't find variable: Headers
Request should get its content-type from init headers if one is provided FAIL Can't find variable: Headers
Request with cache mode: only-if-cached and fetch mode: same-origin FAIL Can't find variable: Request

@w3c-bots
Copy link

w3c-bots commented Aug 3, 2017

View the complete job log.

Chrome (unstable)

Testing web-platform-tests at revision 1438494
Using binary None
Starting tests

@w3c-bots
Copy link

w3c-bots commented Aug 3, 2017

View the complete job log.

Sauce (MicrosoftEdge)

Testing web-platform-tests at revision 1438494
Using binary None
Starting tests
All results were stable

All results

5 tests ran
/fetch/api/abort/general-serviceworker.https.html
Subtest Results Messages
OK
General fetch abort tests in a service worker FAIL Expected ')'
/fetch/api/abort/general-sharedworker.html
Subtest Results Messages
OK
General fetch abort tests - shared worker FAIL 'SharedWorker' is undefined
/fetch/api/abort/general.any.html
Subtest Results Messages
OK
Untitled FAIL Expected ')'
/fetch/api/abort/general.any.worker.html
Subtest Results Messages
OK
Untitled FAIL Expected ')'
/fetch/api/request/request-error.html
Subtest Results Messages
OK
RequestInit's window is not null FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
Input URL is not valid FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
Input URL has credentials FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
RequestInit's mode is navigate FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
RequestInit's referrer is invalid FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
RequestInit's method is invalid FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
RequestInit's method is forbidden FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
RequestInit's mode is no-cors and method is not simple FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
RequestInit's mode is no-cors and integrity is not empty FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
RequestInit's cache mode is only-if-cached and mode is not same-origin FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
Request with cache mode: only-if-cached and fetch mode cors FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
Request with cache mode: only-if-cached and fetch mode no-cors FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
Bad referrerPolicy init parameter value FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
Bad mode init parameter value FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
Bad credentials init parameter value FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
Bad cache init parameter value FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
Bad redirect init parameter value FAIL assert_throws: Expect TypeError exception function "() => new Request(...args)" threw object "TypeMismatchError" ("TypeMismatchError") expected object "TypeError" ("TypeError")
Request should get its content-type from the init request PASS
Request should not get its content-type from the init request if init headers are provided PASS
Request should get its content-type from the body if none is provided PASS
Request should get its content-type from init headers if one is provided PASS
Request with cache mode: only-if-cached and fetch mode: same-origin FAIL TypeMismatchError

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Instead of fetch/api/abort/general.html and fetch/api/abort/general-worker.html you could have those generated automatically by renaming fetch/api/abort/general.js to fetch/api/abort/general.any.js and using the include syntax detailed at http://web-platform-tests.org/writing-tests/testharness.html (you also need to tweak the shared worker wrapper a bit to load general.any.worker.js).

Looks good overall though.

@jakearchibald
Copy link
Contributor Author

@annevk Thanks! Did not know.

@jgraham I've made some changes to the server to allow .any to work with shared workers and service workers. I've also added the ability to add headers per handler – the service worker won't accepts scripts without a valid script content-type.

@annevk
Copy link
Member

annevk commented Aug 4, 2017

@jakearchibald oh that looks cool, but please see #4210. We can't change .any like that I think given the existing tests.

@jakearchibald
Copy link
Contributor Author

Doh, I guessed it wouldn't be that easy.

@jakearchibald
Copy link
Contributor Author

@jgraham I've reverting most of my server changes due to #4210, but I've left the headers addition. Could you review?

@@ -169,6 +174,7 @@ class AnyHtmlHandler(HtmlWrapperHandler):


class AnyWorkerHandler(WrapperHandler):
headers = [('Content-Type', 'application/javascript')]
Copy link
Member

Choose a reason for hiding this comment

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

Should be text/javascript if you want to follow the HTML Standard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wow, I always thought application/javascript was the preferred type. TIL

@jakearchibald
Copy link
Contributor Author

@jgraham could I get a yay/nay for https://github.com/w3c/web-platform-tests/pull/6736/files#diff-54595105eb1b125bb44120e81a893f4eR40? It's a small change, but needed for service worker tests.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

I assume there's already a test that checks that signal and requestSignal are not equal?


controller.abort();

assert_true(requestAborted, "Original request signal aborted");
Copy link
Member

Choose a reason for hiding this comment

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

This assert could be inside the clonedRequest.signal event listener. That way we also verify that the order is correct. Should we also check here that for both the .aborted flag is flipped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I move the tests within the event callbacks then failure to call those callbacks will look like success. I guess I could push items onto an array to check order too.

Copy link
Member

Choose a reason for hiding this comment

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

You could also use a signal variable that you change in the first listener and that you then assert has changed in the second listener and then change again and then assert it has changed after that listener.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From IRC: As spec'd, the clone's abort event would run before the original's. We need to figure out if this is a problem. If it is, we could change the AbortSignal spec so it has a list of "following signals", which copy things that happen to the original, but it happens after the original's event has despatched.

@jakearchibald
Copy link
Contributor Author

I assume there's already a test that checks that signal and requestSignal are not equal?

Yep!

@gsnedders gsnedders removed their request for review August 11, 2017 14:18
@@ -40,6 +40,8 @@ class WrapperHandler(object):

__meta__ = abc.ABCMeta

headers = ()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use a list ([]).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing. Why btw? Just for my own learning, I haven't done python in a while.

Copy link
Contributor

Choose a reason for hiding this comment

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

A tuple is immutable, a list is mutable (and, argument from purity, tuples are supposed to be things where each field has a predefined meaning, not arbitrary ordered collections).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@jgraham
Copy link
Contributor

jgraham commented Aug 11, 2017

The serve.py changes look fine.

@jakearchibald
Copy link
Contributor Author

@annevk feedback addressed.

Also filed whatwg/dom#493 to discuss event ordering.

@jakearchibald jakearchibald merged commit fed14ec into web-platform-tests:master Aug 14, 2017
@jakearchibald jakearchibald deleted the fetch-abort branch August 14, 2017 11:50
rachelandrew pushed a commit to rachelandrew/web-platform-tests that referenced this pull request Nov 8, 2017
* Making use of .any.js for multi-context tests
* Testing that request errors take priority over AbortError
* Ensure request stream error is same as promise reject error
* Testing request clone behaviour
* Adding JS header to .any.worker.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants