Closed Bug 1205221 Opened 9 years ago Closed 9 years ago

chrome.tabs.onUpdate event doesn't be sent when updating tab's attribute

Categories

(WebExtensions :: Untriaged, defect)

defect
Not set
normal

Tracking

(firefox45 fixed)

RESOLVED FIXED
mozilla45
Iteration:
45.1 - Nov 16
Tracking Status
firefox45 --- fixed

People

(Reporter: edgar, Assigned: edgar)

Details

(Whiteboard: [tabs])

Attachments

(1 file, 2 obsolete files)

Found this when writing a test for tabs.onUpdate event.
Attached patch WIP, Patch, v1 (obsolete) — Splinter Review
Assignee: nobody → echen
Attached patch WIP, Patch, v2 (obsolete) — Splinter Review
Attachment #8663481 - Attachment is obsolete: true
Whiteboard: [tabs]
Edgar, how is this going? Do you want to ask for review?
(In reply to Bill McCloskey (:billm) from comment #3)
> Edgar, how is this going? Do you want to ask for review?

Hi Bill, I was working on other issues these days.
Patch is almost ready, but I would like to write some more tests.
I will provide a formal patch for review early next week.
Thank you.
Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed.
Attachment #8664796 - Attachment is obsolete: true
Attachment #8675528 - Flags: review?(wmccloskey)
Comment on attachment 8675528 [details]
MozReview Request: Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed. r=billm

Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed.
Comment on attachment 8675528 [details]
MozReview Request: Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed. r=billm

https://reviewboard.mozilla.org/r/22385/#review20215

Thanks. Could you please rebase over bug 1197422? That added a WindowListManager.browserWindows generator that I think would help you.

::: browser/components/extensions/ext-tabs.js:122
(Diff revision 1)
> -        WindowListManager.addOpenListener(windowListener, false);
> +        WindowListManager.addOpenListener(windowListener);

I don't really understand how or why you're changing the fireOnExisting parameter. Could you please explain that more?
Attachment #8675528 - Flags: review?(wmccloskey)
https://reviewboard.mozilla.org/r/22385/#review20263

::: browser/components/extensions/ext-tabs.js:122
(Diff revision 1)
> -        WindowListManager.addOpenListener(windowListener, false);
> +        WindowListManager.addOpenListener(windowListener);

I change the behavior of  `WindowListManager.addOpenListener()` a bit. `WindowListManager.addOpenListener()` now won't call listener immediately with existing window any more (I also remove the `fireOnExisting` parameter).

After review the caller of `WindowListManager.addOpenListener()` again, I just realize this change affects the `window.onCreate` behavior [1]. With this change, `window.onCreate` won't be triggered by existing window. But it seems like it's the behavior we expect for `window.onCreate`, I guess.

[1] https://dxr.mozilla.org/mozilla-central/source/browser/components/extensions/ext-windows.js#18
ni for comment #8.
I will rebase over bug 1197422 and ask review again.
Thank you.
Flags: needinfo?(wmccloskey)
Flags: blocking-webextensions-
Comment on attachment 8675528 [details]
MozReview Request: Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed. r=billm

Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed.
Attachment #8675528 - Flags: review?(wmccloskey)
Flags: needinfo?(wmccloskey)
Attachment #8675528 - Flags: review?(wmccloskey) → review+
Comment on attachment 8675528 [details]
MozReview Request: Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed. r=billm

https://reviewboard.mozilla.org/r/22385/#review21087

Thanks!

::: browser/components/extensions/ext-utils.js:494
(Diff revision 2)
> +  _openListeners: new Map(),

I don't think you want this. \_openListeners is a property of WindowListManager.

::: browser/components/extensions/ext-utils.js:516
(Diff revision 2)
> -    if (needOpenListener) {
> +    // Register listener to all existing window.

"Register listener on all existing windows."

::: browser/components/extensions/ext-utils.js:518
(Diff revision 2)
> -      this.addWindowListener(window, type, listener);
> +      if (type == "progress") {
> +        window.gBrowser.addTabsProgressListener(listener);
> +      } else {
> +        window.addEventListener(type, listener);
> +      }

I don't think this needs to be changed.

::: browser/components/extensions/ext-utils.js:542
(Diff revision 2)
> +    // Unregister listener to all existing window.

"Unregister listener from all existing windows."

::: browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js:11
(Diff revision 2)
> +  yield extension.awaitMessage("finish");

Please use awaitFinish here.

::: browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js:28
(Diff revision 2)
> +          browser.test.sendMessage("finish");

Please use notifyPass here.

::: browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js:50
(Diff revision 2)
> +          browser.test.sendMessage("finish");

notifyPass

::: browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js:73
(Diff revision 2)
> +          browser.test.sendMessage("finish");

Please use notifyPass here.

::: browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js:116
(Diff revision 2)
> +            browser.test.sendMessage("finish");

notifyPass
https://reviewboard.mozilla.org/r/22385/#review21087

> I don't think you want this. \_openListeners is a property of WindowListManager.

Thanks for catching this.
Comment on attachment 8675528 [details]
MozReview Request: Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed. r=billm

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22385/diff/2-3/
Attachment #8675528 - Attachment description: MozReview Request: Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed. → MozReview Request: Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed. r=billm
browser_ext_tabs_onUpdated.js got an error during try runs [1],

62 INFO TEST-UNEXPECTED-FAIL | browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js | uncaught exception - NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsISpeculativeConnect.speculativeConnect] at chrome://browser/content/newtab/newTab.js:1278

Will update testcase to fix it.

[1] https://treeherder.mozilla.org/#/jobs?repo=try&revision=d83ede38fdb0&group_state=expanded
Comment on attachment 8675528 [details]
MozReview Request: Bug 1205221 - Fix chrome.tabs.onUpdate event doesn't be fired correctly when tab's attribute is changed. r=billm

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22385/diff/3-4/
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/e8133e4a8d6a
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Iteration: --- → 45.1 - Nov 16
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: