WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
200427
WebRTC: got incorrect `this` in negotiationneeded event
https://bugs.webkit.org/show_bug.cgi?id=200427
Summary
WebRTC: got incorrect `this` in negotiationneeded event
zjcqoo
Reported
2019-08-04 01:39:19 PDT
```html <!-- UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15 --> <script> const pc = new RTCPeerConnection(null) pc.onnegotiationneeded = async function(e) { console.log(pc === this) // return false! should be true // TypeError: // Can only call RTCPeerConnection.createOffer on instances of RTCPeerConnection const offer = await this.createOffer() console.log('offer:', offer) } pc.createDataChannel('x') </script> ```
Attachments
Patch
(5.37 KB, patch)
2019-08-04 16:22 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch for landing
(5.09 KB, patch)
2019-08-04 18:44 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
youenn fablet
Comment 1
2019-08-04 16:22:26 PDT
Created
attachment 375509
[details]
Patch
Radar WebKit Bug Importer
Comment 2
2019-08-04 16:24:13 PDT
<
rdar://problem/53923961
>
Darin Adler
Comment 3
2019-08-04 18:16:13 PDT
Comment on
attachment 375509
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=375509&action=review
> Source/WebCore/bindings/js/JSDOMBuiltinConstructor.h:95 > +typename JSC::JSObject& createJSObjectFromWrapper(JSDOMBuiltinConstructor<JSClass>& constructor, Ref<typename JSClass::DOMWrapped>&& domObject)
Not a big fan of names with "dom" in them. I’d call this "wrappedObject" instead of "domObject" if I was writing the code.
> Source/WebCore/bindings/js/JSDOMBuiltinConstructor.h:101 > + auto* domObjectPtr = domObject.ptr(); > + auto wrapper = JSClass::create(getDOMStructure<JSClass>(globalObject.vm(), globalObject), &globalObject, WTFMove(domObject)); > + cacheWrapper(globalObject.world(), domObjectPtr, wrapper); > + return *wrapper;
This looks so identical to createWrapper from JSDOMWrapperCache.h. There’s got to be a way to factor so they share most of their code.
> Source/WebCore/bindings/js/JSDOMBuiltinConstructor.h:104 > +template<typename JSClass> inline
Seems unnecessary that all of these function templates say "inline". I can’t imagine this has any effect one way or another on whether they are inlined nor on whether they are safe to include in a header.
youenn fablet
Comment 4
2019-08-04 18:42:16 PDT
(In reply to Darin Adler from
comment #3
)
> Comment on
attachment 375509
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=375509&action=review
> > > Source/WebCore/bindings/js/JSDOMBuiltinConstructor.h:95 > > +typename JSC::JSObject& createJSObjectFromWrapper(JSDOMBuiltinConstructor<JSClass>& constructor, Ref<typename JSClass::DOMWrapped>&& domObject) > > Not a big fan of names with "dom" in them. I’d call this "wrappedObject" > instead of "domObject" if I was writing the code.
OK
> > Source/WebCore/bindings/js/JSDOMBuiltinConstructor.h:101 > > + auto* domObjectPtr = domObject.ptr(); > > + auto wrapper = JSClass::create(getDOMStructure<JSClass>(globalObject.vm(), globalObject), &globalObject, WTFMove(domObject)); > > + cacheWrapper(globalObject.world(), domObjectPtr, wrapper); > > + return *wrapper; > > This looks so identical to createWrapper from JSDOMWrapperCache.h. There’s > got to be a way to factor so they share most of their code.
Right will do.
> > Source/WebCore/bindings/js/JSDOMBuiltinConstructor.h:104 > > +template<typename JSClass> inline > > Seems unnecessary that all of these function templates say "inline". I can’t > imagine this has any effect one way or another on whether they are inlined > nor on whether they are safe to include in a header.
I guess this is copy/paste with the inline methods.
youenn fablet
Comment 5
2019-08-04 18:44:40 PDT
Created
attachment 375513
[details]
Patch for landing
WebKit Commit Bot
Comment 6
2019-08-04 23:54:13 PDT
Comment on
attachment 375513
[details]
Patch for landing Clearing flags on attachment: 375513 Committed
r248267
: <
https://trac.webkit.org/changeset/248267
>
WebKit Commit Bot
Comment 7
2019-08-04 23:54:15 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 8
2019-08-07 16:30:57 PDT
Comment on
attachment 375513
[details]
Patch for landing View in context:
https://bugs.webkit.org/attachment.cgi?id=375513&action=review
> Source/WebCore/bindings/js/JSDOMBuiltinConstructor.h:97 > + return *createWrapper<typename JSClass::DOMWrapped>(constructor.globalObject(), JSClass::DOMWrapped::create());
I think we can take out the <typename JSClass::DOMWrapped> and everything will still work properly, deduced based on the argument types. Might be worth trying that at some point.
> Source/WebCore/bindings/js/JSDOMBuiltinConstructor.h:111 > + return context ? createWrapper<typename JSClass::DOMWrapped>(constructor.globalObject(), JSClass::DOMWrapped::create(*context)) : nullptr;
Ditto.
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