Closed
Bug 1122516
Opened 11 years ago
Closed 11 years ago
Refactor tabBrowser's closeAllTabs() method in firefox/lib/tabs.js
Categories
(Mozilla QA Graveyard :: Mozmill Tests, defect, P1)
Tracking
(firefox35 fixed, firefox36 fixed, firefox37 fixed, firefox38 fixed, firefox-esr31 wontfix)
People
(Reporter: teodruta, Assigned: teodruta)
References
Details
Attachments
(2 files, 5 obsolete files)
4.61 KB,
patch
|
AndreeaMatei
:
review+
|
Details | Diff | Splinter Review |
4.64 KB,
patch
|
AndreeaMatei
:
review+
|
Details | Diff | Splinter Review |
This method does not clear the history, this could make follow-up tests to fail.
Comment 1•11 years ago
|
||
Why it should clear the history? We need to be able to use this method even without clearing the history. What if we use the method and then we want to restore a tab?
Assignee | ||
Comment 2•11 years ago
|
||
(In reply to Cosmin Malutan, [:cosmin-malutan] from comment #1)
> Why it should clear the history? We need to be able to use this method even
> without clearing the history. What if we use the method and then we want to
> restore a tab?
Then I think that it should be passed as an optional parameter, or maybe even better let the method clear history by default, and pass an optional parameter otherwise.
Comment 3•11 years ago
|
||
When I talked with Teodor on IRC and meant clearing the history, it is about the backward and forward buttons in this tab. To be sure to start with a really clean new tab we should then open a new one at the end but not re-use an already open one.
Comment 4•11 years ago
|
||
Also I do not see that you mentioned which URL to load. As long as about:newtab cannot be handled correctly in Mozmill, we might have to disabling pre-loading of this page.
Comment 5•11 years ago
|
||
Btw. a fix here should really help us to get down the failure rate for waitForPageLoad() calls.
Priority: -- → P1
Assignee | ||
Comment 6•11 years ago
|
||
So, to sum thing up:
What actually we need here in closeAllTabs() method, is that we should open a clean new tab, with about:blank instead of about:newtab, at least till we disable the about new tab preload in mozmill, then close all other tabs.
OR:
Close all tabs besides one, the last one, open a new tab (about:blank), and then close the remaining tab.
Can you confirm this, Henrik? So we could start to work on this.
Flags: needinfo?(hskupin)
Comment 7•11 years ago
|
||
(In reply to Teodor Druta from comment #6)
> What actually we need here in closeAllTabs() method, is that we should open
> a clean new tab, with about:blank instead of about:newtab, at least till we
> disable the about new tab preload in mozmill, then close all other tabs.
That is the right set of actions, because otherwise we jump between closing and opening of tabs.
Flags: needinfo?(hskupin)
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → teodor.druta
Status: NEW → ASSIGNED
Assignee | ||
Comment 8•11 years ago
|
||
So... this should be it. Henrik, can you please provide some feedback on this ? Before I'll request for a review.
Attachment #8552447 -
Flags: feedback?(hskupin)
Comment 9•11 years ago
|
||
Comment on attachment 8552447 [details] [diff] [review]
closealltabsref.patch
Review of attachment 8552447 [details] [diff] [review]:
-----------------------------------------------------------------
::: firefox/lib/tabs.js
@@ +518,5 @@
> */
> closeAllTabs : function tabBrowser_closeAllTabs() {
> + // A new tab will open with default 'about:newtab'
> + // set the 'browser.newtab.url' preference to 'about:blank'
> + prefs.setPref(PREF_NEWTAB_URL, "about:blank");
Thinking more about it we might want to keep about:newtab but disable pre-loading as earlier discussed. Using this page would make more sense given that we hit lots of real problems in the past.
@@ +526,5 @@
> +
> + this.selectTab({index: 0});
> +
> + // Restore 'browser.newtab.url' preference to 'about:newtab'
> + prefs.setPref(PREF_NEWTAB_URL, "about:newtab");
Better to move this up right below waitForPageLoad() and put all into a try/finally to ensure we reset this pref correctly.
::: firefox/lib/tests/testCloseAllTabs.js
@@ +1,1 @@
> +/* This Source Code Form is subject to the terms of the Mozilla Public
We don't want a separate file for that. It should be testTabs.js.
Attachment #8552447 -
Flags: feedback?(hskupin) → feedback+
Assignee | ||
Comment 10•11 years ago
|
||
Removed the unit test, added the code to a new function in the testTabs.js .
Now before opening a new tab, the browser.newtab.preload property is set to false, a new tab is opened and the property is reset to default in a try/finally block.
Attachment #8552447 -
Attachment is obsolete: true
Attachment #8552979 -
Flags: review?(mihaela.velimiroviciu)
Attachment #8552979 -
Flags: review?(andreea.matei)
Comment 11•11 years ago
|
||
Comment on attachment 8552979 [details] [diff] [review]
closealltabsrefv2.patch
Review of attachment 8552979 [details] [diff] [review]:
-----------------------------------------------------------------
You can request from Henrik with this solved.
::: firefox/lib/tabs.js
@@ +526,5 @@
> + this.openTab();
> + this._controller.waitForPageLoad();
> + }
> + finally {
> + // Restore 'browser.newtab.preload' preference to false
You restore to true, the default value.
Attachment #8552979 -
Flags: review?(mihaela.velimiroviciu)
Attachment #8552979 -
Flags: review?(andreea.matei)
Attachment #8552979 -
Flags: review+
Assignee | ||
Comment 12•11 years ago
|
||
Fixed.
Attachment #8552979 -
Attachment is obsolete: true
Attachment #8553035 -
Flags: review?(hskupin)
Comment 13•11 years ago
|
||
Comment on attachment 8553035 [details] [diff] [review]
closealltabsrefv2.1.patch
Review of attachment 8553035 [details] [diff] [review]:
-----------------------------------------------------------------
::: firefox/lib/tabs.js
@@ +518,5 @@
> */
> closeAllTabs : function tabBrowser_closeAllTabs() {
> + // TODO: Bug 1120906
> + // waitForPageLoad fails after opening "about:newtab" when
> + // "browser.newtab.preload" property is set to the "true" value
"preference is set to true"
@@ +522,5 @@
> + // "browser.newtab.preload" property is set to the "true" value
> + prefs.setPref(PREF_NEWTAB_PRELOAD, false);
> +
> + try {
> + this.openTab();
Meanwhile I think it would be better to have this in openTab() given that this is the code which has to take care about it. Sorry.
@@ +523,5 @@
> + prefs.setPref(PREF_NEWTAB_PRELOAD, false);
> +
> + try {
> + this.openTab();
> + this._controller.waitForPageLoad();
I mentioned to use this.controller the last time.
@@ +527,5 @@
> + this._controller.waitForPageLoad();
> + }
> + finally {
> + // Restore 'browser.newtab.preload' preference to true
> + prefs.clearUserPref(PREF_NEWTAB_PRELOAD);
I don't see a reason for this comment. It's clear that we clear the user value.
::: firefox/lib/tests/testTabs.js
@@ +3,5 @@
> * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
>
> // Include required modules
> +var browser = require("../ui/browser");
> +var prefs = require("../../../lib/prefs");
We agreed a while ago to have ui modules in their own block.
@@ +14,5 @@
> url1: "about:preferences",
> + url2: "about:accounts",
> + urls: [BASE_URL + "layout/mozilla_mission.html",
> + BASE_URL + "layout/mozilla_organizations.html",
> + BASE_URL + "layout/mozilla_projects.html"]
Why do we need those URLs? You could easily use "about:blank?index=%x%.
@@ +19,3 @@
> };
>
> +const PREF_NEWTAB_PRELOAD = "browser.newtab.preload";
There is no need to test for the preference here.
@@ +58,5 @@
> + expect.equal(location, "about:newtab",
> + "'about:newtab' tab is open and is the active tab");
> +
> + expect.equal(browserWindow.tabs.length, 1,
> + "There is only one open tab");
You want this as the first test.
@@ +61,5 @@
> + expect.equal(browserWindow.tabs.length, 1,
> + "There is only one open tab");
> +
> + expect.equal(prefs.getPref(PREF_NEWTAB_PRELOAD, false), true,
> + "'browser.newtab.preload' preference has been set to default");
This is not a valid test because it checks against a hard-coded value. You want to remove it as mentioned above.
Attachment #8553035 -
Flags: review?(hskupin) → review-
Assignee | ||
Comment 14•11 years ago
|
||
(In reply to Henrik Skupin (:whimboo) from comment #13)
> Comment on attachment 8553035 [details] [diff] [review]
> closealltabsrefv2.1.patch
>
> Review of attachment 8553035 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: firefox/lib/tabs.js
> @@ +522,5 @@
> > + // "browser.newtab.preload" property is set to the "true" value
> > + prefs.setPref(PREF_NEWTAB_PRELOAD, false);
> > +
> > + try {
> > + this.openTab();
>
> Meanwhile I think it would be better to have this in openTab() given that
> this is the code which has to take care about it. Sorry.
>
As discussed on IRC, we can't implement this in openTab(), so we should leave this in closeAllTabs() until Mozmill 2.1.
> ::: firefox/lib/tests/testTabs.js
>
> @@ +14,5 @@
> > url1: "about:preferences",
> > + url2: "about:accounts",
> > + urls: [BASE_URL + "layout/mozilla_mission.html",
> > + BASE_URL + "layout/mozilla_organizations.html",
> > + BASE_URL + "layout/mozilla_projects.html"]
>
> Why do we need those URLs? You could easily use "about:blank?index=%x%.
>
Removed the urls, using "about:blank?index=%x% as suggested now.
> @@ +19,3 @@
> > };
> >
> > +const PREF_NEWTAB_PRELOAD = "browser.newtab.preload";
>
> There is no need to test for the preference here.
>
Removed the check for preference.
>
> @@ +61,5 @@
> > + expect.equal(browserWindow.tabs.length, 1,
> > + "There is only one open tab");
> > +
> > + expect.equal(prefs.getPref(PREF_NEWTAB_PRELOAD, false), true,
> > + "'browser.newtab.preload' preference has been set to default");
>
> This is not a valid test because it checks against a hard-coded value. You
> want to remove it as mentioned above.
I discovered that the getPref() function http://hg.mozilla.org/qa/mozmill-tests/file/default/lib/prefs.js#l64 in my opinion is not working correctly, if a default value is not specified as 2nd argument, the function will always return undefined.
Attachment #8553035 -
Attachment is obsolete: true
Attachment #8553196 -
Flags: review?(mihaela.velimiroviciu)
Attachment #8553196 -
Flags: review?(andreea.matei)
Updated•11 years ago
|
Attachment #8553196 -
Flags: review?(mihaela.velimiroviciu) → review+
Assignee | ||
Updated•11 years ago
|
Comment 15•11 years ago
|
||
Comment on attachment 8553196 [details] [diff] [review]
closealltabsrefv3.patch
Review of attachment 8553196 [details] [diff] [review]:
-----------------------------------------------------------------
Just a nit.
::: firefox/lib/tests/testTabs.js
@@ +40,5 @@
> + * Test tabBrowser closeAllTabs() method
> + * Bug 1122516
> + */
> +function testCloseAllTabs() {
> + var i = 0
semicolon missing.
Attachment #8553196 -
Flags: review?(andreea.matei) → review+
Assignee | ||
Comment 16•11 years ago
|
||
Fixed. Henrik can you please give a review of this ?
Attachment #8553196 -
Attachment is obsolete: true
Attachment #8554540 -
Flags: review?(hskupin)
Comment 17•11 years ago
|
||
Comment on attachment 8554540 [details] [diff] [review]
closealltabsrefv3.1.patch
Review of attachment 8554540 [details] [diff] [review]:
-----------------------------------------------------------------
Looks fine to me. Please fix the remaining nit, and request review from Andreea.
::: firefox/lib/tests/testTabs.js
@@ +46,5 @@
> + browserWindow.tabs.openTab();
> + browserWindow.controller.open("about:blank?index=" + i);
> + i++;
> + }
> + while (i < 2);
I don't see why this has been implemented as a do/while. Please change to a for loop like `for (var i=0; i < 2; i++)` which saves us two lines.
We could also have used data: urls, but this is probably overkill here.
Attachment #8554540 -
Flags: review?(hskupin) → review+
Assignee | ||
Comment 18•11 years ago
|
||
Changed the 'do {} while' block to a 'for () {}' one.
Attachment #8554540 -
Attachment is obsolete: true
Attachment #8555190 -
Flags: review?(andreea.matei)
Updated•11 years ago
|
Attachment #8555190 -
Flags: review?(andreea.matei) → review+
Comment 19•11 years ago
|
||
Updated•11 years ago
|
Assignee | ||
Comment 20•11 years ago
|
||
The patch applies cleanly and runs well on mozilla-aurora.
For mozilla-beta and mozilla-release it is blocked by Bug 1071566.
status-firefox-esr31:
--- → affected
No longer depends on: 1071566
Assignee | ||
Comment 21•11 years ago
|
||
This is the patch for mozilla-release and mozilla-beta.
Attachment #8555764 -
Flags: review?(andreea.matei)
Assignee | ||
Comment 22•11 years ago
|
||
This patch can't be backported to esr31, due to missing prefs lib.
Updated•11 years ago
|
Attachment #8555764 -
Flags: review?(andreea.matei) → review+
Comment 23•11 years ago
|
||
https://hg.mozilla.org/qa/mozmill-tests/rev/479f574f62b3 (aurora)
https://hg.mozilla.org/qa/mozmill-tests/rev/ff253bcb6254 (beta)
https://hg.mozilla.org/qa/mozmill-tests/rev/d39ed067f846 (release)
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Updated•6 years ago
|
Product: Mozilla QA → Mozilla QA Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•