Bug 108196

Summary: Notification.requestPermission callback should be optional
Product: WebKit Reporter: Jake Archibald <jaffathecake>
Component: DOMAssignee: Kaustubh Atrawalkar <kaustubh.ra>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, buildbot, dglazkov, esprehn+autocc, gyuyoung.kim, haraken, japhet, jochen, kaustubh.ra, ojan.autocc, ossy, rakuco, rniwa, schenney, tmpsantos, vsevik, webkit-ews, webkit.review.bot, zarvai
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 110846, 111096    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Jake Archibald 2013-01-29 08:05:52 PST
Currently, a DOM error is thrown if the callback is omitted.

Spec:
http://notifications.spec.whatwg.org/#api

Spec change discussion:
https://github.com/whatwg/notifications/pull/1
Comment 1 Kaustubh Atrawalkar 2013-02-22 15:22:25 PST
As per the discussion, I agree with making requestPermssion optional. Providing patch to make the proposed changes.
Comment 2 Kaustubh Atrawalkar 2013-02-22 15:27:09 PST
Created attachment 189847 [details]
Patch
Comment 3 Adam Barth 2013-02-23 09:46:39 PST
Comment on attachment 189847 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=189847&action=review

> Source/WebCore/Modules/notifications/Notification.idl:54
> -    [Custom] static void requestPermission(in NotificationPermissionCallback callback);
> +    [Custom] static void requestPermission(in [Optional, Callback] NotificationPermissionCallback callback);

Why does it need to be [Custom]?  It looks like it just needs [CallWith=ScriptExecutionContext].
Comment 4 Adam Barth 2013-02-23 09:47:24 PST
Comment on attachment 189847 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=189847&action=review

> LayoutTests/fast/notifications/notifications-request-permission-optional.html:18
> +    shouldThrow('window.Notification.requestPermission()', notEnoughArguments);

