Bug 32492

Summary: Missing support for document.createEvent("OrientationEvent")
Product: WebKit Reporter: Greg Bolsinga <bolsinga>
Component: WebCore JavaScriptAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: benm, commit-queue, cshu, joepeck, laszlo.gombos, steveblock, tonikitoo, yongjun_zhang
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 50171    
Bug Blocks:    
Attachments:
Description Flags
Implement document.createEvent("OrientationEvent") to help unit testing onOrientationEvent.
none
(2nd try) fix the typo in test description.
none
Address Joe's comment.
none
fix patch none

Description Greg Bolsinga 2009-12-13 10:39:57 PST
When support for OrientationEvents went in with http://trac.webkit.org/changeset/48609, it doesn't have create support.

<rdar://problem/7458132>
Comment 1 Joseph Pecoraro 2010-04-08 14:55:39 PDT
Just some background information: Like other events on the window it can be simulated with createEvent and initEvent:

    var e = document.createEvent("Event");
    e.initEvent('orientationchange', false, false);
    window.dispatchEvent(e);
Comment 2 Yongjun Zhang 2010-10-14 16:24:16 PDT
Created attachment 70795 [details]
Implement document.createEvent("OrientationEvent") to help unit testing onOrientationEvent.
Comment 3 Yongjun Zhang 2010-10-14 16:25:54 PDT
(In reply to comment #2)
> Created an attachment (id=70795) [details]
> Implement document.createEvent("OrientationEvent") to help unit testing onOrientationEvent.

Oops! typo, should be onOrientationChange.
Comment 4 Yongjun Zhang 2010-10-15 09:20:34 PDT
Created attachment 70874 [details]
(2nd try) fix the typo in test description.
Comment 5 Joseph Pecoraro 2010-10-15 09:45:56 PDT
Comment on attachment 70874 [details]
(2nd try) fix the typo in test description.

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

> LayoutTests/fast/dom/DeviceOrientation/create-event-onorientationchange-expected.txt:11
> +Tests that document.createEvent() works with orientationChange
> +
> +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
> +
> +
> +
> +
> +
> +PASS successfullyParsed is true
> +
> +TEST COMPLETE

This is rather blank. There is no PASS / FAIL message in the common case.

> LayoutTests/fast/dom/DeviceOrientation/script-tests/create-event-onorientationchange.js:15
> +try {
> +    var event = document.createEvent("OrientationEvent");
> +    event.initEvent("orientationchange", false, false);
> +    window.dispatchEvent(event);
> +} catch(e) {
> +}

I would suggest outputting something in the catch { ... } along the lines of
"Orientation Events don't appear to be enabled or implemented".

I don't know the best way to reduce the overhead of submitting a test which
will only pass behind an ENABLE flag.
Comment 6 Yongjun Zhang 2010-10-18 09:37:39 PDT
(In reply to comment #5)
> (From update of attachment 70874 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=70874&action=review
> 
> > LayoutTests/fast/dom/DeviceOrientation/create-event-onorientationchange-expected.txt:11
> > +Tests that document.createEvent() works with orientationChange
> > +
> > +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
> > +
> > +
> > +
> > +
> > +
> > +PASS successfullyParsed is true
> > +
> > +TEST COMPLETE
> 
> This is rather blank. There is no PASS / FAIL message in the common case.
> 
> > LayoutTests/fast/dom/DeviceOrientation/script-tests/create-event-onorientationchange.js:15
> > +try {
> > +    var event = document.createEvent("OrientationEvent");
> > +    event.initEvent("orientationchange", false, false);
> > +    window.dispatchEvent(event);
> > +} catch(e) {
> > +}
> 
> I would suggest outputting something in the catch { ... } along the lines of
> "Orientation Events don't appear to be enabled or implemented".
> 
> I don't know the best way to reduce the overhead of submitting a test which
> will only pass behind an ENABLE flag.

thanks for the comments.  Folder fast/dom/DeviceOrientation/ is skipped for most ports, and for those ports (Android?) that enabled device orientation events but not onorientationchange, this test will fail by default, hence the failed result as expected result.   The port need to override the expected result if onorientationchange is implemented.
Comment 7 Yongjun Zhang 2010-10-18 10:14:59 PDT
Created attachment 71051 [details]
Address Joe's comment.
Comment 8 WebKit Commit Bot 2010-10-18 12:34:17 PDT
Comment on attachment 71051 [details]
Address Joe's comment.

Clearing flags on attachment: 71051

Committed r69984: <http://trac.webkit.org/changeset/69984>
Comment 9 WebKit Commit Bot 2010-10-18 12:34:23 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Steve Block 2010-10-25 08:11:12 PDT
I'm not sure why you've added this test to fast/dom/DeviceOrientation. This LayoutTest directory is to test the implementation of the W3C DeviceOrientationEvent (http://dev.w3.org/geo/api/spec-source-orientation.html, https://bugs.webkit.org/show_bug.cgi?id=30335).

Your change seems to be concerned with the OrientationEvent, which is completely separate.

Furthermore, as you point out, ports that don't implement DeviceOrientation skip this entire directory of tests. Those that do implement it should pass all tests. So an expected result which represents failure is probably not appropriate.

Perhaps you could move the test to a more appropriate location?
Comment 11 Yongjun Zhang 2010-10-25 09:32:40 PDT
(In reply to comment #10)
> I'm not sure why you've added this test to fast/dom/DeviceOrientation. This LayoutTest directory is to test the implementation of the W3C DeviceOrientationEvent (http://dev.w3.org/geo/api/spec-source-orientation.html, https://bugs.webkit.org/show_bug.cgi?id=30335).
>
> Your change seems to be concerned with the OrientationEvent, which is completely separate.
>

Thanks for the comments, there are indeed different events.  I will move this test to a different location.
 
> Furthermore, as you point out, ports that don't implement DeviceOrientation skip this entire directory of tests. Those that do implement it should pass all tests. So an expected result which represents failure is probably not appropriate.
> 

I can add it to skipped tests for each port to get rid of the expected failure result.

Thanks.
Comment 12 Steve Block 2010-11-30 02:39:13 PST
> Thanks for the comments, there are indeed different events.  I will move this
> test to a different location.
Please move this test, or let me know where it should be moved to, else I think we should remove it.
Comment 13 Laszlo Gombos 2010-11-30 05:07:43 PST
Perhaps LayoutTests/fast/dom/Orientation ?
Comment 14 Chang Shu 2010-11-30 06:58:28 PST
Created attachment 75142 [details]
fix patch

move test case
Comment 15 Laszlo Gombos 2010-11-30 09:10:25 PST
Comment on attachment 75142 [details]
fix patch

LGTM, r+. Thanks.
Comment 16 WebKit Commit Bot 2010-11-30 20:03:39 PST
Comment on attachment 75142 [details]
fix patch

Rejecting patch 75142 from commit-queue.

Failed to run "['./WebKitTools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '--bot-id=eseidel-cq-sl', 'build', '--no-clean', '--no-update', '--build-style=both']" exit_code: 1
ERROR: Working directory has local commits, pass --force-clean to continue.

Full output: http://queues.webkit.org/results/6512003
Comment 17 Chang Shu 2010-12-01 07:36:55 PST
Comment on attachment 75142 [details]
fix patch

cleanup flags after manual commit
r73019
http://trac.webkit.org/changeset/73019
Comment 18 Steve Block 2010-12-01 08:25:48 PST
Thanks!