Bug 152181 - Refactoring HTMLMediaElement getStartDate() implementation
Summary: Refactoring HTMLMediaElement getStartDate() implementation
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Minor
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-12-11 11:41 PST by Pascal Jacquemart
Modified: 2016-04-02 19:23 PDT (History)
7 users (show)

See Also:


Attachments
Just checking if this change may not break other tests (5.09 KB, patch)
2015-12-11 11:46 PST, Pascal Jacquemart
darin: review-
darin: commit-queue-
Details | Formatted Diff | Diff
Just checking if this change may not break other tests 2 (4.99 KB, patch)
2015-12-21 05:48 PST, Pascal Jacquemart
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews103 for mac-yosemite (905.12 KB, application/zip)
2015-12-21 06:41 PST, Build Bot
no flags Details
Archive of layout-test-results from ews107 for mac-yosemite-wk2 (1.05 MB, application/zip)
2015-12-21 06:44 PST, Build Bot
no flags Details
Archive of layout-test-results from ews113 for mac-yosemite (804.42 KB, application/zip)
2015-12-21 06:50 PST, Build Bot
no flags Details
Just checking if this change may not break other tests 3 (4.62 KB, patch)
2015-12-21 07:41 PST, Pascal Jacquemart
no flags Details | Formatted Diff | Diff
For testing (1.31 KB, patch)
2016-01-05 09:00 PST, Pascal Jacquemart
darin: review-
Details | Formatted Diff | Diff
Make sure HTMLMediaElement getStartDate() always returns a valid Date object (4.35 KB, patch)
2016-01-28 07:18 PST, Pascal Jacquemart
eric.carlson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pascal Jacquemart 2015-12-11 11:41:29 PST
The spec says [1]:

  The getStartDate() method must return a new Date object representing 
  the current timeline offset.

where "a new Date object" is defined as:

  When this specification requires a user agent to create a Date object 
  representing a particular time (which could be the special value 
  Not-a-Number) ...

Current implementation have some JSC quirks to return NaN directly instaead of a valid Date object
Comment 1 Pascal Jacquemart 2015-12-11 11:46:39 PST
Created attachment 267179 [details]
Just checking if this change may not break other tests

Just checking if this change may not break other tests
Comment 2 Darin Adler 2015-12-12 16:08:22 PST
Comment on attachment 267179 [details]
Just checking if this change may not break other tests

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

This patch should only contain the change to HTMLMediaElement.idl. Deleting all the unneeded code can be done in a follow-up that does not change behavior.

> Source/WebCore/bindings/js/JSDOMBinding.cpp:124
>  JSValue jsDateOrNull(ExecState* exec, double value)
>  {
> -    if (!std::isfinite(value))
> +    if (std::isinf(value))
>          return jsNull();
> +    if (std::isnan(value))
> +        return DateInstance::create(exec, exec->lexicalGlobalObject()->dateStructure());
>      return DateInstance::create(exec->vm(), exec->lexicalGlobalObject()->dateStructure(), value);
>  }

This changes the behavior for every callers of jsDateOrNull when the value is a NaN. We do not want to make that global change.
Comment 3 Pascal Jacquemart 2015-12-21 05:48:00 PST
Created attachment 267745 [details]
Just checking if this change may not break other tests 2
Comment 4 Build Bot 2015-12-21 06:41:13 PST
Comment on attachment 267745 [details]
Just checking if this change may not break other tests 2

Attachment 267745 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/588913

New failing tests:
imported/w3c/web-platform-tests/html/dom/interfaces.html
http/tests/media/hls/video-controller-getStartDate.html
http/tests/local/fileapi/file-last-modified.html
imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/text.html
imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/hidden.html
Comment 5 Build Bot 2015-12-21 06:41:16 PST
Created attachment 267746 [details]
Archive of layout-test-results from ews103 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 6 Build Bot 2015-12-21 06:44:47 PST
Comment on attachment 267745 [details]
Just checking if this change may not break other tests 2

Attachment 267745 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/588915

New failing tests:
imported/w3c/web-platform-tests/html/dom/interfaces.html
imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/hidden.html
imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/text.html
http/tests/media/hls/video-controller-getStartDate.html
Comment 7 Build Bot 2015-12-21 06:44:50 PST
Created attachment 267747 [details]
Archive of layout-test-results from ews107 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 8 Build Bot 2015-12-21 06:50:55 PST
Comment on attachment 267745 [details]
Just checking if this change may not break other tests 2

Attachment 267745 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/588914

New failing tests:
http/tests/local/fileapi/file-last-modified.html
imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/hidden.html
imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/text.html
http/tests/media/hls/video-controller-getStartDate.html
Comment 9 Build Bot 2015-12-21 06:50:58 PST
Created attachment 267748 [details]
Archive of layout-test-results from ews113 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 10 Pascal Jacquemart 2015-12-21 07:41:25 PST
Created attachment 267750 [details]
Just checking if this change may not break other tests 3
Comment 11 Pascal Jacquemart 2016-01-05 09:00:49 PST
Created attachment 268284 [details]
For testing
Comment 12 Eric Carlson 2016-01-06 10:11:01 PST
Comment on attachment 268284 [details]
For testing

This looks fine, but should this patch also change HTMLMediaElement.idl because getStartDate will now always return a valid Date object?
Comment 13 Darin Adler 2016-01-18 19:19:33 PST
Comment on attachment 268284 [details]
For testing

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

> Source/WebCore/bindings/js/JSDOMBinding.cpp:120
>  JSValue jsDateOrNaN(ExecState* exec, double value)
>  {
> -    if (std::isnan(value))
> -        return jsDoubleNumber(value);
> -    return jsDateOrNull(exec, value);
> +    return DateInstance::create(exec->vm(), exec->lexicalGlobalObject()->dateStructure(), value);
>  }

If this function no longer returns a NaN when passed a NaN, then it should not be named jsDateOrNaN. We should not change what it does without changing its name.
Comment 14 Pascal Jacquemart 2016-01-28 07:18:05 PST
Created attachment 270113 [details]
Make sure HTMLMediaElement getStartDate() always returns a valid Date object
Comment 15 Eric Carlson 2016-01-28 07:23:08 PST
Comment on attachment 270113 [details]
Make sure HTMLMediaElement getStartDate() always returns a valid Date object

Thank you for sticking with this Pascal!
Comment 16 Darin Adler 2016-01-28 08:20:42 PST
Comment on attachment 270113 [details]
Make sure HTMLMediaElement getStartDate() always returns a valid Date object

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

This doesn’t seem right. Is it really acceptable to create a date object with the value NaN?

Why no new test case? What’s the point of making this change if it doesn’t fix a bug?

> Source/WebCore/bindings/js/JSDOMBinding.cpp:120
> +JSValue jsDate(ExecState* exec, double value)
> +{
> +    return DateInstance::create(exec->vm(), exec->lexicalGlobalObject()->dateStructure(), value);
> +}

What does this function do if it’s passed null or infinity? Is it legal to create a date instance with such values? Is it a programming error to call this? If so, then should something ASSERT(std::isfinite(value))? Maybe DateInstance::create already does that?
Comment 17 Radar WebKit Bug Importer 2016-04-02 19:23:14 PDT
<rdar://problem/25513326>