Bug 160379 - console.log() is not working in WebInspector on sec.sogou.com
Summary: console.log() is not working in WebInspector on sec.sogou.com
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: Other
Hardware: All All
: P2 Minor
Assignee: Matt Baker
URL:
Keywords: InRadar
: 160380 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-07-30 08:56 PDT by 5up3rc.95
Modified: 2016-07-30 18:16 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 5up3rc.95 2016-07-30 08:56:43 PDT
In the crawler test. Found that including chrome, Safari, phantomjs are unable to traverse document.getElementsByTagName.The same situation can be under the Firefox


在做爬虫测试。发现包括chrome,Safari,phantomjs都无法遍历document.getElementsByTagName,同样的情况在firefox下是可以的
Comment 1 Chris Dumez 2016-07-30 09:29:29 PDT
*** Bug 160380 has been marked as a duplicate of this bug. ***
Comment 2 5up3rc.95 2016-07-30 09:41:41 PDT
hi!is bug?
Comment 3 Chris Dumez 2016-07-30 09:58:27 PDT
Can you please provide a sample of JavaScript code that is failing on sec.sogou.com ? I am not clear on what the bug is yet.
Comment 4 Chris Dumez 2016-07-30 10:03:44 PDT
> elements = document.getElementsByTagName("a")
< HTMLCollection [<a>, <a>, <a>, <a>, <a>, <a>, <a id="login">, <a id="user">, <a>, <a>, …] (39)
> elements.length
< 39
> for (var i = 0; i < elements.length; i++) { console.log(elements[i]); }
< undefined
> elements[1]
< <a href="/">首页</a>

So it looks like console.log() is not working?
Comment 5 Chris Dumez 2016-07-30 10:05:47 PDT
So the issue is not that we cannot traverse the HTMLCollection because:

for (var i = 0; i < elements.length; i = i + 1) { alert(elements[i]); }

displays 39 alert dialogs.

However, if I use console.log(), I see nothing in WebInspector.

This could be a WebInspector bug?
Comment 6 Radar WebKit Bug Importer 2016-07-30 10:06:58 PDT
<rdar://problem/27625945>
Comment 7 Chris Dumez 2016-07-30 10:08:24 PDT
Reproduction steps:
1. Go to http://sec.sogou.com
2. Open WebInspector
3. Type "console.log('test')" and press ENTER
-> undefined, logs nothing.

If you do the same thing on google.com, it works as expected.
Comment 8 5up3rc.95 2016-07-30 10:17:20 PDT
No. This problem only occurs in sec.sogou.com
I use the safari phantomjs chrome in this site test can not traverse through the console.log output, but in other sites can traverse and through the console.log output
There's no problem in google.com.
Comment 9 Chris Dumez 2016-07-30 10:20:53 PDT
(In reply to comment #8)
> No. This problem only occurs in sec.sogou.com
> I use the safari phantomjs chrome in this site test can not traverse through
> the console.log output, but in other sites can traverse and through the
> console.log output
> There's no problem in google.com.

Yes this is what I said...
Comment 10 5up3rc.95 2016-07-30 10:25:14 PDT
Use console.debug or console.info to output. So this is not the browser in the processing of bug console.log?
Comment 11 Matt Baker 2016-07-30 10:30:49 PDT
Interestingly console.warn and console.error work correctly. Investigating.
Comment 12 5up3rc.95 2016-07-30 10:33:40 PDT
Yeah, and the problem is only for sec.sogou.com, the other is not found
Comment 13 Matt Baker 2016-07-30 11:54:10 PDT
JavaScriptCore/runtime/ConsoleObject.cpp:73:

// For legacy reasons, console properties are enumerable, writable, deleteable,
// and all have a length of 0. This may change if Console is standardized.

I wonder if the site is overwriting or deleting the `log` property. Every other console code path I tested works.
Comment 14 Matt Baker 2016-07-30 11:59:27 PDT
(In reply to comment #13)
> JavaScriptCore/runtime/ConsoleObject.cpp:73:
> 
> // For legacy reasons, console properties are enumerable, writable,
> deleteable,
> // and all have a length of 0. This may change if Console is standardized.
> 
> I wonder if the site is overwriting or deleting the `log` property. Every
> other console code path I tested works.

Logging some console properties confirms this:

> console.debug
< function debug() {
    [native code]
}
> console.info
< function info() {
    [native code]
}
> console.warn
< function warn() {
    [native code]
}
> console.error
< function error() {
    [native code]
}
> console.log
< function () {}
Comment 15 Matt Baker 2016-07-30 12:01:44 PDT
The offending code is at the beginning of main.js:

if (!window.debug) {
    console.log = function() {};
}
Comment 16 Chris Dumez 2016-07-30 12:04:31 PDT
Thanks for looking Matt.
Comment 17 Matt Baker 2016-07-30 12:14:05 PDT
Sure thing!
Comment 18 5up3rc.95 2016-07-30 18:16:51 PDT
Thank you,But have a bit puzzled in the Firefox browser, but can use the normal console.log