Closed
Bug 936520
Opened 12 years ago
Closed 11 years ago
[mocha] we can't see console.error in the console
Categories
(Firefox OS Graveyard :: Gaia::TestAgent, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: julienw, Assigned: rickychien)
Details
Attachments
(4 files)
STR:
* use console.error in a test file
* run the test file using the test-agent
Expected:
* we see the text in the console
Actual:
* we don't, we only see it in the Browser's Web Console
We should also have a look to the other info, warn, etc functions
Assignee | ||
Comment 1•11 years ago
|
||
You're right!
We didn't see any console.info/warn/error output on terminal console. On the other hand, for each console.log will cause browser console output twice log message. This bug probably confuse so many developers.
I'm going to upload the new patch for it
Assignee: nobody → ricky060709
Status: NEW → ASSIGNED
Assignee | ||
Comment 2•11 years ago
|
||
Hi Juilen, I think I need your information for this small patch. It shouldn't takes too much time for you. :)
Attachment #8418630 -
Flags: review?(felash)
Assignee | ||
Comment 3•11 years ago
|
||
Attachment #8418631 -
Flags: review?(felash)
Assignee | ||
Comment 4•11 years ago
|
||
Attachment #8418632 -
Flags: review?(felash)
Reporter | ||
Comment 5•11 years ago
|
||
This looks good, but I'd like to check why we get twice the same log message; do you know why? I see that you removed one of these messages (the "log.apply" call) but how is the log message displayed then? Is it displayed by the main test-agent window (as opposed to the test-agent iframe)?
Also, the line in [1] confuses me. Can you help me understand how console.{log/info/etc} functions work?
[1] https://github.com/julienw/js-test-agent/blob/f93b4f7ff779d96bafaa0cb7b45baf814a85f86f/lib/test-agent/browser-worker/mocha-driver.js#L68
Assignee | ||
Comment 6•11 years ago
|
||
When we inserting console.error in test file, it will use iframe's console to output message.
The line at [1] assign iframe console to JsonStreamReporter make the [2] can overwrite iframe's console.
Then, [3] is running in main frame, it receives message from it's iframe and output message through main frame's console.log (here is real console, not our consoleShim).
Look into [2], we print log at
line 35: log.apply(this, arguments);
generate once message,
and then in
line 70: MochaReporter.send(
JSON.stringify(['log', logDetails])
);
MochaReporter.send will send messages to main frame by using postMessage and send out message to test-agent server through web-socket simultaneously. So I guess the reason is [3] receive this 'log' event from postMessage and print out log message second time.
[1] https://github.com/julienw/js-test-agent/blob/f93b4f7ff779d96bafaa0cb7b45baf814a85f86f/lib/test-agent/browser-worker/mocha-driver.js#L68
[2] https://github.com/julienw/js-test-agent/blob/f93b4f7ff779d96bafaa0cb7b45baf814a85f86f/lib/test-agent/mocha/json-stream-reporter.js
[3] https://github.com/mozilla-b2g/js-test-agent/pull/71/files#diff-058182f77ac39b039113303e02da6744R93
Reporter | ||
Comment 7•11 years ago
|
||
And it's then sent to the websocket server because all data is mirrored?
Assignee | ||
Comment 8•11 years ago
|
||
Data mirroring happen on NodeJs (consist of server and client). It takes over to forward messages which received from server then send it to client if there is a client already connected.
I'm talking about what's going on just regarding to web console.
Reporter | ||
Comment 9•11 years ago
|
||
Data mirroring needs to happen in the browser too, because otherwise we couldn't see the console in the terminal...
Assignee | ||
Comment 10•11 years ago
|
||
Yeah, it could be regarded as a data mirroring too. So I thought your description on comment 7 was right.
Reporter | ||
Comment 11•11 years ago
|
||
Comment on attachment 8418630 [details] [review]
Gaia PR
ok, so I tried it, but I have some comments:
* first, the most important: in the devtools, we see which code line the log is sent. But here we see it comes from [1], which is not useful at all.
Do you think it's possible to both :
+ keep the log showing at the right place in the devtools
+ keep the mirroring feature to see the logs in the console
I think it's not possible, but I'd like that you have a look
* second, is it possible to have console.dir and console.trace working? (maybe not)
keeping the r? request until these questions are answered.
Thanks Ricky!
[1] https://github.com/mozilla-b2g/gaia/pull/19025/files#diff-bc377f19df7784162a70aba0e6306bdaR1679
Assignee | ||
Comment 12•11 years ago
|
||
+ keep the log showing at the right place in the devtools
It's impossible to change console.log position which output from Gecko console. However, maybe we can print an additional line message after log like this http://jsfiddle.net/drzaus/pWe6W/9/. How do you think of that?
Assignee | ||
Comment 13•11 years ago
|
||
New PR for console.dir and console.trace was added.
Reporter | ||
Comment 14•11 years ago
|
||
Let's forget the mirroring for now.
I added a handful of comments on github.
Assignee | ||
Comment 15•11 years ago
|
||
New PR was updated. You can check it again if you feel free!
Reporter | ||
Comment 16•11 years ago
|
||
Comment on attachment 8418631 [details] [review]
Js-test-agent PR
r=me
thanks !
Attachment #8418631 -
Flags: review?(felash) → review+
Reporter | ||
Comment 17•11 years ago
|
||
Comment on attachment 8418632 [details] [review]
Gaia-node-modules PR
I trust you to do the correct changes here to apply the changes in test-agent.
Attachment #8418632 -
Flags: review?(felash)
Reporter | ||
Comment 18•11 years ago
|
||
Comment on attachment 8418630 [details] [review]
Gaia PR
same here; I hope that when bug 874510 lands we'll only need to update package.json and node_modules hash :)
Attachment #8418630 -
Flags: review?(felash)
Assignee | ||
Comment 19•11 years ago
|
||
Thanks Julien! I fixed some of comments on Github and it works fine after my test.
PR will be landed soon after new PR pass on Travis and Try.
Assignee | ||
Comment 20•11 years ago
|
||
Assignee | ||
Comment 21•11 years ago
|
||
Assignee | ||
Comment 22•11 years ago
|
||
Assignee | ||
Comment 23•11 years ago
|
||
Merged gaia_node_modules.revision.
https://github.com/mozilla-b2g/gaia/commit/eca8a384a14b3fb2394ca2ed482d52e9f6e73264
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•