Bug 198495 - Date.prototype.toJSON throws if toISOString returns an object
Summary: Date.prototype.toJSON throws if toISOString returns an object
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Minor
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-06-03 14:00 PDT by Alexey Shvayka
Modified: 2019-08-19 16:28 PDT (History)
13 users (show)

See Also:


Attachments
Patch (1.35 KB, patch)
2019-06-03 14:23 PDT, Alexey Shvayka
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews103 for mac-highsierra (3.23 MB, application/zip)
2019-06-03 15:13 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews107 for mac-highsierra-wk2 (3.03 MB, application/zip)
2019-06-03 15:30 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews215 for win-future (13.71 MB, application/zip)
2019-06-03 15:54 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews117 for mac-highsierra (3.02 MB, application/zip)
2019-06-03 16:01 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews122 for ios-simulator-wk2 (2.60 MB, application/zip)
2019-06-03 16:20 PDT, Build Bot
no flags Details
Patch (3.52 KB, patch)
2019-06-03 19:57 PDT, Alexey Shvayka
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews105 for mac-highsierra-wk2 (3.01 MB, application/zip)
2019-06-04 01:33 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews211 for win-future (13.77 MB, application/zip)
2019-06-04 02:59 PDT, Build Bot
no flags Details
Patch (3.68 KB, patch)
2019-06-05 05:33 PDT, Alexey Shvayka
no flags Details | Formatted Diff | Diff
Patch (6.10 KB, patch)
2019-06-18 12:47 PDT, Alexey Shvayka
no flags Details | Formatted Diff | Diff
Patch (5.74 KB, patch)
2019-08-19 14:01 PDT, Alexey Shvayka
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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 Build Bot 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.