WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 40980
Web Inspector: null is not properly handled when evaluated in console (V8 only)
https://bugs.webkit.org/show_bug.cgi?id=40980
Summary
Web Inspector: null is not properly handled when evaluated in console (V8 only)
Andrey Kosyakov
Reported
2010-06-22 04:34:50 PDT
Injected script does not handle evaluation of null values properly.
> null
TypeError: Cannot read property 'constructor' of null
Attachments
patch
(4.92 KB, patch)
2010-06-22 08:22 PDT
,
Andrey Kosyakov
no flags
Details
Formatted Diff
Diff
patch (more different types of objects added)
(9.16 KB, patch)
2010-06-22 10:03 PDT
,
Andrey Kosyakov
pfeldman
: review-
Details
Formatted Diff
Diff
patch (fixed abbreviation, always use toString for all functions)
(9.08 KB, patch)
2010-06-23 02:58 PDT
,
Andrey Kosyakov
pfeldman
: review-
Details
Formatted Diff
Diff
patch (separated tests with platform-specific expectations, fixed nits)
(7.96 KB, patch)
2010-06-23 07:02 PDT
,
Andrey Kosyakov
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Andrey Kosyakov
Comment 1
2010-06-22 08:22:15 PDT
Created
attachment 59369
[details]
patch
Andrey Kosyakov
Comment 2
2010-06-22 10:03:28 PDT
Created
attachment 59384
[details]
patch (more different types of objects added)
Pavel Feldman
Comment 3
2010-06-22 12:37:11 PDT
Comment on
attachment 59384
[details]
patch (more different types of objects added) WebCore/inspector/front-end/InjectedScript.js:604 + objectText = type; So you always return "function" for functions that have poor toString. Old code was smarter (before it got regressed). It was doing Object.prototype.toString(obj) on objects like this (which was evolved into "[object Function]" or similar). Then, className was extracting the "Function" part. I think we should fix the regression in the InjectedScript._toString first (see Safari 4 code for that). Note that there were some reservations wrt Object lifetime that were making Object.prototype.toString call problematic. Maybe we should simplify the code as you suggested, but I don't think returning "function" for all objects like this is a good idea. WebCore/inspector/front-end/InjectedScript.js: + if (typeof obj !== "object") I think this will break chromium interactive tests. Take a look at
r58956
. I know that typeof null is in fact "object", so the fix in
r58956
itself was arguable. Probably this needs a more strict check such as (obj === null || typeof obj !== "object")
Eric Seidel (no email)
Comment 4
2010-06-22 13:22:41 PDT
Comment on
attachment 59369
[details]
patch Cleared Yury Semikhatsky's review+ from obsolete
attachment 59369
[details]
so that this bug does not appear in
http://webkit.org/pending-commit
.
Andrey Kosyakov
Comment 5
2010-06-23 02:58:21 PDT
Created
attachment 59497
[details]
patch (fixed abbreviation, always use toString for all functions)
Andrey Kosyakov
Comment 6
2010-06-23 03:02:45 PDT
(In reply to
comment #3
)
> (From update of
attachment 59384
[details]
) > WebCore/inspector/front-end/InjectedScript.js:604 > + objectText = type; > So you always return "function" for functions that have poor toString. Old code was smarter (before it got regressed). It was doing Object.prototype.toString(obj) on objects like this (which was evolved into "[object Function]" or similar). Then, className was extracting the "Function" part. I think we should fix the regression in the InjectedScript._toString first (see Safari 4 code for that). Note that there were some reservations wrt Object lifetime that were making Object.prototype.toString call problematic. > > Maybe we should simplify the code as you suggested, but I don't think returning "function" for all objects like this is a good idea.
As agreed offline -- there's not much sense in displaying "Function" rather than "function" for some functions; We choose to use function's toString() whatever it is.
> WebCore/inspector/front-end/InjectedScript.js: > + if (typeof obj !== "object") > I think this will break chromium interactive tests. Take a look at
r58956
. I know that typeof null is in fact "object", so the fix in
r58956
itself was arguable. Probably this needs a more strict check such as (obj === null || typeof obj !== "object")
I don't think so -- the problem was because we were calling _className always, without regard to what _type() returns. Now we only call it for objects, and only if these are not nulls (null is treated as special type "null" by _type()).
Pavel Feldman
Comment 7
2010-06-23 04:56:28 PDT
Comment on
attachment 59497
[details]
patch (fixed abbreviation, always use toString for all functions) WebCore/inspector/front-end/InjectedScript.js:604 + objectText = /.*/.exec(obj)[0].replace(/ +$/g, ""); did you mean exec(objectText) here? LayoutTests/inspector/console-tests-expected.txt:37 + console-tests.html:22null console-message console-js-source console-log-level I would expect to see console-formatted-null in the list of styles. LayoutTests/platform/chromium/inspector/console-tests-expected.txt:1 + CONSOLE MESSAGE: line 9: log Given that there is a handful of mismatches wrt WebKit, I would extract them into separate test so that we could reuse most of the standard expectations.
Andrey Kosyakov
Comment 8
2010-06-23 07:02:40 PDT
Created
attachment 59510
[details]
patch (separated tests with platform-specific expectations, fixed nits) Re adding styles for type-specific formatting to tests expectation -- we agreed not to do it now, as it is logically unrelated to this fix.
Yury Semikhatsky
Comment 9
2010-06-23 07:15:51 PDT
Comment on
attachment 59510
[details]
patch (separated tests with platform-specific expectations, fixed nits) WebCore/inspector/front-end/InjectedScript.js:604 + objectText = /.*/.exec(objectText)[0].replace(/ +$/g, ""); Please add a comment describing what the regexp does or better rewrite the code to make its intent clear.
Yury Semikhatsky
Comment 10
2010-06-24 01:57:26 PDT
Comment on
attachment 59510
[details]
patch (separated tests with platform-specific expectations, fixed nits) Clearing flags on attachment: 59510 Committed
r61748
: <
http://trac.webkit.org/changeset/61748
>
Yury Semikhatsky
Comment 11
2010-06-24 01:57:37 PDT
All reviewed patches have been landed. Closing bug.
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