Bug 198495

Summary: Date.prototype.toJSON throws if toISOString returns an object
Product: WebKit Reporter: Alexey Shvayka <ashvayka>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Minor CC: achristensen, commit-queue, ews-watchlist, fpizlo, keith_miller, mark.lam, msaboff, rniwa, ross.kirsling, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
See Also: https://bugs.webkit.org/show_bug.cgi?id=105282
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews103 for mac-highsierra
none
Archive of layout-test-results from ews107 for mac-highsierra-wk2
none
Archive of layout-test-results from ews215 for win-future
none
Archive of layout-test-results from ews117 for mac-highsierra
none
Archive of layout-test-results from ews122 for ios-simulator-wk2
none
Patch
none
Archive of layout-test-results from ews105 for mac-highsierra-wk2
none
Archive of layout-test-results from ews211 for win-future
none
Patch
none
Patch
none
Patch none

Description Alexey Shvayka 2019-06-03 14:00:33 PDT
Test case:
> Date.prototype.toJSON.call({toISOString: () => []})

Expected:
< []

Actual:
< TypeError: toISOString did not return a primitive value

ECMA262: https://tc39.github.io/ecma262/#sec-date.prototype.tojson (step 4)
Test262: https://github.com/tc39/test262/pull/2190
Comment 1 Radar WebKit Bug Importer 2019-06-03 14:12:08 PDT
<rdar://problem/51367166>
Comment 2 Alexey Shvayka 2019-06-03 14:23:02 PDT
Created attachment 371211 [details]
Patch
Comment 3 EWS Watchlist 2019-06-03 15:13:19 PDT
Comment on attachment 371211 [details]
Patch

Attachment 371211 [details] did not pass mac-ews (mac):
Output: https://webkit-queues.webkit.org/results/12366422

New failing tests:
js/dom/JSON-stringify.html
Comment 4 EWS Watchlist 2019-06-03 15:13:21 PDT
Created attachment 371218 [details]
Archive of layout-test-results from ews103 for mac-highsierra

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-highsierra  Platform: Mac OS X 10.13.6
Comment 5 EWS Watchlist 2019-06-03 15:30:47 PDT
Comment on attachment 371211 [details]
Patch

Attachment 371211 [details] did not pass mac-wk2-ews (mac-wk2):
Output: https://webkit-queues.webkit.org/results/12366518

New failing tests:
js/dom/JSON-stringify.html
Comment 6 EWS Watchlist 2019-06-03 15:30:48 PDT
Created attachment 371219 [details]
Archive of layout-test-results from ews107 for mac-highsierra-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-highsierra-wk2  Platform: Mac OS X 10.13.6
Comment 7 EWS Watchlist 2019-06-03 15:54:14 PDT
Comment on attachment 371211 [details]
Patch

Attachment 371211 [details] did not pass win-ews (win):
Output: https://webkit-queues.webkit.org/results/12366610

New failing tests:
js/dom/JSON-stringify.html
Comment 8 EWS Watchlist 2019-06-03 15:54:16 PDT
Created attachment 371222 [details]
Archive of layout-test-results from ews215 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews215  Port: win-future  Platform: CYGWIN_NT-10.0-17763-3.0.5-338.x86_64-x86_64-64bit
Comment 9 EWS Watchlist 2019-06-03 16:01:44 PDT
Comment on attachment 371211 [details]
Patch

Attachment 371211 [details] did not pass mac-debug-ews (mac):
Output: https://webkit-queues.webkit.org/results/12366526

New failing tests:
js/dom/JSON-stringify.html
Comment 10 EWS Watchlist 2019-06-03 16:01:46 PDT
Created attachment 371223 [details]
Archive of layout-test-results from ews117 for mac-highsierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews117  Port: mac-highsierra  Platform: Mac OS X 10.13.6
Comment 11 EWS Watchlist 2019-06-03 16:20:00 PDT
Comment on attachment 371211 [details]
Patch

Attachment 371211 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: https://webkit-queues.webkit.org/results/12366676

New failing tests:
js/dom/JSON-stringify.html
Comment 12 EWS Watchlist 2019-06-03 16:20:02 PDT
Created attachment 371226 [details]
Archive of layout-test-results from ews122 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews122  Port: ios-simulator-wk2  Platform: Mac OS X 10.14.5
Comment 13 Alexey Shvayka 2019-06-03 19:57:43 PDT
Created attachment 371240 [details]
Patch
Comment 14 EWS Watchlist 2019-06-04 01:33:00 PDT
Comment on attachment 371240 [details]
Patch

Attachment 371240 [details] did not pass mac-wk2-ews (mac-wk2):
Output: https://webkit-queues.webkit.org/results/12370562

New failing tests:
http/wpt/service-workers/service-worker-networkprocess-crash.html
Comment 15 EWS Watchlist 2019-06-04 01:33:02 PDT
Created attachment 371255 [details]
Archive of layout-test-results from ews105 for mac-highsierra-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-highsierra-wk2  Platform: Mac OS X 10.13.6
Comment 16 EWS Watchlist 2019-06-04 02:59:21 PDT
Comment on attachment 371240 [details]
Patch

Attachment 371240 [details] did not pass win-ews (win):
Output: https://webkit-queues.webkit.org/results/12370787

New failing tests:
fast/shadow-dom/svg-text-path-href-change-in-shadow-tree.html
Comment 17 EWS Watchlist 2019-06-04 02:59:24 PDT
Created attachment 371260 [details]
Archive of layout-test-results from ews211 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews211  Port: win-future  Platform: CYGWIN_NT-10.0-17763-3.0.5-338.x86_64-x86_64-64bit
Comment 18 Alex Christensen 2019-06-04 16:36:13 PDT
Comment on attachment 371240 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:8
> +        Don't throw TypeError if result of toISOString call is not a primitive.

What's the motivation for this change?  Is there a relevant specification?  How do other browsers behave?
Comment 19 Keith Miller 2019-06-05 01:50:06 PDT
Comment on attachment 371240 [details]
Patch

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

Are there no test262 tests for this? Can you run `./Tools/Scripts/test262-runner` and see it this fixes any tests?

>> Source/JavaScriptCore/ChangeLog:8
>> +        Don't throw TypeError if result of toISOString call is not a primitive.
> 
> What's the motivation for this change?  Is there a relevant specification?  How do other browsers behave?

I think Alexsey commented on this in the bugzilla. It's part of https://tc39.github.io/ecma262/#sec-date.prototype.tojson. Although, I think it'd be good to have a link to the spec in the ChangeLog.
Comment 20 Alexey Shvayka 2019-06-05 05:33:59 PDT
Created attachment 371390 [details]
Patch
Comment 21 Alexey Shvayka 2019-06-05 05:51:38 PDT
I've updated change logs to include spec link.
Other browsers agree on spec: please see CI results of https://github.com/tc39/test262/pull/2190
Comment 22 Alexey Shvayka 2019-06-18 12:47:43 PDT
Created attachment 372363 [details]
Patch

With test262 imported, this patch now fixes a few tests.
Comment 23 Alexey Shvayka 2019-08-19 14:01:23 PDT
Created attachment 376709 [details]
Patch

Rebase patch.
Comment 24 WebKit Commit Bot 2019-08-19 16:28:03 PDT
Comment on attachment 376709 [details]
Patch

Clearing flags on attachment: 376709

Committed r248876: <https://trac.webkit.org/changeset/248876>
Comment 25 WebKit Commit Bot 2019-08-19 16:28:05 PDT
All reviewed patches have been landed.  Closing bug.