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

Test StorageEvent constructor and initStorageEvent() #13368

Merged
merged 2 commits into from
Oct 5, 2018

Conversation

foolip
Copy link
Member

@foolip foolip commented Oct 4, 2018

Follows whatwg/html#4063.

@foolip
Copy link
Member Author

foolip commented Oct 4, 2018

A little report on failures in various browsers:

  • Chrome+Safari have no required arguments, and key isn't nullable.
  • Edge has 8 (!) required arguments, arguments key, oldValue and newValue aren't nullable, and storageArea is weird because it can take the value undefined in the last test.
  • Firefox: url is nullable, otherwise everything passes

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.)

@@ -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) {
Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

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.

initstorageevent.html could have been .any.js, but this will do.

@@ -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) {
Copy link
Member

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.

foolip added 2 commits October 5, 2018 15:15
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.
@foolip foolip force-pushed the foolip/initStorageEvent branch from c517898 to 56c3da3 Compare October 5, 2018 13:38
@foolip foolip changed the title Test initStorageEvent() Test StorageEvent constructor and initStorageEvent() Oct 5, 2018
@@ -1,32 +1,81 @@
<!DOCTYPE HTML>
<html>
<head>
<title>WebStorage Test: StorageEvent - init value</title>
<title>WebStorage Test: StorageEvent - constructor</title>
Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@inexorabletash inexorabletash left a comment

Choose a reason for hiding this comment

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

looks great, thanks!

foolip added a commit to whatwg/html that referenced this pull request Oct 5, 2018
@foolip
Copy link
Member Author

foolip commented Oct 5, 2018

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.

@foolip foolip merged commit bd5f340 into master Oct 5, 2018
@foolip foolip deleted the foolip/initStorageEvent branch October 5, 2018 19:34
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');
Copy link
Member

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?

Copy link
Member Author

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.

mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
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.

5 participants