Closed
Bug 1223116
Opened 9 years ago
Closed 9 years ago
webconsole should filter service worker logs using same logic as ServiceWorkerManager
Categories
(DevTools :: Console, defect)
DevTools
Console
Tracking
(firefox43 wontfix, firefox44 fixed, firefox45 fixed)
RESOLVED
FIXED
Firefox 45
People
(Reporter: bkelly, Assigned: bkelly)
References
(Blocks 1 open bug)
Details
Attachments
(3 files, 9 obsolete files)
3.33 KB,
patch
|
bgrins
:
review+
ritu
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
5.67 KB,
patch
|
catalinb
:
review+
ritu
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
10.45 KB,
patch
|
bkelly
:
review+
ritu
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
Once bug 1217909 lands we are going to have two slightly different approaches to reporting to the console.
A service worker console.log() follows this rule:
"Show logs in a window if the service worker scope matches the window.location or any frame.src within the window."
In contrast, ServiceWorkerManager internally is going to use this rule for reporting exceptions:
"Shows logs in a window if its controlled or if it called .register() for the given SW script/scope."
This is slightly better in that it will show messages in the console when a window registers a service worker for a scope that doesn't match the current window. This will be common, for example, when using only push and not offline
support.
We should expose the ServiceWorkerManager logic in a shouldReportToWindow() method on the nsIServiceWorkerManager interface.
Assignee | ||
Comment 1•9 years ago
|
||
Assignee | ||
Comment 2•9 years ago
|
||
Work-in-progress. I still need to do some cleanup. Also, the logs are not showing when navigating from an uncontrolled page to a controlled page. I may need to change it around to use outer window ID or something.
Assignee | ||
Comment 3•9 years ago
|
||
This essentially exposes the same logic from ServiceWorkerManager::ReportToAllClients() to chrome script. This lets devtools then ask us if it should show a particular console message on any given window.
Attachment #8685120 -
Attachment is obsolete: true
Attachment #8685754 -
Flags: review?(catalin.badea392)
Assignee | ||
Comment 4•9 years ago
|
||
Brian does this look right?
I still need to look and see if the test needs to be adjusted.
Attachment #8685122 -
Attachment is obsolete: true
Attachment #8685755 -
Flags: review?(bgrinstead)
Assignee | ||
Comment 5•9 years ago
|
||
Yea, it seems the test times out. I will investigate tomorrow.
Comment 6•9 years ago
|
||
Ben, will this logic also handle the scenario in Bug 1221772?
Flags: needinfo?(bkelly)
Assignee | ||
Comment 7•9 years ago
|
||
(In reply to Brian Grinstead [:bgrins] from comment #6)
> Ben, will this logic also handle the scenario in Bug 1221772?
Well, we currently have bugs with SW treating the Worker as a client. Part of fixing that would include extending the logic I'm providing here to include the Worker's parent document in the list of registering documents.
Flags: needinfo?(bkelly)
Assignee | ||
Comment 8•9 years ago
|
||
More specifically, it should be part of fixing bug 1032521.
Assignee | ||
Comment 9•9 years ago
|
||
I had a bug in my ShouldReportToWindow() method. It needs to use the top window when comparing IDs. The test correctly caught this problem. The test passes with these changes.
Attachment #8685754 -
Attachment is obsolete: true
Attachment #8685754 -
Flags: review?(catalin.badea392)
Attachment #8686273 -
Flags: review?(catalin.badea392)
Comment 10•9 years ago
|
||
Comment on attachment 8685755 [details] [diff] [review]
P2 Make webconsole use new nsIServiceWorkerManager.shouldReportToWindow(). r=bgrins
Review of attachment 8685755 [details] [diff] [review]:
-----------------------------------------------------------------
This change looks good to me from the webconsole end, test_console_serviceworker.html should catch any regressions. I'd like to extend that test to also register a non-matching service worker and make sure it's message doesn't appear. Will registering a new SW with a non-matching scope do that, or do we need to register a new one on a different domain?
Attachment #8685755 -
Flags: review?(bgrinstead) → review+
Assignee | ||
Comment 11•9 years ago
|
||
This tests the case where we navigate from an uncontrolled document to a controlled document.
Attachment #8686283 -
Flags: review?(bgrinstead)
Assignee | ||
Comment 12•9 years ago
|
||
(In reply to Brian Grinstead [:bgrins] from comment #10)
> I'd like to extend that test to also register a non-matching service worker and make
> sure it's message doesn't appear. Will registering a new SW with a
> non-matching scope do that, or do we need to register a new one on a
> different domain?
I'll do this tomorrow or later tonight. The non-matching scope should be enough. In fact, I can even change the current register() to do that as its the same path for whats going on there now. With my P3 patch the main thing thats missing is a test of the log showing up for a controlled frame.
Comment 13•9 years ago
|
||
Comment on attachment 8686283 [details] [diff] [review]
P3 Extend the test to check console messages during navigation interceptions. r =bgrins
Review of attachment 8686283 [details] [diff] [review]:
-----------------------------------------------------------------
::: devtools/shared/webconsole/test/test_console_serviceworker.html
@@ +20,3 @@
>
> let swClosed = new Promise(() => {});
> let expectedConsoleCalls = [
Does expectedConsoleCalls need a new entry for the fetch log here? According to the comment right before the navigation we are expecting an additional log to happen at that point
@@ +56,5 @@
> win.navigator.serviceWorker.register(SERVICE_WORKER_URL).then(swr => {
> + // Now navigate the frame to trigger another console message from
> + // the fetch event handler.
> + iframe.onload = function() {
> + info("Service worker registered. Unregistering");
Nit: move this info call outside of the onload
Attachment #8686283 -
Flags: review?(bgrinstead)
Assignee | ||
Comment 14•9 years ago
|
||
Good catch. I don't think the fetch event is firing. Probably because I need to wait for the SW to be activated. I'll fix tomorrow and expand to cover some more test cases.
Assignee | ||
Comment 15•9 years ago
|
||
Ok, there were a few problems before. The service worker wasn't firing correctly, but the test was also terminating as soon as it got the number of expected console calls. So additional console calls did not cause a failure either.
The modified test now tests these conditions:
1) Console calls from SW to registering, out-of-scope frame
2) Console calls from SW handling navigation from non-scope to in-scope
3) Console calls from SW handling non-navigation from a controlled frame
Attachment #8686283 -
Attachment is obsolete: true
Attachment #8686814 -
Flags: review?(bgrinstead)
Comment 16•9 years ago
|
||
Comment on attachment 8686814 [details] [diff] [review]
P3 Extend the test to check console messages for more service worker conditions . r=bgrins
Review of attachment 8686814 [details] [diff] [review]:
-----------------------------------------------------------------
This is great, thanks!
::: devtools/shared/webconsole/test/test_console_serviceworker.html
@@ +62,5 @@
> attachConsoleToTab(["ConsoleAPI"], onAttach);
> });
> addEventListener("load", startTest);
>
> +function with_frame(url) {
Nit: camelcase to match webconsole style
@@ +114,1 @@
> function onAttach(state, response) {
Nit: please use Task.async and yield to match other new webconsole tests. Something like..
let onAttach = Task.async(function*(state, response) {
...
let currentFrame = yield with_frame(NONSCOPE_FRAME_URL);
yield with_active_service_worker(currentFrame.contentWindow,
SERVICE_WORKER_URL, SCOPE);
yield navigate_frame(currentFrame, SCOPE_FRAME_URL);
yield currentFrame.contentWindow.fetch(SCOPE_FRAME_URL2);
yield unregister_service_worker(currentFrame.contentWindow);
...
});
@@ +147,5 @@
> + return unregister_service_worker(currentFrame.contentWindow);
> + }).then(() => {
> + info('Service worker unregistered. Checking console calls.');
> + state.dbgClient.removeListener("consoleAPICall", onConsoleAPICall);
> + is(consoleCalls.length, expectedConsoleCalls.length,
This still doesn't add a case where a non-relevant SW does a log that should be ignored, right? But at least now it will fail when we add that.
Attachment #8686814 -
Flags: review?(bgrinstead) → review+
Assignee | ||
Comment 17•9 years ago
|
||
(In reply to Brian Grinstead [:bgrins] from comment #16)
> @@ +114,1 @@
> > function onAttach(state, response) {
>
> Nit: please use Task.async and yield to match other new webconsole tests.
> Something like..
How important is this? I did it, but it makes the .register() fail with an InvalidStateError. It seems the entry document or something might not be right using Task.async here.
Assignee | ||
Comment 19•9 years ago
|
||
Attachment #8686814 -
Attachment is obsolete: true
Attachment #8686901 -
Flags: review+
Assignee | ||
Comment 20•9 years ago
|
||
Attachment #8686901 -
Attachment is obsolete: true
Attachment #8686902 -
Flags: review+
Comment 21•9 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #17)
> (In reply to Brian Grinstead [:bgrins] from comment #16)
> > @@ +114,1 @@
> > > function onAttach(state, response) {
> >
> > Nit: please use Task.async and yield to match other new webconsole tests.
> > Something like..
>
> How important is this? I did it, but it makes the .register() fail with an
> InvalidStateError. It seems the entry document or something might not be
> right using Task.async here.
That's weird, maybe some kind of timing issue? It's not a huge deal, but if Bug 1224237 is going to fix this anyway then let's go with it.
Assignee | ||
Comment 22•9 years ago
|
||
(In reply to Brian Grinstead [:bgrins] from comment #21)
> That's weird, maybe some kind of timing issue? It's not a huge deal, but if
> Bug 1224237 is going to fix this anyway then let's go with it.
Yea, I expect bug 1224237 to land before this.
Assignee | ||
Comment 23•9 years ago
|
||
Updated the test to perform a console.log() from the service worker while there are no controlling or registering documents and verify that the window does not get a console call.
Its good I did this because it revealed a bug in how I was handling detached documents in SWM::ShouldReportToWindow().
Attachment #8686902 -
Attachment is obsolete: true
Attachment #8686977 -
Flags: review+
Assignee | ||
Comment 24•9 years ago
|
||
Update the patch to skip documents that return false from IsCurrentActiveDocument(). This makes it so we don't spam the console in windows that have a controlled or registering document in their bfcache history.
Also, check GetScriptableTop() return for nullptr.
Attachment #8686273 -
Attachment is obsolete: true
Attachment #8686273 -
Flags: review?(catalin.badea392)
Attachment #8686979 -
Flags: review?(catalin.badea392)
Assignee | ||
Updated•9 years ago
|
Attachment #8686979 -
Attachment description: bug1223116_p1_swmshouldreport.patch → P1 Expose nsIServiceWorkerManager.shouldReportToWindow(). r=catalinb
Assignee | ||
Comment 25•9 years ago
|
||
One more to remove some stale code and add a comment I forgot to put in.
Attachment #8686977 -
Attachment is obsolete: true
Attachment #8686986 -
Flags: review+
Assignee | ||
Comment 26•9 years ago
|
||
Assignee | ||
Comment 27•9 years ago
|
||
Updated•9 years ago
|
Attachment #8686979 -
Flags: review?(catalin.badea392) → review+
Comment 28•9 years ago
|
||
Assignee | ||
Comment 29•9 years ago
|
||
Comment on attachment 8686979 [details] [diff] [review]
P1 Expose nsIServiceWorkerManager.shouldReportToWindow(). r=catalinb
Approval request for patches P1 to P3. All the patches.
Approval Request Comment
[Feature/regressing bug #]: Service workers
[User impact if declined]: This is needed to provide a better developer experience for sites trying to use service workers on firefox. It improves where console.log() messages from a service worker show up.
[Describe test coverage new/current, TreeHerder]: Included test.
[Risks and why]: Minimal. Only affects service workers.
[String/UUID change made/needed]: None.
Attachment #8686979 -
Flags: approval-mozilla-aurora?
Assignee | ||
Updated•9 years ago
|
Will wait for these to land on m-c before approving uplift to m-a.
Comment 31•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/69f09bd56c59
https://hg.mozilla.org/mozilla-central/rev/50cf666c196d
https://hg.mozilla.org/mozilla-central/rev/d60d5f8ffda4
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 45
Comment on attachment 8686979 [details] [diff] [review]
P1 Expose nsIServiceWorkerManager.shouldReportToWindow(). r=catalinb
SW is planned for FF44
Attachment #8686979 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment on attachment 8685755 [details] [diff] [review]
P2 Make webconsole use new nsIServiceWorkerManager.shouldReportToWindow(). r=bgrins
Aurora44+
Attachment #8685755 -
Flags: approval-mozilla-aurora+
Comment on attachment 8686986 [details] [diff] [review]
P3 Extend the test to check console messages for more service worker condit ions. r=bgrins
Aurora44+
Attachment #8686986 -
Flags: approval-mozilla-aurora+
I'm hitting conflicts uplifting this to aurora. Can we get rebased patches?
Flags: needinfo?(bkelly)
Assignee | ||
Comment 36•9 years ago
|
||
Yea, this depends on bug 1217909. I will uplift both later today. Thanks.
Assignee | ||
Comment 37•9 years ago
|
||
remote: https://hg.mozilla.org/releases/mozilla-aurora/rev/a8babe14e557
remote: https://hg.mozilla.org/releases/mozilla-aurora/rev/4ddcaa564eb8
remote: https://hg.mozilla.org/releases/mozilla-aurora/rev/7e411051b2d6
Flags: needinfo?(bkelly)
Comment 38•9 years ago
|
||
bugherder uplift |
https://hg.mozilla.org/releases/mozilla-b2g44_v2_5/rev/a8babe14e557
https://hg.mozilla.org/releases/mozilla-b2g44_v2_5/rev/4ddcaa564eb8
https://hg.mozilla.org/releases/mozilla-b2g44_v2_5/rev/7e411051b2d6
status-b2g-v2.5:
--- → fixed
Updated•9 years ago
|
status-b2g-v2.5:
fixed → ---
Updated•7 years ago
|
Product: Firefox → DevTools
Updated•6 years ago
|
Blocks: dt-service-worker
You need to log in
before you can comment on or make changes to this bug.
Description
•