Doesn't this show that the argument is not optional?  /me is confused.
Comment 5 Kaustubh Atrawalkar 2013-02-23 12:12:32 PST
(In reply to comment #3)
> Why does it need to be [Custom]?  It looks like it just needs [CallWith=ScriptExecutionContext].

Yes, seems fine to me as well. I just kept the semantics as it is and added optional. But changing it as suggested would be better. Will do that.

(In reply to comment #4) 
> > LayoutTests/fast/notifications/notifications-request-permission-optional.html:18
> > +    shouldThrow('window.Notification.requestPermission()', notEnoughArguments);
> 
> Doesn't this show that the argument is not optional?  /me is confused.

Basically it will throw error if the argument is not optional. When requestPermission() is called without any arguments it should work as it is. If the compiler detects the argument is missing, it will throw error. in this case, as the argument is optional, it wont. I hope my understanding is right. please correct me if wrong.
Comment 6 Adam Barth 2013-02-23 12:23:48 PST
Comment on attachment 189847 [details]
Patch

I'm, sorry, but I don't understand what you are saying.  Your patch doesn't actually change any behavior because this function has Custom bindings.  I believe your test demonstrates that the argument is not optional.
Comment 7 Adam Barth 2013-02-23 12:24:14 PST
Comment on attachment 189847 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=189847&action=review

> LayoutTests/fast/notifications/notifications-request-permission-optional.html:9
> +function runTests()

I don't think this function is even called.
Comment 8 Kaustubh Atrawalkar 2013-02-25 16:50:12 PST
Created attachment 190156 [details]
Patch
Comment 9 Kaustubh Atrawalkar 2013-02-25 16:52:15 PST
(In reply to comment #6)
> (From update of attachment 189847 [details])
> I'm, sorry, but I don't understand what you are saying.  Your patch doesn't actually change any behavior because this function has Custom bindings.  I believe your test demonstrates that the argument is not optional.

I removed the Custom bindings and updated the idl file with [CallWith=ScriptExecutionContext]. Also updated the test case to make a call. Can you review once?
Comment 10 Adam Barth 2013-02-25 16:57:55 PST
Comment on attachment 190156 [details]
Patch

this looks much better
Comment 11 Early Warning System Bot 2013-02-25 17:13:30 PST
Comment on attachment 190156 [details]
Patch

Attachment 190156 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/16756535
Comment 12 Kaustubh Atrawalkar 2013-02-25 17:16:06 PST
(In reply to comment #10)
> (From update of attachment 190156 [details])
> this looks much better

Thank you for the quick review. This is still not final patch. Seems there are few build breaks. I will fix those and put up patch again.
Comment 13 Early Warning System Bot 2013-02-25 17:17:11 PST
Comment on attachment 190156 [details]
Patch

Attachment 190156 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/16744612
Comment 14 Build Bot 2013-02-25 17:30:42 PST
Comment on attachment 190156 [details]
Patch

Attachment 190156 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://queues.webkit.org/results/16743632
Comment 15 Build Bot 2013-02-25 18:02:58 PST
Comment on attachment 190156 [details]
Patch

Attachment 190156 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/16746642
Comment 16 WebKit Review Bot 2013-02-26 13:55:01 PST
Comment on attachment 190156 [details]
Patch

Attachment 190156 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://webkit-commit-queue.appspot.com/results/16780353

New failing tests:
fast/notifications/notifications-rtl.html
Comment 17 Kaustubh Atrawalkar 2013-02-26 15:56:52 PST
Created attachment 190382 [details]
Patch
Comment 18 Kentaro Hara 2013-02-26 16:06:50 PST
Comment on attachment 190382 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=190382&action=review

The change looks good. A couple of comments on the test.

> LayoutTests/fast/notifications/notifications-request-permission-optional.html:9
> +function log(message)
> +{
> +    document.getElementById("result").innerHTML += message + "<br>";
> +}

Nit: Remove this.

> LayoutTests/fast/notifications/notifications-request-permission-optional.html:14
> +    if (window.testRunner)
> +        testRunner.dumpAsText();
> +

Nit: This is not needed.

> LayoutTests/fast/notifications/notifications-request-permission-optional.html:16
> +    if (!window.webkitNotifications)
> +        log("FAIL: No webkitNotification interface!");

You can write: shouldNotBe('!window.webkitNotifications');

> LayoutTests/fast/notifications/notifications-request-permission-optional.html:25
> +runTests();

Nit: Now the test is just two lines. You can directly write the test here.

> LayoutTests/fast/notifications/notifications-request-permission-optional.html:27
> +</body>

Please add <script src="../js/resources/js-test-post.js"></script>
Comment 19 Kaustubh Atrawalkar 2013-02-26 16:40:37 PST
(In reply to comment #18)
> (From update of attachment 190382 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=190382&action=review
> 
> The change looks good. A couple of comments on the test.

Thanks :) I made those change. Will be landing patch soon.
Comment 20 Kaustubh Atrawalkar 2013-02-26 16:55:03 PST
Committed r144126: <http://trac.webkit.org/changeset/144126>
Comment 21 Stephen Chenney 2013-02-26 18:43:43 PST
Reopening. This is causing crashes in fast/notifications/notifications-request-permission.html

http://test-results.appspot.com/dashboards/flakiness_dashboard.html#tests=fast%2Fnotifications%2Fnotifications-request-permission.html

Expectations added in r144134.
Comment 22 Stephen Chenney 2013-02-26 18:44:54 PST
Why on earth can't I reopen this bug?
Comment 23 Adam Barth 2013-02-26 21:02:55 PST
Reopening
Comment 24 Adam Barth 2013-02-26 21:03:09 PST
Hum...   Seems to work for me...
Comment 25 Adam Barth 2013-02-26 21:04:34 PST
Stephen, I just ran a script to give you canconfirm and editbugs.  You probably already had them, however.  :)
Comment 26 Vsevolod Vlasov 2013-02-27 00:35:24 PST
Layout test fast/notifications/notifications-request-permission-optional.html is also crashing flakily.
Filed https://bugs.webkit.org/show_bug.cgi?id=110956 and marked as crashing in http://trac.webkit.org/changeset/144153
Comment 27 Thiago Marcos P. Santos 2013-02-27 01:33:50 PST
Just a nit, remember to fix the bindings generator tests that is failing after this patch.
Comment 28 Kaustubh Atrawalkar 2013-02-27 11:05:10 PST
I will try to fix these asap. Thank you.
Comment 29 Stephen Chenney 2013-02-27 11:39:22 PST
I fixed the bindings generator test in http://trac.webkit.org/changeset/144176
Comment 30 Kaustubh Atrawalkar 2013-02-27 14:51:57 PST
Created attachment 190608 [details]
Patch
Comment 31 Early Warning System Bot 2013-02-27 15:10:26 PST
Comment on attachment 190608 [details]
Patch

Attachment 190608 [details] did not pass qt-ews (qt):
Output: http://webkit-commit-queue.appspot.com/results/16758269
Comment 32 Kaustubh Atrawalkar 2013-02-27 15:25:48 PST
Thats what i was trying to find the JS Custom bindings file for NotificationCenter. It was with different name. Adding new patch.
Comment 33 Kaustubh Atrawalkar 2013-02-27 15:55:00 PST
Created attachment 190622 [details]
Patch
Comment 34 Zoltan Arvai 2013-02-28 02:48:23 PST
On Qt fast/notifications/notifications-request-permission-optional.html test causes other test to crash:

02:19:50.168 16160 worker/0 fast/notifications/notifications-request-permission-optional.html passed
02:19:50.294 16160 worker/0 fast/notifications/notifications-rtl.html crashed, (stderr lines):

http://build.webkit.sed.hu/builders/x86-64%20Linux%20Qt%20Release/builds/48658/steps/layout-test/logs/stdio
Comment 35 Adam Barth 2013-02-28 11:27:55 PST
If this patch is causing crashes, we should roll it out.
Comment 36 Kaustubh Atrawalkar 2013-02-28 12:45:40 PST
Created attachment 190786 [details]
Patch
Comment 37 Kaustubh Atrawalkar 2013-02-28 12:58:49 PST
Merged both patches together. It required NotificationCenter class as well to have requestPermission callback as optional. Removed both custom bindings from Notification.idl & NotificationCenter.idl. Please review once.
Comment 38 Kentaro Hara 2013-02-28 13:17:45 PST
What is the current status? The patch that caused the crashes was rolled out, and now you are going to reland the patch with proper fixes, right?
Comment 39 Kaustubh Atrawalkar 2013-02-28 13:45:09 PST
Yes that's correct. I have merged both patches together. Can you review?
Comment 40 Kentaro Hara 2013-02-28 13:46:18 PST
Comment on attachment 190786 [details]
Patch

LGTM. Please keep watching the build tree when landing.
Comment 41 Kaustubh Atrawalkar 2013-02-28 13:55:29 PST
(In reply to comment #40)
> (From update of attachment 190786 [details])
> LGTM. Please keep watching the build tree when landing.

Sure I will keep eye on build tree. Thanks.
Comment 42 WebKit Review Bot 2013-02-28 14:59:48 PST
Comment on attachment 190786 [details]
Patch

Clearing flags on attachment: 190786

Committed r144376: <http://trac.webkit.org/changeset/144376>
Comment 43 WebKit Review Bot 2013-02-28 14:59:55 PST
All reviewed patches have been landed.  Closing bug.
Comment 44 Kaustubh Atrawalkar 2013-02-28 17:28:31 PST
*** Bug 110956 has been marked as a duplicate of this bug. ***