Closed
Bug 1448531
Opened 6 years ago
Closed 6 years ago
Use BrowserTestUtils.waitForNewTab in test for drag-and-drop URLs
Categories
(Core :: DOM: Copy & Paste and Drag & Drop, enhancement)
Core
DOM: Copy & Paste and Drag & Drop
Tracking
()
RESOLVED
FIXED
mozilla61
Tracking | Status | |
---|---|---|
firefox61 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(6 files, 3 obsolete files)
18.04 KB,
patch
|
enndeakin
:
review+
|
Details | Diff | Splinter Review |
15.30 KB,
patch
|
enndeakin
:
review+
|
Details | Diff | Splinter Review |
4.23 KB,
patch
|
enndeakin
:
review+
|
Details | Diff | Splinter Review |
Part 5: Add BrowserTestUtils.waitForNewWindow and use it in tests for drag-and-drop URLs for window.
9.41 KB,
patch
|
enndeakin
:
review+
|
Details | Diff | Splinter Review |
6.34 KB,
patch
|
enndeakin
:
review+
|
Details | Diff | Splinter Review |
1.71 KB,
patch
|
dao
:
review+
|
Details | Diff | Splinter Review |
Currently the following tests are counting the number of opened tab/window, but we should check the URLs of the actually opened tabs/windows. https://searchfox.org/mozilla-central/source/browser/base/content/test/general/browser_newTabDrop.js https://searchfox.org/mozilla-central/source/browser/base/content/test/general/browser_newWindowDrop.js https://searchfox.org/mozilla-central/source/browser/base/content/test/general/browser_tabDrop.js We can use BrowserTestUtils.waitForNewTab for tabs.
Assignee | ||
Comment 1•6 years ago
|
||
tests for tab can be rewritten easily. the test for window is troublesome, because the current BrowserTestUtils doesn't support waiting for error page in new window, and also waiting for *any* new window with given URL. supporting them will introduce 1 or more parameters into some helper functions, and I wonder if I should change the functions signature first (use single object instead of multiple parameters)
Assignee | ||
Comment 2•6 years ago
|
||
try https://treeherder.mozilla.org/#/jobs?repo=try&revision=8fd424083df674065966c4f637091705b98426fa
Assignee | ||
Comment 3•6 years ago
|
||
Changed manual TabOpen event handling to BrowserTestUtils.waitForNewTab, with expected URLs. ANY_URL is used for search case, to accept any URL.
Assignee | ||
Comment 4•6 years ago
|
||
So, I needed the similar testing function for window case, and added BrowserTestUtils.waitForAnyNewBrowserWindow (added separate function because this behaves very differently than BrowserTestUtils.waitForNewWindow) Then, some URLs results in error page, and "load" event is not dispatched, and browserLoaded didn't work. So added maybeErrorPage parameter which uses DOMContentLoaded event that is dispatched for error page case, and also in that case it uses document.location.href, because event.target.documentURI is "about:neterror..."
Attachment #8962148 -
Flags: review?(enndeakin)
Comment 5•6 years ago
|
||
Comment on attachment 8962148 [details] [diff] [review] Part 2: Add BrowserTestUtils.waitForAnyNewBrowserWindow and use it in tests for drag-and-drop URLs for window. I'd rather not have two wait-for-window-open functions, especially since it isn't clear when you would use one or other. I don't see anything that stands out as being too different about the two functions.
Assignee | ||
Comment 6•6 years ago
|
||
Okay, I'll merge them into one. then, I think it's better making the parameter an object, to clarify which "true" is what (I think it's better fixing other APIs as well) this patch just changes the signature of BrowserTestUtils.waitForNewWindow, and fixes tests that passes the parameter.
Attachment #8962148 -
Attachment is obsolete: true
Attachment #8962148 -
Flags: review?(enndeakin)
Attachment #8963856 -
Flags: review?(enndeakin)
Assignee | ||
Comment 7•6 years ago
|
||
and this patch adds anyWindow parameter.
Attachment #8963857 -
Flags: review?(enndeakin)
Assignee | ||
Comment 8•6 years ago
|
||
and maybeErrorPage parameter to BrowserTestUtils.waitForNewWindow and BrowserTestUtils.browserLoaded. (I'll file a bug to fix BrowserTestUtils.browserLoaded parameter if this way is fine)
Attachment #8963858 -
Flags: review?(enndeakin)
Assignee | ||
Comment 9•6 years ago
|
||
and finally fixes browser_newWindowDrop.js by using BrowserTestUtils.waitForNewWindow
Attachment #8963859 -
Flags: review?(enndeakin)
Updated•6 years ago
|
Attachment #8962147 -
Flags: review?(enndeakin) → review+
Updated•6 years ago
|
Attachment #8963856 -
Flags: review?(enndeakin) → review+
Comment 10•6 years ago
|
||
Comment on attachment 8963857 [details] [diff] [review] Part 3: Add anyWindow parameter to BrowserTestUtils.waitForNewWindow. >+ >+ let win = subject.QueryInterface(Ci.nsIDOMWindow); QueryInterface isn't needed here. You can just call the argument 'win'.
Attachment #8963857 -
Flags: review?(enndeakin) → review+
Comment 11•6 years ago
|
||
Comment on attachment 8963858 [details] [diff] [review] Part 4: Add maybeErrorPage parameter to BrowserTestUtils.waitForNewWindow and BrowserTestUtils.browserLoaded. > let mm = browser.ownerGlobal.messageManager; >- mm.addMessageListener("browser-test-utils:loadEvent", function onLoad(msg) { >+ let eventName = maybeErrorPage >+ ? "browser-test-utils:DOMContentLoadedEvent" >+ : "browser-test-utils:loadEvent"; >+ mm.addMessageListener(eventName, function onLoad(msg) { > if (msg.target == browser && (!msg.data.subframe || includeSubFrames) && >- isWanted(msg.data.url)) { >- mm.removeMessageListener("browser-test-utils:loadEvent", onLoad); >+ isWanted(maybeErrorPage ? msg.data.href : msg.data.url)) { >+ mm.removeMessageListener(eventName, onLoad); It's a bit confusing having 'href' and 'url' here being different in a way that isn't clear what the distinction is. I'm not really sure myself.
Updated•6 years ago
|
Attachment #8963859 -
Flags: review?(enndeakin) → review+
Assignee | ||
Comment 12•6 years ago
|
||
Okay, I renamed them to internalURL/visibleURL, and also added some comment.
Attachment #8963858 -
Attachment is obsolete: true
Attachment #8963858 -
Flags: review?(enndeakin)
Attachment #8964784 -
Flags: review?(enndeakin)
Updated•6 years ago
|
Attachment #8964784 -
Flags: review?(enndeakin) → review+
Assignee | ||
Comment 13•6 years ago
|
||
Thank you for reviewing :) unfortunately these patches fail on debug build, because of a leak: https://treeherder.mozilla.org/#/jobs?repo=try&revision=9fe272799329307fcdfc672d6b9aad79dc72aefd&group_state=expanded&selectedJob=172230608 looks like the anyWindow option leaks the dialog, because it's waiting forever on confirm dialog that is not what the test expects. I'll try fixing shortly.
Assignee | ||
Comment 14•6 years ago
|
||
So, it turns out that observer for browser-delayed-startup-finished is the reason of the leak. because the observer is not removed if non-browser window is opened. I've made TestUtils.topicObserved to return a function that removes the observer, as an optional out-parameter, and made BrowserTestUtils.waitForNewWindow to use it.
Attachment #8965585 -
Flags: review?(dao+bmo)
Comment 15•6 years ago
|
||
Comment on attachment 8965585 [details] [diff] [review] Part 6: Remove unnecessary observer in BrowserTestUtils.waitForNewWindow. >+ let startupObservationCanceller = { value: null }; > let promises = [ > TestUtils.topicObserved("browser-delayed-startup-finished", >- subject => subject == win), >+ subject => subject == win, >+ startupObservationCanceller), > ]; > > if (url) { > await this.waitForEvent(win, "DOMContentLoaded"); > > if (win.document.documentURI != "chrome://browser/content/browser.xul") { >+ // For non-browser window, browser-delayed-startup-finished >+ // won't be notified. We should remove the observer. >+ startupObservationCanceller.value(); Can you just check win.location before adding the observer (and before waiting for DOMContentLoaded, I guess)?
Attachment #8965585 -
Flags: review?(dao+bmo) → review-
Assignee | ||
Comment 16•6 years ago
|
||
Thank you for reviewing! (In reply to Dão Gottwald [::dao] from comment #15) > Can you just check win.location before adding the observer (and before > waiting for DOMContentLoaded, I guess)? unfortunately, win.location.href is "about:blank" at that point. if there's any other way to get the URL specified by openWindow/openDialog, we could use it tho...
Comment 17•6 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #16) > Thank you for reviewing! > > (In reply to Dão Gottwald [::dao] from comment #15) > > Can you just check win.location before adding the observer (and before > > waiting for DOMContentLoaded, I guess)? > > unfortunately, win.location.href is "about:blank" at that point. Hmm. Did bug 1336227 "break" this? Alternatively, you can add the observer after DOMContentLoaded.
Assignee | ||
Comment 18•6 years ago
|
||
(In reply to Dão Gottwald [::dao] from comment #17) > (In reply to Tooru Fujisawa [:arai] from comment #16) > > Thank you for reviewing! > > > > (In reply to Dão Gottwald [::dao] from comment #15) > > > Can you just check win.location before adding the observer (and before > > > waiting for DOMContentLoaded, I guess)? > > > > unfortunately, win.location.href is "about:blank" at that point. > > Hmm. Did bug 1336227 "break" this? possibly. > Alternatively, you can add the observer after DOMContentLoaded. yeah, it seems to work locally. I'll ask review after try run, to make sure the reordering doesn't break other tests.
Assignee | ||
Comment 19•6 years ago
|
||
Okay, waiting for DOMContentLoaded before adding browser-delayed-startup-finished observer works
Attachment #8965585 -
Attachment is obsolete: true
Attachment #8966092 -
Flags: review?(dao+bmo)
Updated•6 years ago
|
Attachment #8966092 -
Flags: review?(dao+bmo) → review+
Assignee | ||
Comment 20•6 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/f344c2aa32c929855c05250e1a58bde0ece1d0b0 Bug 1448531 - Part 1: Use BrowserTestUtils.waitForNewTab in tests for drag-and-drop URLs for tab. r=enndeakin https://hg.mozilla.org/integration/mozilla-inbound/rev/0a6b2d9e232e47cbb718190056576f0bca79c2e5 Bug 1448531 - Part 2: Make BrowserTestUtils.waitForNewWindow receive parameters object. r=enndeakin https://hg.mozilla.org/integration/mozilla-inbound/rev/ab9912ab15f7daf6d0fea0fabdaed1d7b07fce88 Bug 1448531 - Part 3: Add anyWindow parameter to BrowserTestUtils.waitForNewWindow. r=enndeakin https://hg.mozilla.org/integration/mozilla-inbound/rev/b6bbfaef732e42910ca7b1a2c110f4f15b0f443e Bug 1448531 - Part 4: Add maybeErrorPage parameter to BrowserTestUtils.waitForNewWindow and BrowserTestUtils.browserLoaded. r=enndeakin https://hg.mozilla.org/integration/mozilla-inbound/rev/de4ceede58ecf75ce76e5442b241926c06d35843 Bug 1448531 - Part 5: Add BrowserTestUtils.waitForNewWindow and use it in tests for drag-and-drop URLs for window. r=enndeakin https://hg.mozilla.org/integration/mozilla-inbound/rev/d2b269a30cba2645488b6f67e10a681ba750120c Bug 1448531 - Part 6: Wait for DOMContentLoaded before adding observer. r=dao
Assignee | ||
Comment 21•6 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/73a3eabd2bd29d2ef8945648615f49ed29b326c9 Bug 1448531 - Part 7: Request longer timeout for browser/base/content/test/general/browser_newTabDrop.js. r=bustage
Comment 22•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/f344c2aa32c9 https://hg.mozilla.org/mozilla-central/rev/0a6b2d9e232e https://hg.mozilla.org/mozilla-central/rev/ab9912ab15f7 https://hg.mozilla.org/mozilla-central/rev/b6bbfaef732e https://hg.mozilla.org/mozilla-central/rev/de4ceede58ec https://hg.mozilla.org/mozilla-central/rev/d2b269a30cba https://hg.mozilla.org/mozilla-central/rev/73a3eabd2bd2
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in
before you can comment on or make changes to this bug.
Description
•