-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Test StorageEvent constructor and initStorageEvent() #13368
Conversation
Tests: web-platform-tests/wpt#13368 Fixes #1054.
A little report on failures in various browsers:
The "initStorageEvent with 8 sensible arguments" test passes on all, suggesting that the code path that matters most is actually pretty fine, interop-wise. (Unsurprising.) |
webstorage/event_constructor.html
Outdated
@@ -9,21 +9,18 @@ | |||
<h1>event_session_Constructor</h1> | |||
<div id="log"></div> | |||
<script> | |||
test(function() { | |||
var t = async_test("storageeventinit test"); | |||
async_test(function(t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a drive-by change to make the test more similar event_constructor_eventinit.html. All the business with dispatchEvent
actually isn't necessary to test the constructor, but I just wanted to get of the extra no-op test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a synchronous test as you're not actually waiting for anything. You still need to wrap the callbacks as you've done though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but the whole dispatchEvent
thing is also unnecessary. This made it consistent with other tests, and I don't want to rewrite them all since it's pretty harmless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initstorageevent.html could have been .any.js, but this will do.
webstorage/event_constructor.html
Outdated
@@ -9,21 +9,18 @@ | |||
<h1>event_session_Constructor</h1> | |||
<div id="log"></div> | |||
<script> | |||
test(function() { | |||
var t = async_test("storageeventinit test"); | |||
async_test(function(t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a synchronous test as you're not actually waiting for anything. You still need to wrap the callbacks as you've done though.
The use of `async_test` was already unnecessary as `dispatchEvent` synchronously invokes listeners, and use of `dispatcEvent` itself is not necessary to test the constructor, so simplify to just `test`s.
c517898
to
56c3da3
Compare
@@ -1,32 +1,81 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>WebStorage Test: StorageEvent - init value</title> | |||
<title>WebStorage Test: StorageEvent - constructor</title> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've run these tests manually. They pass 5/5 in Chrome, Firefox in Safari. In Edge on real hardware and on BrowserStack however, the test seems to crash Edge, saying "This page is having a problem loading". @thejohnjansen FYI, there's probably a real bug here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've narrowed it down to new StorageEvent('storage', { url: null })
. I'll file a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, thanks!
Tests: web-platform-tests/wpt#13368 Fixes #1054.
I've merged the spec change with the intention of merging this right after, but then saw that Travis was failing. Looks like a network flake, so I've restarted. |
assert_equals(event.key, null, 'event.key'); | ||
assert_equals(event.oldValue, null, 'event.oldValue'); | ||
assert_equals(event.newValue, null, 'event.newValue'); | ||
assert_equals(event.url, 'undefined', 'event.url'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@foolip I'm implementing initStorageEvent()
in jsdom and got an error on this line. Should this be the empty string rather than 'undefined'
, given the default value for url
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was a mistake. Only the non-optional argument (type) will be the string 'undefined'. Sending fix.
Tests: web-platform-tests/wpt#13368 Fixes whatwg#1054.
Tests: web-platform-tests/wpt#13368 Fixes whatwg#1054.
Follows whatwg/html#4063.