WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 20141
114406
Calling console.{log, info, error, ...} should not require this === console
https://bugs.webkit.org/show_bug.cgi?id=114406
Summary
Calling console.{log, info, error, ...} should not require this === console
Victor Costan
Reported
2013-04-10 19:07:47 PDT
This is a bug for a patch that I will attach very soon. In a nutshell, this change will make the code below not throw an exception: f = console.log; f("Hello world"); This comes in handy when debugging asynchronous code in the Web Inspector, because console.log can be passed as a callback that prints its arguments. For example, given a node.js-style asynchronous function perform(action, error, callback) can be called as follows in the Inspector, for quick debugging. perform(action, console.warn, console.log); In order to achieve this, the patch introduces the [LenientThis] WebKitIDL attribute, which is heavily inspired from the LenientThis WebIDL.
http://www.w3.org/TR/WebIDL/#LenientThis
I implemented LenientThis for methods. I figured the only way to not require a specific type for "this" is to completely ignore the value, so a LenientThis method calls a static method in WebCore. A LenientMethod is similar to a static method, but it can be accessed as a property of the interface instances, instead of being a property of the interface object. I hope this makes sense, and I look forward to feedback.
Attachments
Patch
(35.82 KB, patch)
2013-04-10 19:27 PDT
,
Victor Costan
no flags
Details
Formatted Diff
Diff
Patch
(35.82 KB, patch)
2013-04-10 20:22 PDT
,
Victor Costan
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Victor Costan
Comment 1
2013-04-10 19:27:19 PDT
Created
attachment 197464
[details]
Patch
WebKit Commit Bot
Comment 2
2013-04-10 19:29:22 PDT
Attachment 197464
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast/dom/Window/console-unbound-functions-expected.txt', u'LayoutTests/fast/dom/Window/console-unbound-functions.html', u'Source/WebCore/ChangeLog', u'Source/WebCore/bindings/scripts/CodeGeneratorJS.pm', u'Source/WebCore/bindings/scripts/IDLAttributes.txt', u'Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp', u'Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h', u'Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp', u'Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h', u'Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp', u'Source/WebCore/bindings/scripts/test/JS/JSTestObj.h', u'Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h', u'Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm', u'Source/WebCore/bindings/scripts/test/TestObj.idl', u'Source/WebCore/page/Console.cpp', u'Source/WebCore/page/Console.h', u'Source/WebCore/page/Console.idl']" exit_code: 1 Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h:188: The parameter name "str" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 1 in 18 files If any of these errors are false positives, please file a bug against check-webkit-style.
Darin Adler
Comment 3
2013-04-10 19:44:52 PDT
Comment on
attachment 197464
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=197464&action=review
> Source/WebCore/page/Console.idl:62 > - [CallWith=ScriptArguments|ScriptState] void clear(); > + [CallWith=ScriptArguments|ScriptState] static void clear();
Why is this different from the others? Was this an earlier syntax you had experimented with?
Victor Costan
Comment 4
2013-04-10 20:22:03 PDT
Created
attachment 197499
[details]
Patch
Victor Costan
Comment 5
2013-04-10 20:26:56 PDT
Darin, thank you so much for catching that! Yes, I tried static first, hoping it would work. I'm really sorry about this omission, I was so happy when I got the IDL generator working that I forgot to double-check my Console changes. :( Also, should I worry about the style error in the generated code?
WebKit Commit Bot
Comment 6
2013-04-10 20:31:30 PDT
Attachment 197499
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast/dom/Window/console-unbound-functions-expected.txt', u'LayoutTests/fast/dom/Window/console-unbound-functions.html', u'Source/WebCore/ChangeLog', u'Source/WebCore/bindings/scripts/CodeGeneratorJS.pm', u'Source/WebCore/bindings/scripts/IDLAttributes.txt', u'Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp', u'Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h', u'Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp', u'Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h', u'Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp', u'Source/WebCore/bindings/scripts/test/JS/JSTestObj.h', u'Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h', u'Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm', u'Source/WebCore/bindings/scripts/test/TestObj.idl', u'Source/WebCore/page/Console.cpp', u'Source/WebCore/page/Console.h', u'Source/WebCore/page/Console.idl']" exit_code: 1 Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h:188: The parameter name "str" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 1 in 18 files If any of these errors are false positives, please file a bug against check-webkit-style.
Alexey Proskuryakov
Comment 7
2013-04-10 22:02:10 PDT
Is this the same as
bug 20141
?
Alexey Proskuryakov
Comment 8
2013-04-10 22:04:51 PDT
If you agree, I think that it would be better to dupe this to older bug, and to move the patch there.
Victor Costan
Comment 9
2013-04-10 23:37:09 PDT
Thank you for pointing this out, Alexey! Should I add the description of my patch as a comment in #20141? *** This bug has been marked as a duplicate of
bug 20141
***
Alexey Proskuryakov
Comment 10
2013-04-10 23:54:46 PDT
> Should I add the description of my patch as a comment in #20141?
Sure,
bug 20141
should have enough information to learn what's going on.
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