Closed
Bug 1110677
Opened 10 years ago
Closed 9 years ago
Add automated test for "Change newtab page appearance"
Categories
(Firefox :: New Tab Page, defect)
Firefox
New Tab Page
Tracking
()
RESOLVED
FIXED
Firefox 38
People
(Reporter: teodruta, Assigned: cosmin-malutan)
References
()
Details
Attachments
(1 file, 3 obsolete files)
3.48 KB,
patch
|
ttaubert
:
review+
|
Details | Diff | Splinter Review |
https://moztrap.mozilla.org/manage/case/14576/ 1. Open Firefox 2. Go to about:newtab or open a new tab 3. Click on the gear (preferences) button located in the top right corner of the page >> "You are able to change between 3 modes: Enhanced, Classic and Blank. Also, you will have a fourth option, which is ""What is this page?""" The new test should be chrome, and should live under: https://github.com/mozilla/gecko-dev/tree/master/browser/base/content/test/newtab
Reporter | ||
Comment 1•10 years ago
|
||
Tim, can you please provide your input on this ? Will this test be helpful ?
Flags: needinfo?(ttaubert)
Comment 2•10 years ago
|
||
I thought we have a test for this? Ed, what of this is covered already?
Flags: needinfo?(ttaubert) → needinfo?(edilee)
Comment 3•10 years ago
|
||
There's https://github.com/mozilla/gecko-dev/blob/master/browser/base/content/test/newtab/browser_newtab_enhanced.js that tests if the tiles are showing history vs enhanced tiles depending on the enhanced/classic state. I don't think there's a test for the click event checking to make sure the menu options switches prefs correctly.
Flags: needinfo?(edilee)
Comment 4•10 years ago
|
||
We could cover that by instead of toggling |NewTabUtils.allPages.enhanced| actually opening the popup and calling .click() on the desired menu item. That would just be updating the existing test instead of writing a new one.
Updated•10 years ago
|
Component: Mochitest Chrome → New Tab Page
Product: Testing → Firefox
Assignee | ||
Comment 5•10 years ago
|
||
I created an helper method which opens newtab customization panel, changes the option and closes the panel, the I replaced the direct configuration changes with that method in test itself. With this patch we will have full coverage for the moztrap https://moztrap.mozilla.org/manage/case/14576/
Assignee: nobody → cosmin.malutan
Status: NEW → ASSIGNED
Attachment #8540651 -
Flags: review?(edilee)
Assignee | ||
Updated•9 years ago
|
Attachment #8540651 -
Flags: review?(ttaubert)
Comment 6•9 years ago
|
||
Comment on attachment 8540651 [details] [diff] [review] patch v1.0 Review of attachment 8540651 [details] [diff] [review]: ----------------------------------------------------------------- This looks great, just a few comments we should address. Thanks! ::: browser/base/content/test/newtab/browser_newtab_enhanced.js @@ +75,5 @@ > is(title, "site#-1"); > > is(getData(1), null, "directory link still pushed out by pinned history link"); > + > + ok(!!getContentDocument().getElementById("newtab-intro-what"), Nit: the !! isn't needed, we'll cast it to a bool anyway. ::: browser/base/content/test/newtab/head.js @@ +690,5 @@ > + * > + * @param {string} aOption > + * Option to be set("blank"|"classic"|"enhanced") > + */ > +function customizeNewTabPage(aOption) { "aOption" sound like we would accept options. Should rename it to maybe "aTheme" or something? We can surely find a better name. @@ +691,5 @@ > + * @param {string} aOption > + * Option to be set("blank"|"classic"|"enhanced") > + */ > +function customizeNewTabPage(aOption) { > + let deferred = new Promise.defer(); Should use the new Promise() API, without any Deferreds. @@ +701,5 @@ > + panel.removeEventListener("popupshown", onShown); > + > + // Get the element for the specific option and click on it, > + // then trigger an escape to close the panel > + document.getElementById("newtab-customize-"+aOption).click(); Nit: I'd move that to a variable under "let panel = ...". @@ +702,5 @@ > + > + // Get the element for the specific option and click on it, > + // then trigger an escape to close the panel > + document.getElementById("newtab-customize-"+aOption).click(); > + EventUtils.synthesizeKey("VK_ESCAPE", {}); EventUtils have focus issues sometimes, can't we just call panel.hidePopup()? Maybe off executeSoon() because we're inside an event handler.
Attachment #8540651 -
Flags: review?(ttaubert) → feedback+
Assignee | ||
Comment 7•9 years ago
|
||
(In reply to Tim Taubert [:ttaubert] from comment #6) > EventUtils have focus issues sometimes, can't we just call > panel.hidePopup()? Maybe off executeSoon() because we're inside an event > handler. I don't think we use executeSoon in this test, maybe there is something I don't understand here.
Attachment #8540651 -
Attachment is obsolete: true
Attachment #8540651 -
Flags: review?(edilee)
Attachment #8546572 -
Flags: review?(ttaubert)
Comment 8•9 years ago
|
||
(In reply to Cosmin Malutan from comment #7) > (In reply to Tim Taubert [:ttaubert] from comment #6) > > EventUtils have focus issues sometimes, can't we just call > > panel.hidePopup()? Maybe off executeSoon() because we're inside an event > > handler. > I don't think we use executeSoon in this test, maybe there is something I > don't understand here. The concern is that synthesizing ESC might send it to the wrong place, i.e., not the panel, so it would end up never dismissing. We're not testing the functionality of hiding the panel, so it would be good enough to just call hidePopup() to get rid of it. We might need an executeSoon() to delay the hiding of the popup just momentarily to allow the currently triggering popup event to complete before changing state of the popup.
Assignee | ||
Comment 9•9 years ago
|
||
(In reply to Ed Lee :Mardak from comment #8) > The concern is that synthesizing ESC might send it to the wrong place, i.e., > not the panel, so it would end up never dismissing. We're not testing the > functionality of hiding the panel, so it would be good enough to just call > hidePopup() to get rid of it. We might need an executeSoon() to delay the > hiding of the popup just momentarily to allow the currently triggering popup > event to complete before changing state of the popup. Makes sense, thanks for explanation.
Attachment #8546572 -
Attachment is obsolete: true
Attachment #8546572 -
Flags: review?(ttaubert)
Attachment #8547402 -
Flags: review?(ttaubert)
Comment 10•9 years ago
|
||
Comment on attachment 8547402 [details] [diff] [review] patch v2.1 Review of attachment 8547402 [details] [diff] [review]: ----------------------------------------------------------------- ::: browser/base/content/test/newtab/head.js @@ +685,5 @@ > return deferred.promise; > } > + > +/** > + * Change the newtab customization option and waits for panel to open and close Nit: "Changes..." and "... for the panel to..." @@ +688,5 @@ > +/** > + * Change the newtab customization option and waits for panel to open and close > + * > + * @param {string} aTheme > + * Option to be set("blank"|"classic"|"enhanced") Nit: Maybe s/Option to be/Can be any of/? @@ +702,5 @@ > + > + // Get the element for the specific option and click on it, > + // then trigger an escape to close the panel > + document.getElementById("newtab-customize-"+aTheme).click(); > + panel.hidePopup(); executeSoon(() => panel.hidePopup()); We should wait for the event to be fully processed before closing the popup again. @@ +708,5 @@ > + > + let promise = new Promise((resolve) => { > + // Attache the listener for panel closing, this will resolve the promise > + panel.addEventListener("popuphidden", function onShown() { > + panel.removeEventListener("popuphidden", onShown); The function name should be "onHidden". @@ +709,5 @@ > + let promise = new Promise((resolve) => { > + // Attache the listener for panel closing, this will resolve the promise > + panel.addEventListener("popuphidden", function onShown() { > + panel.removeEventListener("popuphidden", onShown); > + resolve(); Instead of using a Promise at all, we should do: executeSoon(TestRunner.next); That effectively does the same but is more straightforward.
Attachment #8547402 -
Flags: review?(ttaubert)
Assignee | ||
Comment 11•9 years ago
|
||
(In reply to Tim Taubert [:ttaubert] from comment #10) > > + // then trigger an escape to close the panel > > + document.getElementById("newtab-customize-"+aTheme).click(); > > + panel.hidePopup(); > > executeSoon(() => panel.hidePopup()); > > We should wait for the event to be fully processed before closing the popup > again. I thought I did that, but it seems I forget to refresh before exporting the patch, thanks.
Attachment #8547402 -
Attachment is obsolete: true
Attachment #8547507 -
Flags: review?(ttaubert)
Comment 12•9 years ago
|
||
Comment on attachment 8547507 [details] [diff] [review] patch v3.0 Review of attachment 8547507 [details] [diff] [review]: ----------------------------------------------------------------- Great, thanks! Can you please push it to try before requesting checkin-needed?
Attachment #8547507 -
Flags: review?(ttaubert) → review+
Assignee | ||
Comment 13•9 years ago
|
||
Result https://treeherder.mozilla.org/#/jobs?repo=try&revision=f33fbd5dec25
Keywords: checkin-needed
Assignee | ||
Comment 14•9 years ago
|
||
There was some failures on one build but on tests that has nothing to do with the test I enhanced.
https://hg.mozilla.org/mozilla-central/rev/e5b52cac8853
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 38
You need to log in
before you can comment on or make changes to this bug.
Description
•