WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
142829
[ES6] Implement Symbol.unscopables
https://bugs.webkit.org/show_bug.cgi?id=142829
Summary
[ES6] Implement Symbol.unscopables
Yusuke Suzuki
Reported
2015-03-18 11:10:08 PDT
Implement Symbol.unscopables support in with scope. It allow runtime to expose some generic name methods like `values`.
Attachments
Patch
(10.50 KB, patch)
2015-03-19 01:42 PDT
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(10.68 KB, patch)
2015-03-19 01:47 PDT
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(12.64 KB, patch)
2015-03-22 04:44 PDT
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(13.61 KB, patch)
2015-03-31 14:32 PDT
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(13.62 KB, patch)
2015-03-31 14:34 PDT
,
Yusuke Suzuki
ggaren
: review+
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Yusuke Suzuki
Comment 1
2015-03-19 01:42:58 PDT
Created
attachment 249026
[details]
Patch
Yusuke Suzuki
Comment 2
2015-03-19 01:47:46 PDT
Created
attachment 249027
[details]
Patch
Yusuke Suzuki
Comment 3
2015-03-21 04:43:12 PDT
Could anyone take a look?
Joseph Pecoraro
Comment 4
2015-03-21 09:27:16 PDT
Comment on
attachment 249027
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=249027&action=review
Nifty!
> Source/JavaScriptCore/tests/stress/unscopables.js:25 > + test(__proto__, Array.prototype); // array's unscopbales.__proto__ is undefined => false.
Typo: unscopbales
> Source/JavaScriptCore/tests/stress/unscopables.js:47 > + test(toString, "toString"); // object.toString is hidden by unscopables.toString.
Can we have an equivalent test where the unscopables object doesn't have the Object prototype? So: [Symbol.unscopables]: { Cocoa: false, Cappuccino: true, __proto__: null }. In which I think we would expect test(toString) to be Object.prototype.toString within this with block.
Yusuke Suzuki
Comment 5
2015-03-22 04:44:56 PDT
Created
attachment 249193
[details]
Patch
Yusuke Suzuki
Comment 6
2015-03-22 04:45:41 PDT
Comment on
attachment 249027
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=249027&action=review
Added comments and updated the patch.
>> Source/JavaScriptCore/tests/stress/unscopables.js:25 >> + test(__proto__, Array.prototype); // array's unscopbales.__proto__ is undefined => false. > > Typo: unscopbales
Oops! Thank you. Fixed.
>> Source/JavaScriptCore/tests/stress/unscopables.js:47 >> + test(toString, "toString"); // object.toString is hidden by unscopables.toString. > > Can we have an equivalent test where the unscopables object doesn't have the Object prototype? So: [Symbol.unscopables]: { Cocoa: false, Cappuccino: true, __proto__: null }. In which I think we would expect test(toString) to be Object.prototype.toString within this with block.
Sounds very nice. Added.
Yusuke Suzuki
Comment 7
2015-03-31 14:32:39 PDT
Created
attachment 249852
[details]
Patch
Yusuke Suzuki
Comment 8
2015-03-31 14:34:21 PDT
Created
attachment 249853
[details]
Patch
Geoffrey Garen
Comment 9
2015-03-31 16:27:44 PDT
Comment on
attachment 249853
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=249853&action=review
r=me
> Source/JavaScriptCore/runtime/JSScope.cpp:161 > + if (scope->type() != WithScopeType) > + return object; > + > + JSValue unscopables = object->get(exec, exec->propertyNames().unscopablesSymbol); > + if (exec->hadException()) > + return object; > + if (!unscopables.isObject()) > + return object; > + JSValue blocked = jsCast<JSObject*>(unscopables)->get(exec, ident); > + if (exec->hadException()) > + return object; > + if (!blocked.toBoolean(exec)) > + return object; > + ASSERT_WITH_MESSAGE(!exec->hadException(), "JSValue::toBoolean does not raise any errors.");
It would be nice to factor this code into a static inline helper function named "isUnscopable".
Yusuke Suzuki
Comment 10
2015-04-01 02:04:01 PDT
Committed
r182225
: <
http://trac.webkit.org/changeset/182225
>
Yusuke Suzuki
Comment 11
2015-04-01 02:31:07 PDT
Comment on
attachment 249853
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=249853&action=review
Thank you for your review! I've landed it with fix.
>> Source/JavaScriptCore/runtime/JSScope.cpp:161 >> + ASSERT_WITH_MESSAGE(!exec->hadException(), "JSValue::toBoolean does not raise any errors."); > > It would be nice to factor this code into a static inline helper function named "isUnscopable".
OK! I've extracted it to isUnscopable function.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug