Closed Bug 896523 Opened 6 years ago Closed 6 years ago

In Firefox, Console.log does not work from apps launched within the system app

Categories

(Firefox OS Graveyard :: Gaia, defect)

x86
macOS
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED
1.3 C3/1.4 S3(31jan)

People

(Reporter: kgrandon, Assigned: paul)

References

Details

Attachments

(2 files, 3 obsolete files)

Perhaps this is due to being in a mozbrowser, but I feel like this used to work before. Ideally console.log statements should work when apps are launched in their own tabs or inside of the system app.
Duplicate of this bug: 916870
How do you start the console? Do use the special profile for Firefox Desktop (DEBUG=1 DESKTOP=1)?
Mihai, at the console level, do we, at some point, cross frame boundaries (as in, do we use `window.parent`)?
Flags: needinfo?(mihai.sucan)
(In reply to Paul Rouget [:paul] from comment #3)
> Mihai, at the console level, do we, at some point, cross frame boundaries
> (as in, do we use `window.parent`)?

Once we receive a console API message:

1. we get the window object that it belongs to, based on the window ID. (is this working? is the console actor in the same process?)
2. once we have the window object, we get window.top. (is this allowed?)
3. we compare messageWindow.top to consoleActor.window check if they are the same.

If yes, then the message is sent from the server to the client to be displayed.

See CAL_observe() in toolkit/devtools/webconsole/utils.js.
Flags: needinfo?(mihai.sucan)
(In reply to Mihai Sucan [:msucan] from comment #4)
> 2. once we have the window object, we get window.top. (is this allowed?)

Not in mozbrowser. You have to use the docshell API instead:
http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsIDocShellTreeItem.idl#64

Maybe I can look at this. Where do we do that?
(In reply to Paul Rouget [:paul] from comment #5)
> (In reply to Mihai Sucan [:msucan] from comment #4)
> > 2. once we have the window object, we get window.top. (is this allowed?)
> 
> Not in mozbrowser. You have to use the docshell API instead:
> http://mxr.mozilla.org/mozilla-central/source/docshell/base/
> nsIDocShellTreeItem.idl#64
> 
> Maybe I can look at this. Where do we do that?

In the aforementioned utils.js. See comment #4.
Attached patch Patch v1 (obsolete) — Splinter Review
Mihai, what do you think of that?

Not asking for a review yet, I need to figure out how to test that.
Assignee: nobody → paul
Status: NEW → ASSIGNED
Attachment #805876 - Flags: feedback?(mihai.sucan)
To test that, you need to enable mozbrowser. What I do is to run the gaia with:

> DEBUG=1 DESKTOP=1 make profile-debug && ~/mozilla/apps/firefox/firefox -profile /home/paul/github/gaia/profile-debug -no-remote

Also, see https://developer.mozilla.org/en-US/docs/WebAPI/Browser

The preferences are:

> user_pref("dom.mozBrowserFramesEnabled", true);
> user_pref("dom.mozApps.used", true);
Comment on attachment 805876 [details] [diff] [review]
Patch v1

Review of attachment 805876 [details] [diff] [review]:
-----------------------------------------------------------------

I am getting the following error when I try to open the browser console:

Timestamp: 17/09/2013 23:01:17
Error: error occurred while processing 'startListeners: TypeError: aTopLevelWindow is null
Stack: LayoutHelpers@resource://gre/modules/devtools/LayoutHelpers.jsm:19
ConsoleServiceListener@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/toolkit/webconsole/utils.js:933
WCA_onStartListeners@resource://gre/modules/devtools/dbg-server.jsm -> resource://gre/modules/devtools/server/main.js -> resource://gre/modules/devtools/server/actors/webconsole.js:361
DSC_onPacket@resource://gre/modules/devtools/dbg-server.jsm -> resource://gre/modules/devtools/server/main.js:1018
LDT_send/<@resource://gre/modules/devtools/dbg-server.jsm -> resource://gre/modules/devtools/server/main.js -> resource://gre/modules/devtools/server/transport.js:255
makeInfallible/<@resource://gre/modules/devtools/dbg-server.jsm -> resource://gre/modules/devtools/server/main.js -> resource://gre/modules/devtools/DevToolsUtils.js:72

Source File: resource://gre/modules/devtools/dbg-server.jsm -> resource://gre/modules/devtools/server/main.js
Line: 923

The reason is that the browser console does not use per-window object message filtering. The ConsoleAPIListener and the ConsoleServiceListener constructors have the window argument, but that's optional.

The web console seems to be working well. The patch looks fine. f+ with the above bug fixed.
Attachment #805876 - Flags: feedback?(mihai.sucan) → feedback+
Attached patch patch v1.1 (no tests) (obsolete) — Splinter Review
Fixed the exception.
Attachment #805876 - Attachment is obsolete: true
I'm struggling  with the tests. Apparently, I can only set the browser permission from a mochitest-plain (not mochistest-chrome). `SpecialPowers.addPermission("browser", true, document)` raises an exception. From a mochitest-plain, I'm struggling to start the debugger and get the webconsole actor.

Alex, if I'm not mistaken, you've been working on something similar for the webapp actors. Can you help?
Flags: needinfo?(poirot.alex)
Yes, I'm using mochitest-plain, as mochitest-chrome aren't run on b2g.
In order to do that, I introduced a way to easily have chrome script helpers in mochitest-plain (bug 914633). It only allows you to have a decent piece of chrome code, but it doesn't allow you to test the chrome code, yet.
So if your main goal is to test the actor, that's not perfect, but if most assertions live in content, that's a good way to go.
The first test using this is the app actor mochitest:
  http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/apps/tests/test_webapps_actor.html?force=1#83
This mochitest-plain interact with the following chrome script:
  http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/apps/tests/debugger-protocol-helper.js

Do you have a test draft?
Flags: needinfo?(poirot.alex)
Hi Paul - is the only thing that's blocking this tests?
Flags: needinfo?(paul)
(In reply to Kevin Grandon :kgrandon from comment #13)
> Hi Paul - is the only thing that's blocking this tests?

yes.
Flags: needinfo?(paul)
Attached patch Patch v1.2 (obsolete) — Splinter Review
Attachment #807804 - Attachment is obsolete: true
(In reply to Alexandre Poirot (:ochameau) from comment #12)
> Do you have a test draft?

See attachment 832882 [details] [diff] [review].
Flags: needinfo?(poirot.alex)
Paul - any chance we can land this and file a bug to follow-up with a test? This is pretty painful, and getting more complaints on IRC. Thanks.
Flags: needinfo?(paul)
Kevin, can you still reproduce? Do you use B2G Desktop or on the device?
Flags: needinfo?(paul)
Yes, this is still an issue. This is broken in Firefox Nightly, and every few weeks we have more contributors complaining about it. If we can fix it, that would be great.
Attached patch patch v2Splinter Review
https://tbpl.mozilla.org/?tree=Try&rev=6aa00cc0fc35

Let's work on test later. This is blocking people.
Attachment #832881 - Attachment is obsolete: true
Attachment #8364472 - Flags: review?(mihai.sucan)
Flags: needinfo?(poirot.alex)
Comment on attachment 8364472 [details] [diff] [review]
patch v2

Review of attachment 8364472 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, assuming the LayoutHelpers work as advertised.
Attachment #8364472 - Flags: review?(mihai.sucan) → review+
Keywords: checkin-needed
Should we have a follow-up bug to add a test?
(In reply to Mihai Sucan [:msucan] from comment #23)
> Should we have a follow-up bug to add a test?

bug 963530
https://hg.mozilla.org/mozilla-central/rev/4852d88cc2ae
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → 1.3 C3/1.4 S3(31jan)
(In reply to Ryan VanderMeulen [:RyanVM UTC-4] from comment #26)
> https://hg.mozilla.org/mozilla-central/rev/4852d88cc2ae
Then how we can debug system apps. I am not able to debug system apps.
Please give some information regarding the prints logs.
(In reply to sb00349044 from comment #27)
> (In reply to Ryan VanderMeulen [:RyanVM UTC-4] from comment #26)
> > https://hg.mozilla.org/mozilla-central/rev/4852d88cc2ae
> Then how we can debug system apps. I am not able to debug system apps.
> Please give some information regarding the prints logs.

To discuss the specific issue you're seeing it would be best to do one of the following:

* Email the dev-b2g or dev-developer-tools mailing list
* Discuss in the #devtools IRC room
* File a new bug about your issue
You need to log in before you can comment on or make changes to this bug.