Bug 1411396 - Cleanup and move formValidation b-c tests. r=felipe
MozReview-Commit-ID: D75z5temxCG
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -187,19 +187,16 @@ skip-if = true # bug 1393813
[browser_bug553455.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug555224.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug555767.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug559991.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
-[browser_bug561636.js]
-skip-if = true # bug 1057615
-# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug563588.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug565575.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug567306.js]
subsuite = clipboard
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug1261299.js]
@@ -232,19 +229,16 @@ skip-if = toolkit != "cocoa" # Because o
[browser_bug585830.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug590206.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug592338.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug594131.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
-[browser_bug595507.js]
-skip-if = true # bug 1057615
-# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug596687.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug597218.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug609700.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug623893.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -114,17 +114,20 @@ with Files("UpdateTopLevelContentWindowI
with Files("webrtcUI.jsm"):
BUG_COMPONENT = ("Firefox", "Device Permissions")
with Files("ZoomUI.jsm"):
BUG_COMPONENT = ("Firefox", "Toolbars and Customization")
-BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
+BROWSER_CHROME_MANIFESTS += [
+ 'test/browser/browser.ini',
+ 'test/browser/formValidation/browser.ini',
+]
XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
EXTRA_JS_MODULES += [
'AboutHome.jsm',
'AboutNewTab.jsm',
'AttributionCode.jsm',
'BrowserUITelemetry.jsm',
'BrowserUsageTelemetry.jsm',
--- a/browser/modules/test/browser/browser.ini
+++ b/browser/modules/test/browser/browser.ini
@@ -5,17 +5,16 @@ support-files =
[browser_BrowserUITelemetry_buckets.js]
skip-if = !e10s # Bug 1373549
[browser_BrowserUITelemetry_defaults.js]
skip-if = !e10s # Bug 1373549
[browser_BrowserUITelemetry_sidebar.js]
skip-if = !e10s # Bug 1373549
[browser_BrowserUITelemetry_syncedtabs.js]
skip-if = !e10s # Bug 1373549
-[browser_bug1319078.js]
[browser_ContentSearch.js]
support-files =
contentSearch.js
contentSearchBadImage.xml
contentSearchSuggestions.sjs
contentSearchSuggestions.xml
!/browser/components/search/test/head.js
!/browser/components/search/test/testEngine.xml
new file mode 100644
--- /dev/null
+++ b/browser/modules/test/browser/formValidation/.eslinrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+ "extends": [
+ "plugin:mozilla/browser-test"
+ ]
+};
new file mode 100644
--- /dev/null
+++ b/browser/modules/test/browser/formValidation/browser.ini
@@ -0,0 +1,4 @@
+[browser_form_validation.js]
+skip-if = true # bug 1057615
+[browser_validation_iframe.js]
+[browser_validation_invisible.js]
rename from browser/base/content/test/general/browser_bug561636.js
rename to browser/modules/test/browser/formValidation/browser_form_validation.js
--- a/browser/base/content/test/general/browser_bug561636.js
+++ b/browser/modules/test/browser/formValidation/browser_form_validation.js
@@ -1,8 +1,44 @@
+/**
+ * COPIED FROM browser/base/content/test/general/head.js.
+ * This function should be removed and replaced with BTU withNewTab calls
+ *
+ * Waits for a load (or custom) event to finish in a given tab. If provided
+ * load an uri into the tab.
+ *
+ * @param tab
+ * The tab to load into.
+ * @param [optional] url
+ * The url to load, or the current url.
+ * @return {Promise} resolved when the event is handled.
+ * @resolves to the received event
+ * @rejects if a valid load event is not received within a meaningful interval
+ */
+function promiseTabLoadEvent(tab, url) {
+ info("Wait tab event: load");
+
+ function handle(loadedUrl) {
+ if (loadedUrl === "about:blank" || (url && loadedUrl !== url)) {
+ info(`Skipping spurious load event for ${loadedUrl}`);
+ return false;
+ }
+
+ info("Tab event received: load");
+ return true;
+ }
+
+ let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
+
+ if (url)
+ BrowserTestUtils.loadURI(tab.linkedBrowser, url);
+
+ return loaded;
+}
+
var gInvalidFormPopup = document.getElementById("invalid-form-popup");
ok(gInvalidFormPopup,
"The browser should have a popup to show when a form is invalid");
function checkPopupShow() {
ok(gInvalidFormPopup.state == "showing" || gInvalidFormPopup.state == "open",
"[Test " + testId + "] The invalid form popup should be shown");
}
@@ -101,17 +137,17 @@ add_task(async function() {
* In this test, we check that, when an invalid form is submitted,
* the invalid element is focused and a popup appears.
*/
add_task(async function() {
incrementTest();
let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input required id='i'><input id='s' type='submit'></form>" + getDocFooter();
let browser = await openNewTab(uri);
- let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
+ let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
gBrowser.removeCurrentTab();
});
@@ -120,17 +156,17 @@ add_task(async function() {
* In this test, we check that, when an invalid form is submitted,
* the first invalid element is focused and a popup appears.
*/
add_task(async function() {
incrementTest();
let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input><input id='i' required><input required><input id='s' type='submit'></form>" + getDocFooter();
let browser = await openNewTab(uri);
- let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
+ let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
gBrowser.removeCurrentTab();
});
@@ -139,40 +175,40 @@ add_task(async function() {
* In this test, we check that, we hide the popup by interacting with the
* invalid element if the element becomes valid.
*/
add_task(async function() {
incrementTest();
let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter();
let browser = await openNewTab(uri);
- let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
+ let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
- let popupHiddenPromise = promiseWaitForEvent(gInvalidFormPopup, "popuphidden");
+ let popupHiddenPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popuphidden");
EventUtils.synthesizeKey("a", {});
await popupHiddenPromise;
gBrowser.removeCurrentTab();
});
/**
* In this test, we check that, we don't hide the popup by interacting with the
* invalid element if the element is still invalid.
*/
add_task(async function() {
incrementTest();
let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input type='email' id='i' required><input id='s' type='submit'></form>" + getDocFooter();
let browser = await openNewTab(uri);
- let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
+ let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
await new Promise((resolve, reject) => {
EventUtils.synthesizeKey("a", {});
@@ -189,68 +225,68 @@ add_task(async function() {
* In this test, we check that we can hide the popup by blurring the invalid
* element.
*/
add_task(async function() {
incrementTest();
let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter();
let browser = await openNewTab(uri);
- let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
+ let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
- let popupHiddenPromise = promiseWaitForEvent(gInvalidFormPopup, "popuphidden");
+ let popupHiddenPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popuphidden");
await blurChildElement(browser);
await popupHiddenPromise;
gBrowser.removeCurrentTab();
});
/**
* In this test, we check that we can hide the popup by pressing TAB.
*/
add_task(async function() {
incrementTest();
let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter();
let browser = await openNewTab(uri);
- let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
+ let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
- let popupHiddenPromise = promiseWaitForEvent(gInvalidFormPopup, "popuphidden");
+ let popupHiddenPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popuphidden");
EventUtils.synthesizeKey("VK_TAB", {});
await popupHiddenPromise;
gBrowser.removeCurrentTab();
});
/**
* In this test, we check that the popup will hide if we move to another tab.
*/
add_task(async function() {
incrementTest();
let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter();
let browser1 = await openNewTab(uri);
- let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
+ let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser1);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser1, gInvalidFormPopup.firstChild.textContent);
- let popupHiddenPromise = promiseWaitForEvent(gInvalidFormPopup, "popuphidden");
+ let popupHiddenPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popuphidden");
let browser2 = await openNewTab("data:text/html,<html></html>");
await popupHiddenPromise;
gBrowser.removeTab(gBrowser.getTabForBrowser(browser1));
gBrowser.removeTab(gBrowser.getTabForBrowser(browser2));
});
@@ -297,17 +333,17 @@ add_task(async function() {
/**
* In this test, we check that the author defined error message is shown.
*/
add_task(async function() {
incrementTest();
let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input x-moz-errormessage='foo' required id='i'><input id='s' type='submit'></form>" + getDocFooter();
let browser = await openNewTab(uri);
- let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
+ let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
is(gInvalidFormPopup.firstChild.textContent, "foo",
"The panel should show the author defined error message");
@@ -318,24 +354,24 @@ add_task(async function() {
/**
* In this test, we check that the message is correctly updated when it changes.
*/
add_task(async function() {
incrementTest();
let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input type='email' required id='i'><input id='s' type='submit'></form>" + getDocFooter();
let browser = await openNewTab(uri);
- let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
+ let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
- let inputPromise = promiseWaitForEvent(gBrowser.contentDocument.getElementById("i"), "input");
+ let inputPromise = BrowserTestUtils.waitForEvent(gBrowser.contentDocument.getElementById("i"), "input");
EventUtils.synthesizeKey("f", {});
await inputPromise;
// Now, the element suffers from another error, the message should have
// been updated.
await new Promise((resolve, reject) => {
// XXXndeakin This isn't really going to work when the content is another process
executeSoon(function() {
rename from browser/base/content/test/general/browser_bug595507.js
rename to browser/modules/test/browser/formValidation/browser_validation_iframe.js
--- a/browser/base/content/test/general/browser_bug595507.js
+++ b/browser/modules/test/browser/formValidation/browser_validation_iframe.js
@@ -1,36 +1,29 @@
/**
* Make sure that the form validation error message shows even if the form is in an iframe.
*/
-add_task(async function() {
- let uri = "<iframe src=\"data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input required id='i'><input id='s' type='submit'></form>\"</iframe>";
+add_task(async function test_iframe() {
+ let uri = "data:text/html;charset=utf-8," + escape("<iframe src=\"data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input required id='i'><input id='s' type='submit'></form>\" height=\"600\"></iframe>");
var gInvalidFormPopup = document.getElementById("invalid-form-popup");
ok(gInvalidFormPopup,
"The browser should have a popup to show when a form is invalid");
- let tab = BrowserTestUtils.addTab(gBrowser);
- let browser = gBrowser.getBrowserForTab(tab);
- gBrowser.selectedTab = tab;
+ await BrowserTestUtils.withNewTab(uri, async function checkTab(browser) {
+ let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
- await promiseTabLoadEvent(tab, "data:text/html," + escape(uri));
+ await ContentTask.spawn(browser, {}, async function() {
+ content.document.getElementsByTagName("iframe")[0]
+ .contentDocument.getElementById("s").click();
+ });
+ await popupShownPromise;
- let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
+ await ContentTask.spawn(browser, {}, async function() {
+ let childdoc = content.document.getElementsByTagName("iframe")[0].contentDocument;
+ Assert.equal(childdoc.activeElement, childdoc.getElementById("i"),
+ "First invalid element should be focused");
+ });
- await ContentTask.spawn(browser, {}, async function() {
- content.document.getElementsByTagName("iframe")[0]
- .contentDocument.getElementById("s").click();
+ ok(gInvalidFormPopup.state == "showing" || gInvalidFormPopup.state == "open",
+ "The invalid form popup should be shown");
});
- await popupShownPromise;
-
- await ContentTask.spawn(browser, {}, async function() {
- let childdoc = content.document.getElementsByTagName("iframe")[0].contentDocument;
- Assert.equal(childdoc.activeElement, childdoc.getElementById("i"),
- "First invalid element should be focused");
- });
-
- ok(gInvalidFormPopup.state == "showing" || gInvalidFormPopup.state == "open",
- "The invalid form popup should be shown");
-
- gBrowser.removeCurrentTab();
});
-
rename from browser/modules/test/browser/browser_bug1319078.js
rename to browser/modules/test/browser/formValidation/browser_validation_invisible.js
--- a/browser/modules/test/browser/browser_bug1319078.js
+++ b/browser/modules/test/browser/formValidation/browser_validation_invisible.js
@@ -12,38 +12,38 @@ var testId = 0;
function incrementTest() {
testId++;
info("Starting next part of test");
}
/**
* In this test, we check that no popup appears if the element display is none.
*/
-add_task(async function() {
+add_task(async function test_display_none() {
ok(gInvalidFormPopup,
"The browser should have a popup to show when a form is invalid");
incrementTest();
let testPage =
- "data:text/html," +
+ "data:text/html;charset=utf-8," +
'<form target="t"><input type="url" placeholder="url" value="http://" style="display: none;"><input id="s" type="button" value="check"></form>';
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, testPage);
await BrowserTestUtils.synthesizeMouse("#s", 0, 0, {}, gBrowser.selectedBrowser);
checkPopupHide();
await BrowserTestUtils.removeTab(tab);
});
/**
* In this test, we check that no popup appears if the element visibility is hidden.
*/
-add_task(async function() {
+add_task(async function test_visibility_hidden() {
incrementTest();
let testPage =
- "data:text/html," +
+ "data:text/html;charset=utf-8," +
'<form target="t"><input type="url" placeholder="url" value="http://" style="visibility: hidden;"><input id="s" type="button" value="check"></form>';
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, testPage);
await BrowserTestUtils.synthesizeMouse("#s", 0, 0, {}, gBrowser.selectedBrowser);
checkPopupHide();
await BrowserTestUtils.removeTab(tab);
});