Bug 66097

Summary: REGRESSION: Qt JavaScript bridge signal connection fails
Product: WebKit Reporter: Andrew Wason <rectalogic>
Component: WebKit QtAssignee: Nobody <webkit-unassigned>
Severity: Normal CC: erights, jwalden+bwo, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Description Flags
pass toThisObject() to JS signal handler none

Description Andrew Wason 2011-08-11 14:16:39 PDT
Connecting to a Qt signal from JavaScript now fails.

This can be reproduced with an existing testcase:

$ WebKitBuild/Debug/WebKit/qt/tests/qwebframe/tst_qwebframe connectAndDisconnect
********* Start testing of tst_QWebFrame *********
Config: Using QTest library 4.7.3, Qt 4.7.3
PASS   : tst_QWebFrame::initTestCase()
ASSERTION FAILED: isValidThisObject(thisValue, exec)
../../../Source/JavaScriptCore/runtime/CallData.cpp(38) : JSC::JSValue JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, const JSC::CallData&, JSC::JSValue, const JSC::ArgList&)
QFATAL : tst_QWebFrame::connectAndDisconnect() Received signal 11
FAIL!  : tst_QWebFrame::connectAndDisconnect() Received a fatal error.
   Loc: [Unknown file(0)]
Totals: 1 passed, 1 failed, 0 skipped
********* Finished testing of tst_QWebFrame *********
Comment 1 Andrew Wason 2011-08-11 16:35:27 PDT
Looks like the problem was introduced with r91095 from bug 64250
Comment 2 Andrew Wason 2011-08-11 17:32:30 PDT
A workaround is to pass an anonymous object as the first arg to connect, e.g.:

context.someSignal.connect({}, function() { });

Because otherwise JSC::Bindings::QtRuntimeConnectionMethod::call() uses the window object (exec->lexicalGlobalObject()) and that seems to trigger the assert.
See http://trac.webkit.org/browser/trunk/Source/WebCore/bridge/qt/qt_runtime.cpp#L1587
Comment 3 Andrew Wason 2011-08-11 18:36:36 PDT
Created attachment 103719 [details]
pass toThisObject() to JS signal handler

This also re-enables tst_QWebFrame::connectAndDisconnect() tests that were disabled with bug 65170
Comment 4 Gavin Barraclough 2011-08-11 19:29:33 PDT
Comment on attachment 103719 [details]
pass toThisObject() to JS signal handler

Ooops, apologies for the breakage! - thanks for the fix.
Comment 5 WebKit Review Bot 2011-08-11 20:14:45 PDT
Comment on attachment 103719 [details]
pass toThisObject() to JS signal handler

Clearing flags on attachment: 103719

Committed r92907: <http://trac.webkit.org/changeset/92907>
Comment 6 WebKit Review Bot 2011-08-11 20:14:49 PDT
All reviewed patches have been landed.  Closing bug.