summaryrefslogtreecommitdiffstats
path: root/layout/xul/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--layout/xul/test/.eslintrc.js9
-rw-r--r--layout/xul/test/browser.ini9
-rw-r--r--layout/xul/test/browser_bug1163304.js56
-rw-r--r--layout/xul/test/browser_bug685470.js38
-rw-r--r--layout/xul/test/browser_bug703210.js56
-rw-r--r--layout/xul/test/browser_bug706743.js158
-rw-r--r--layout/xul/test/chrome.ini42
-rw-r--r--layout/xul/test/file_bug386386.sjs8
-rw-r--r--layout/xul/test/mochitest.ini10
-rw-r--r--layout/xul/test/test_blockify_moz_box.html126
-rw-r--r--layout/xul/test/test_bug1197913.xhtml68
-rw-r--r--layout/xul/test/test_bug159346.xhtml137
-rw-r--r--layout/xul/test/test_bug372685.xhtml49
-rw-r--r--layout/xul/test/test_bug381167.xhtml49
-rw-r--r--layout/xul/test/test_bug386386.html34
-rw-r--r--layout/xul/test/test_bug394800.xhtml39
-rw-r--r--layout/xul/test/test_bug398982-1.xhtml31
-rw-r--r--layout/xul/test/test_bug398982-2.xhtml33
-rw-r--r--layout/xul/test/test_bug467442.xhtml52
-rw-r--r--layout/xul/test/test_bug477754.xhtml49
-rw-r--r--layout/xul/test/test_bug511075.html121
-rw-r--r--layout/xul/test/test_bug563416.html53
-rw-r--r--layout/xul/test/test_bug703150.xhtml70
-rw-r--r--layout/xul/test/test_bug987230.xhtml108
-rw-r--r--layout/xul/test/test_menuitem_ctrl_click.xhtml78
-rw-r--r--layout/xul/test/test_popupReflowPos.xhtml76
-rw-r--r--layout/xul/test/test_popupSizeTo.xhtml55
-rw-r--r--layout/xul/test/test_popupZoom.xhtml53
-rw-r--r--layout/xul/test/test_resizer.xhtml94
-rw-r--r--layout/xul/test/test_resizer_ctrl_click.xhtml50
-rw-r--r--layout/xul/test/test_resizer_incontent.xhtml42
-rw-r--r--layout/xul/test/test_splitter.xhtml101
-rw-r--r--layout/xul/test/test_submenuClose.xhtml91
-rw-r--r--layout/xul/test/test_titlebar_ctrl_click.xhtml52
-rw-r--r--layout/xul/test/test_toolbarbutton_ctrl_click.xhtml50
-rw-r--r--layout/xul/test/test_windowminmaxsize.xhtml235
-rw-r--r--layout/xul/test/titledpanelwindow.xhtml4
-rw-r--r--layout/xul/test/window_resizer.xhtml113
-rw-r--r--layout/xul/test/window_resizer_element.xhtml188
-rw-r--r--layout/xul/test/windowminmaxsize1.xhtml4
-rw-r--r--layout/xul/test/windowminmaxsize10.xhtml4
-rw-r--r--layout/xul/test/windowminmaxsize2.xhtml4
-rw-r--r--layout/xul/test/windowminmaxsize3.xhtml4
-rw-r--r--layout/xul/test/windowminmaxsize4.xhtml4
-rw-r--r--layout/xul/test/windowminmaxsize5.xhtml4
-rw-r--r--layout/xul/test/windowminmaxsize6.xhtml4
-rw-r--r--layout/xul/test/windowminmaxsize7.xhtml4
-rw-r--r--layout/xul/test/windowminmaxsize8.xhtml4
-rw-r--r--layout/xul/test/windowminmaxsize9.xhtml4
49 files changed, 2727 insertions, 0 deletions
diff --git a/layout/xul/test/.eslintrc.js b/layout/xul/test/.eslintrc.js
new file mode 100644
index 0000000000..6499767b2d
--- /dev/null
+++ b/layout/xul/test/.eslintrc.js
@@ -0,0 +1,9 @@
+"use strict";
+
+module.exports = {
+ extends: [
+ "plugin:mozilla/mochitest-test",
+ "plugin:mozilla/browser-test",
+ "plugin:mozilla/chrome-test",
+ ],
+};
diff --git a/layout/xul/test/browser.ini b/layout/xul/test/browser.ini
new file mode 100644
index 0000000000..e06fed409b
--- /dev/null
+++ b/layout/xul/test/browser.ini
@@ -0,0 +1,9 @@
+[DEFAULT]
+
+[browser_bug685470.js]
+[browser_bug703210.js]
+skip-if = os == 'linux' || (verify && (os == 'linux')) || os == 'mac' || os == 'win' # Bugs 1382428, 1567736, 1565339
+[browser_bug706743.js]
+skip-if = (os == 'linux') || e10s # Bug 1157576
+[browser_bug1163304.js]
+skip-if = os != 'linux' && os != 'win' // Due to testing menubar behavior with keyboard
diff --git a/layout/xul/test/browser_bug1163304.js b/layout/xul/test/browser_bug1163304.js
new file mode 100644
index 0000000000..149a56bd79
--- /dev/null
+++ b/layout/xul/test/browser_bug1163304.js
@@ -0,0 +1,56 @@
+ChromeUtils.import(
+ "resource://testing-common/CustomizableUITestUtils.jsm",
+ this
+);
+let gCUITestUtils = new CustomizableUITestUtils(window);
+
+add_task(async function test_setup() {
+ await gCUITestUtils.addSearchBar();
+ registerCleanupFunction(() => {
+ gCUITestUtils.removeSearchBar();
+ });
+});
+
+add_task(async function() {
+ BrowserSearch.searchBar.focus();
+
+ let DOMWindowUtils = EventUtils._getDOMWindowUtils();
+ is(
+ DOMWindowUtils.IMEStatus,
+ DOMWindowUtils.IME_STATUS_ENABLED,
+ "IME should be available when searchbar has focus"
+ );
+
+ let searchPopup = document.getElementById("PopupSearchAutoComplete");
+
+ let shownPromise = BrowserTestUtils.waitForEvent(searchPopup, "popupshown");
+ // Open popup of the searchbar
+ EventUtils.synthesizeKey("KEY_F4");
+ await shownPromise;
+ await new Promise(r => setTimeout(r, 0));
+
+ is(
+ DOMWindowUtils.IMEStatus,
+ DOMWindowUtils.IME_STATUS_ENABLED,
+ "IME should be available even when the popup of searchbar is open"
+ );
+
+ // Activate the menubar, then, the popup should be closed
+ let hiddenPromise = BrowserTestUtils.waitForEvent(searchPopup, "popuphidden");
+ EventUtils.synthesizeKey("KEY_Alt");
+ await hiddenPromise;
+ await new Promise(r => setTimeout(r, 0));
+
+ is(
+ DOMWindowUtils.IMEStatus,
+ DOMWindowUtils.IME_STATUS_DISABLED,
+ "IME should not be available when menubar is active"
+ );
+ // Inactivate the menubar (and restore the focus to the searchbar
+ EventUtils.synthesizeKey("KEY_Escape");
+ is(
+ DOMWindowUtils.IMEStatus,
+ DOMWindowUtils.IME_STATUS_ENABLED,
+ "IME should be available after focus is back to the searchbar"
+ );
+});
diff --git a/layout/xul/test/browser_bug685470.js b/layout/xul/test/browser_bug685470.js
new file mode 100644
index 0000000000..8542fbaeb6
--- /dev/null
+++ b/layout/xul/test/browser_bug685470.js
@@ -0,0 +1,38 @@
+add_task(async function() {
+ const html =
+ '<p id="p1" title="tooltip is here">This paragraph has a tooltip.</p>';
+ await BrowserTestUtils.openNewForegroundTab(
+ gBrowser,
+ "data:text/html," + html
+ );
+
+ await new Promise(resolve => {
+ SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] }, resolve);
+ });
+
+ await BrowserTestUtils.synthesizeMouseAtCenter(
+ "#p1",
+ { type: "mousemove" },
+ gBrowser.selectedBrowser
+ );
+ await BrowserTestUtils.synthesizeMouseAtCenter(
+ "#p1",
+ {},
+ gBrowser.selectedBrowser
+ );
+
+ // Wait until the tooltip timeout triggers that would normally have opened the popup.
+ await new Promise(resolve => setTimeout(resolve, 0));
+ is(
+ document.getElementById("aHTMLTooltip").state,
+ "closed",
+ "local tooltip is closed"
+ );
+ is(
+ document.getElementById("remoteBrowserTooltip").state,
+ "closed",
+ "remote tooltip is closed"
+ );
+
+ gBrowser.removeCurrentTab();
+});
diff --git a/layout/xul/test/browser_bug703210.js b/layout/xul/test/browser_bug703210.js
new file mode 100644
index 0000000000..c02b7aba08
--- /dev/null
+++ b/layout/xul/test/browser_bug703210.js
@@ -0,0 +1,56 @@
+add_task(async function() {
+ const url =
+ "data:text/html," +
+ "<html onmousemove='event.stopPropagation()'" +
+ " onmouseenter='event.stopPropagation()' onmouseleave='event.stopPropagation()'" +
+ " onmouseover='event.stopPropagation()' onmouseout='event.stopPropagation()'>" +
+ '<p id="p1" title="tooltip is here">This paragraph has a tooltip.</p>' +
+ '<p id="p2">This paragraph doesn\'t have tooltip.</p></html>';
+
+ let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
+ let browser = gBrowser.selectedBrowser;
+
+ await new Promise(resolve => {
+ SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] }, resolve);
+ });
+
+ let popupShownPromise = BrowserTestUtils.waitForEvent(
+ document,
+ "popupshown",
+ false,
+ event => {
+ is(event.originalTarget.localName, "tooltip", "tooltip is showing");
+ return true;
+ }
+ );
+ let popupHiddenPromise = BrowserTestUtils.waitForEvent(
+ document,
+ "popuphidden",
+ false,
+ event => {
+ is(event.originalTarget.localName, "tooltip", "tooltip is hidden");
+ return true;
+ }
+ );
+
+ // Send a mousemove at a known position to start the test.
+ await BrowserTestUtils.synthesizeMouseAtCenter(
+ "#p2",
+ { type: "mousemove" },
+ browser
+ );
+ await BrowserTestUtils.synthesizeMouseAtCenter(
+ "#p1",
+ { type: "mousemove" },
+ browser
+ );
+ await popupShownPromise;
+ await BrowserTestUtils.synthesizeMouseAtCenter(
+ "#p2",
+ { type: "mousemove" },
+ browser
+ );
+ await popupHiddenPromise;
+
+ gBrowser.removeCurrentTab();
+});
diff --git a/layout/xul/test/browser_bug706743.js b/layout/xul/test/browser_bug706743.js
new file mode 100644
index 0000000000..cb7e487a26
--- /dev/null
+++ b/layout/xul/test/browser_bug706743.js
@@ -0,0 +1,158 @@
+add_task(async function() {
+ const url =
+ "data:text/html,<html><head></head><body>" +
+ '<a id="target" href="about:blank" title="This is tooltip text" ' +
+ 'style="display:block;height:20px;margin:10px;" ' +
+ 'onclick="return false;">here is an anchor element</a></body></html>';
+
+ let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
+ let browser = gBrowser.selectedBrowser;
+
+ await new Promise(resolve => {
+ SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] }, resolve);
+ });
+
+ // Send a mousemove at a known position to start the test.
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ -5,
+ -5,
+ { type: "mousemove" },
+ browser
+ );
+
+ // show tooltip by mousemove into target.
+ let popupShownPromise = BrowserTestUtils.waitForEvent(document, "popupshown");
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ 5,
+ 15,
+ { type: "mousemove" },
+ browser
+ );
+ await popupShownPromise;
+
+ // hide tooltip by mousemove to outside.
+ let popupHiddenPromise = BrowserTestUtils.waitForEvent(
+ document,
+ "popuphidden"
+ );
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ -5,
+ 15,
+ { type: "mousemove" },
+ browser
+ );
+ await popupHiddenPromise;
+
+ // mousemove into the target and start drag by emulation via nsIDragService.
+ // Note that on some platforms, we cannot actually start the drag by
+ // synthesized events. E.g., Windows waits an actual mousemove event after
+ // dragstart.
+
+ // Emulate a buggy mousemove event. widget might dispatch mousemove event
+ // during drag.
+
+ function tooltipNotExpected() {
+ ok(false, "tooltip is shown during drag");
+ }
+ addEventListener("popupshown", tooltipNotExpected, true);
+
+ let dragService = Cc["@mozilla.org/widget/dragservice;1"].getService(
+ Ci.nsIDragService
+ );
+ dragService.startDragSessionForTests(
+ Ci.nsIDragService.DRAGDROP_ACTION_MOVE |
+ Ci.nsIDragService.DRAGDROP_ACTION_COPY |
+ Ci.nsIDragService.DRAGDROP_ACTION_LINK
+ );
+ try {
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ 5,
+ 15,
+ { type: "mousemove" },
+ browser
+ );
+
+ // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
+ await new Promise(resolve => setTimeout(resolve, 100));
+ } finally {
+ removeEventListener("popupshown", tooltipNotExpected, true);
+ dragService.endDragSession(true);
+ }
+
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ -5,
+ -5,
+ { type: "mousemove" },
+ browser
+ );
+
+ // If tooltip listener used a flag for managing D&D state, we would need
+ // to test if the tooltip is shown after drag.
+
+ // show tooltip by mousemove into target.
+ popupShownPromise = BrowserTestUtils.waitForEvent(document, "popupshown");
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ 5,
+ 15,
+ { type: "mousemove" },
+ browser
+ );
+ await popupShownPromise;
+
+ // hide tooltip by mousemove to outside.
+ popupHiddenPromise = BrowserTestUtils.waitForEvent(document, "popuphidden");
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ -5,
+ 15,
+ { type: "mousemove" },
+ browser
+ );
+ await popupHiddenPromise;
+
+ // Show tooltip after mousedown
+ popupShownPromise = BrowserTestUtils.waitForEvent(document, "popupshown");
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ 5,
+ 15,
+ { type: "mousemove" },
+ browser
+ );
+ await popupShownPromise;
+
+ popupHiddenPromise = BrowserTestUtils.waitForEvent(document, "popuphidden");
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ 5,
+ 15,
+ { type: "mousedown" },
+ browser
+ );
+ await popupHiddenPromise;
+
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ 5,
+ 15,
+ { type: "mouseup" },
+ browser
+ );
+ await BrowserTestUtils.synthesizeMouse(
+ "#target",
+ -5,
+ 15,
+ { type: "mousemove" },
+ browser
+ );
+
+ ok(true, "tooltips appear properly");
+
+ gBrowser.removeCurrentTab();
+});
diff --git a/layout/xul/test/chrome.ini b/layout/xul/test/chrome.ini
new file mode 100644
index 0000000000..796a8ebdff
--- /dev/null
+++ b/layout/xul/test/chrome.ini
@@ -0,0 +1,42 @@
+[DEFAULT]
+skip-if = os == 'android'
+support-files =
+ window_resizer.xhtml
+ window_resizer_element.xhtml
+ windowminmaxsize1.xhtml
+ windowminmaxsize2.xhtml
+ windowminmaxsize3.xhtml
+ windowminmaxsize4.xhtml
+ windowminmaxsize5.xhtml
+ windowminmaxsize6.xhtml
+ windowminmaxsize7.xhtml
+ windowminmaxsize8.xhtml
+ windowminmaxsize9.xhtml
+ windowminmaxsize10.xhtml
+ titledpanelwindow.xhtml
+
+[test_bug159346.xhtml]
+[test_bug372685.xhtml]
+[test_bug381167.xhtml]
+[test_bug398982-1.xhtml]
+[test_bug398982-2.xhtml]
+[test_bug467442.xhtml]
+[test_bug477754.xhtml]
+[test_bug703150.xhtml]
+[test_bug987230.xhtml]
+skip-if = os == 'linux' # No native mousedown event on Linux
+[test_bug1197913.xhtml]
+[test_popupReflowPos.xhtml]
+[test_popupSizeTo.xhtml]
+[test_popupZoom.xhtml]
+[test_resizer.xhtml]
+skip-if = (verify && (os == 'win'))
+[test_submenuClose.xhtml]
+[test_windowminmaxsize.xhtml]
+[test_resizer_ctrl_click.xhtml]
+[test_resizer_incontent.xhtml]
+[test_splitter.xhtml]
+skip-if = toolkit == 'android' # no XUL theme
+[test_titlebar_ctrl_click.xhtml]
+[test_toolbarbutton_ctrl_click.xhtml]
+[test_menuitem_ctrl_click.xhtml]
diff --git a/layout/xul/test/file_bug386386.sjs b/layout/xul/test/file_bug386386.sjs
new file mode 100644
index 0000000000..cba983d094
--- /dev/null
+++ b/layout/xul/test/file_bug386386.sjs
@@ -0,0 +1,8 @@
+// SJS file for test_bug386386.html
+"use strict";
+
+function handleRequest(request, response) {
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "application/xhtml+xml;charset=utf-8", false);
+ response.write("%3C%3Fxml%20version%3D%221.0%22%3F%3E%0A%3Cwindow%3E%3C/window%3E");
+}
diff --git a/layout/xul/test/mochitest.ini b/layout/xul/test/mochitest.ini
new file mode 100644
index 0000000000..eebac3a3c1
--- /dev/null
+++ b/layout/xul/test/mochitest.ini
@@ -0,0 +1,10 @@
+[DEFAULT]
+support-files =
+ file_bug386386.sjs
+[test_blockify_moz_box.html]
+[test_bug386386.html]
+[test_bug394800.xhtml]
+[test_bug511075.html]
+skip-if = toolkit == 'android' #bug 798806
+[test_bug563416.html]
+skip-if = toolkit == 'android'
diff --git a/layout/xul/test/test_blockify_moz_box.html b/layout/xul/test/test_blockify_moz_box.html
new file mode 100644
index 0000000000..ec5ee77312
--- /dev/null
+++ b/layout/xul/test/test_blockify_moz_box.html
@@ -0,0 +1,126 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1580012
+-->
+<head>
+ <title>Test for Bug 1580012</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <style>
+ /* Styling for parents that blockify their children: */
+ .grid { display: grid; }
+ .flex { display: flex; }
+
+ /* Styling that blockifies an element itself: */
+ .float { float: left; }
+ .abs { position: absolute; }
+ </style>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1580012">Mozilla Bug 1580012</a>
+<p id="display"></p>
+<div id="content">
+ <!-- Boxes that have no reason to be blockified: -->
+ <div class="moz-box" id="regularMozBox"></div>
+ <div class="moz-inline-box" id="regularMozInlineBox"></div>
+
+ <!-- A grid container with a -moz-box and a -moz-inline-box grid item (which
+ should both end up with display:-moz-box), and a -moz-inline-box
+ grandchild (which should preserve its -moz-inline-box display val): -->
+ <div class="grid">
+ <div class="moz-box" id="gridItemMozBox"></div>
+ <div class="moz-inline-box" id="gridItemMozInlineBox"></div>
+ <div><div class="moz-inline-box" id="gridGrandchildMozInlineBox"></div></div>
+ </div>
+
+ <!-- A flex container with a -moz-box and a -moz-inline-box flex item (which
+ should both end up with display:-moz-box), and a -moz-inline-box
+ grandchild (which should preserve its -moz-inline-box display val): -->
+ <div class="flex">
+ <div class="moz-box" id="flexItemMozBox"></div>
+ <div class="moz-inline-box" id="flexItemMozInlineBox"></div>
+ <div><div class="moz-inline-box" id="flexGrandchildMozInlineBox"></div></div>
+ </div>
+
+ <!-- Boxes that are directly blockified via other styling on them: -->
+ <!-- XXXdholbert commenting these out -- see notes below about assertion
+ failures for floated -moz-box.
+ <div class="float moz-box" id="floatMozBox"></div>
+ <div class="float moz-inline-box" id="floatMozInlineBox"></div>
+ -->
+ <!-- XXXdholbert commenting these out -- see notes below about assertion
+ failures for positioned -moz-box.
+ <div class="abs moz-box" id="absMozBox"></div>
+ <div class="abs moz-inline-box" id="absMozInlineBox"></div>
+ -->
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 1580012 **/
+SimpleTest.waitForExplicitFinish();
+
+function checkDisp(elemId, expectedDisplay) {
+ var elem = document.getElementById(elemId);
+ ok(elem, "should have a valid ID for an element");
+
+ is(getComputedStyle(elem).display, expectedDisplay,
+ "Element with ID " + elemId + " should have expected display value");
+}
+function runTest() {
+ // Create CSS Style rules to add -moz-box / -moz-inline-box styling.
+ // Note that these style won't parse correctly until after we've flipped
+ // the prefs via pushPrefEnv(). That's why I'm creating these style rules
+ // here rather than just putting them inline in the <style> element.
+ var sheet = document.styleSheets[0];
+ sheet.insertRule(".moz-box { display: -moz-box; }");
+ sheet.insertRule(".moz-inline-box { display: -moz-inline-box; }");
+
+ // Check the computed 'display' of the various elements.
+ checkDisp("regularMozBox", "-moz-box");
+ checkDisp("regularMozInlineBox", "-moz-inline-box");
+
+ checkDisp("gridItemMozBox", "-moz-box");
+ checkDisp("gridItemMozInlineBox", "-moz-box");
+ checkDisp("gridGrandchildMozInlineBox", "-moz-inline-box");
+
+ checkDisp("flexItemMozBox", "-moz-box");
+ checkDisp("flexItemMozInlineBox", "-moz-box");
+ checkDisp("flexGrandchildMozInlineBox", "-moz-inline-box");
+
+ // XXXdholbert The floated boxes trigger assertion failures where
+ // nsLineLayout thinks it somehow ended up with an inline-level (really, just
+ // a non-'block') floated thing. In practice this isn't really a concern
+ // since -moz-box display values are disabled in content and since XUL
+ // doesn't use 'float' for layout. So: I've added a fatal assertion in
+ // ReflowInput.cpp to validate that we never actually encounter a floated
+ // -moz-box/-moz-inline-box, and I'm commenting out these lines (which
+ // trigger that fatal assertion).
+ //
+ // checkDisp("floatMozBox", "-moz-box");
+ // checkDisp("floatMozInlineBox", "-moz-box");
+
+
+ // XXXdholbert These abspos boxes trigger a diagnostic assertion added in
+ // bug 1582819 which is intended to flush out XUL content that is positioned
+ // and hence was previously blockified to 'block' but will now be '-moz-box'.
+ // The diagnostic assertion doesn't need to stay around forever, but while
+ // it exists, we can't test this scenario without triggering it.
+ //
+ // checkDisp("absMozBox", "-moz-box");
+ // checkDisp("absMozInlineBox", "-moz-box");
+
+ SimpleTest.finish();
+}
+
+SpecialPowers.pushPrefEnv({
+ "set": [
+ ["layout.css.xul-box-display-values.content.enabled", true],
+ ]
+}, runTest);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/layout/xul/test/test_bug1197913.xhtml b/layout/xul/test/test_bug1197913.xhtml
new file mode 100644
index 0000000000..a511bc1fd0
--- /dev/null
+++ b/layout/xul/test/test_bug1197913.xhtml
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1197913
+-->
+<window title="Mozilla Bug 1197913"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="SimpleTest.waitForFocus(nextTest, window)">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1197913"
+ target="_blank">Mozilla Bug 1197913</a>
+ </body>
+
+ <hbox align="center" pack="center">
+ <menulist>
+ <menupopup>
+ <menuitem label="Car" />
+ <menuitem label="Taxi" id="target" />
+ <menuitem label="Bus" />
+ </menupopup>
+ </menulist>
+ </hbox>
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ let menulist = document.getElementsByTagName("menulist")[0];
+ let menuitem = document.getElementById("target");
+
+ function onDOMMenuItemActive(e) {
+ menuitem.removeEventListener("DOMMenuItemActive", onDOMMenuItemActive);
+
+ synthesizeMouse(menuitem, 0, 0, { type: "mousemove" });
+ synthesizeMouse(menuitem, -1, 0, { type: "mousemove" });
+
+ setTimeout(() => {
+ if (navigator.platform.toLowerCase().startsWith("win")) {
+ ok(menuitem.getAttribute("_moz-menuactive"));
+ } else {
+ ok(!menuitem.getAttribute("_moz-menuactive"));
+ }
+
+ SimpleTest.finish();
+ });
+ }
+
+ function onPopupShown(e) {
+ menulist.removeEventListener("popupshown", onPopupShown);
+ menuitem.addEventListener("DOMMenuItemActive", onDOMMenuItemActive);
+ synthesizeMouse(menuitem, 0, 0, { type: "mousemove" });
+ synthesizeMouse(menuitem, 1, 0, { type: "mousemove" });
+ }
+
+ function nextTest(e) {
+ menulist.addEventListener("popupshown", onPopupShown);
+ synthesizeMouseAtCenter(menulist, {});
+ }
+
+ ]]>
+ </script>
+</window>
diff --git a/layout/xul/test/test_bug159346.xhtml b/layout/xul/test/test_bug159346.xhtml
new file mode 100644
index 0000000000..f46f4ce643
--- /dev/null
+++ b/layout/xul/test/test_bug159346.xhtml
@@ -0,0 +1,137 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ title="Test for Bug 159346">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=159346
+-->
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+
+<scrollbar id="scrollbar" curpos="0" maxpos="500"/>
+
+<script class="testbody" type="application/javascript">
+<![CDATA[
+
+var scrollbar = document.getElementById("scrollbar");
+var downButton;
+
+var domWinUtils = SpecialPowers.DOMWindowUtils;
+domWinUtils.loadSheetUsingURIString('data:text/css,@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); scrollbarbutton[type="increment"][sbattr="scrollbar-down-bottom"] { display: -moz-box; min-width: 3px; min-height: 3px; }', domWinUtils.AGENT_SHEET);
+
+function init()
+{
+ downButton = SpecialPowers.unwrap(
+ SpecialPowers.InspectorUtils.getChildrenForNode(scrollbar, true)[4]);
+ SimpleTest.executeSoon(doTest1);
+}
+
+function getCurrentPos()
+{
+ return Number(scrollbar.getAttribute("curpos"));
+}
+
+function doTest1()
+{
+ var lastPos = 0;
+
+ synthesizeMouseAtCenter(downButton, { type: "mousedown" });
+ ok(getCurrentPos() > lastPos,
+ "scrollbar didn't change curpos by mousedown #1");
+ lastPos = getCurrentPos();
+
+ setTimeout(function () {
+ ok(getCurrentPos() > lastPos,
+ "scrollbar didn't change curpos by auto repeat #1");
+ synthesizeMouseAtCenter(downButton, { type: "mouseup" });
+ lastPos = getCurrentPos();
+
+ setTimeout(function () {
+ is(getCurrentPos(), lastPos,
+ "scrollbar changed curpos after mouseup #1");
+ SimpleTest.executeSoon(doTest2);
+ }, 1000);
+ }, 1000);
+}
+
+function doTest2()
+{
+ SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 0);
+
+ scrollbar.setAttribute("curpos", 0);
+ var lastPos = 0;
+
+ synthesizeMouseAtCenter(downButton, { type: "mousedown" });
+ ok(getCurrentPos() > lastPos,
+ "scrollbar didn't change curpos by mousedown #2");
+ lastPos = getCurrentPos();
+
+ synthesizeMouse(downButton, -10, -10, { type: "mousemove" });
+ lastPos = getCurrentPos();
+
+ setTimeout(function () {
+ is(getCurrentPos(), lastPos,
+ "scrollbar changed curpos by auto repeat when cursor is outside of scrollbar button #2");
+ synthesizeMouseAtCenter(downButton, { type: "mousemove" });
+ lastPos = getCurrentPos();
+
+ setTimeout(function () {
+ ok(getCurrentPos() > lastPos,
+ "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #2");
+ synthesizeMouseAtCenter(downButton, { type: "mouseup" });
+ SimpleTest.executeSoon(doTest3);
+ }, 1000);
+ }, 1000);
+}
+
+function doTest3()
+{
+ SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 1);
+
+ scrollbar.setAttribute("curpos", 0);
+ var lastPos = 0;
+
+ synthesizeMouseAtCenter(downButton, { type: "mousedown" });
+ ok(getCurrentPos() > lastPos,
+ "scrollbar didn't change curpos by mousedown #3");
+ synthesizeMouse(downButton, -10, -10, { type: "mousemove" });
+ lastPos = getCurrentPos();
+
+ setTimeout(function () {
+ ok(getCurrentPos() > lastPos,
+ "scrollbar didn't change curpos by auto repeat when cursor is outside of scrollbar button #3");
+ synthesizeMouseAtCenter(downButton, { type: "mousemove" });
+ lastPos = getCurrentPos();
+
+ setTimeout(function () {
+ ok(getCurrentPos() > lastPos,
+ "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #3");
+ synthesizeMouseAtCenter(downButton, { type: "mouseup" });
+
+ SpecialPowers.clearUserPref("ui.scrollbarButtonAutoRepeatBehavior");
+ SimpleTest.finish();
+ }, 1000);
+ }, 1000);
+}
+
+SimpleTest.waitForExplicitFinish();
+
+]]>
+</script>
+
+<body id="html_body" xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=159346">Mozilla Bug 159346</a>
+<p id="display"></p>
+
+<pre id="test">
+</pre>
+<script>
+addLoadEvent(init);
+</script>
+</body>
+
+
+</window>
diff --git a/layout/xul/test/test_bug372685.xhtml b/layout/xul/test/test_bug372685.xhtml
new file mode 100644
index 0000000000..ea48474cd6
--- /dev/null
+++ b/layout/xul/test/test_bug372685.xhtml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ title="Test for Bug 372685">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=372685
+-->
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<menuitem id="a" style="display: -moz-stack;">
+<box id="b" style="display: -moz-popup; ">
+<box id="c" style="position: fixed;"></box>
+</box>
+</menuitem>
+
+<script class="testbody" type="application/javascript">
+<![CDATA[
+
+function removestyles(i){
+ document.getElementById('a').removeAttribute('style');
+ var x=document.getElementById('html_body').offsetHeight;
+ is(0, 0, "this is a crash test, so always ok if we survive this far");
+ SimpleTest.finish();
+}
+function do_test() {
+ setTimeout(removestyles,200);
+}
+
+SimpleTest.waitForExplicitFinish();
+
+]]>
+</script>
+
+<body id="html_body" xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=372685">Mozilla Bug 372685</a>
+<p id="display"></p>
+
+<pre id="test">
+</pre>
+<script>
+addLoadEvent(do_test);
+</script>
+</body>
+
+
+</window>
diff --git a/layout/xul/test/test_bug381167.xhtml b/layout/xul/test/test_bug381167.xhtml
new file mode 100644
index 0000000000..1bf55f6fdb
--- /dev/null
+++ b/layout/xul/test/test_bug381167.xhtml
@@ -0,0 +1,49 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=381167
+-->
+<head>
+ <title>Test for Bug 381167</title>
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=381167">Mozilla Bug 381167</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<xul:tree>
+ <xul:tree>
+ <xul:treechildren/>
+ <xul:treecol/>
+ </xul:tree>
+</xul:tree>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 381167 **/
+
+SimpleTest.waitForExplicitFinish();
+
+function closeit() {
+ var evt = document.createEvent('KeyboardEvent');
+ evt.initKeyEvent('keypress', true, true,
+ window,
+ true, false, false, false,
+ 'W'.charCodeAt(0), 0);
+ window.dispatchEvent(evt);
+
+ setTimeout(finish, 200);
+}
+window.addEventListener('load', closeit);
+
+function finish()
+{
+ ok(true, "This is a mochikit version of a crash test. To complete is to pass.");
+ SimpleTest.finish();
+}
+</script>
+</pre>
+</body>
+</html>
diff --git a/layout/xul/test/test_bug386386.html b/layout/xul/test/test_bug386386.html
new file mode 100644
index 0000000000..d3187c9142
--- /dev/null
+++ b/layout/xul/test/test_bug386386.html
@@ -0,0 +1,34 @@
+<html>
+<head><title>Testcase for bug 386386</title>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=386386
+-->
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+</head>
+<body>
+
+<iframe id="test386386" src="file_bug386386.sjs"></iframe>
+
+<script class="testbody" type="application/javascript">
+
+function boom()
+{
+ var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+ var doc = document.getElementById("test386386").contentDocument;
+ var observes = doc.createElementNS(XUL_NS, 'observes');
+ doc.removeChild(doc.documentElement);
+ doc.appendChild(observes);
+ is(0, 0, "Test is successful if we get here without crashing");
+ SimpleTest.finish();
+}
+
+function do_test() {
+ setTimeout(boom, 200);
+}
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+addLoadEvent(do_test);
+</script>
+
+</body>
+</html>
diff --git a/layout/xul/test/test_bug394800.xhtml b/layout/xul/test/test_bug394800.xhtml
new file mode 100644
index 0000000000..26fc50f771
--- /dev/null
+++ b/layout/xul/test/test_bug394800.xhtml
@@ -0,0 +1,39 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<head>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=394800
+-->
+ <title>Test Mozilla bug 394800</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+
+<script class="testbody" type="application/javascript">
+
+function do_test()
+{
+ var x = document.getElementById("x");
+ x.parentNode.removeChild(x);
+ is(0, 0, "this is a crash/assertion test, so we're ok if we survived this far");
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+</script>
+</head>
+
+<body>
+
+<xul:menulist><xul:tooltip/><div><span><xul:hbox id="x"/></span></div></xul:menulist>
+
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=394800">Mozilla Bug 394800</a>
+<p id="display"></p>
+
+<pre id="test">
+</pre>
+
+<script>
+ addLoadEvent(do_test);
+</script>
+
+</body>
+</html>
diff --git a/layout/xul/test/test_bug398982-1.xhtml b/layout/xul/test/test_bug398982-1.xhtml
new file mode 100644
index 0000000000..da6598b70d
--- /dev/null
+++ b/layout/xul/test/test_bug398982-1.xhtml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<menuitem xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ style="position: absolute; display: block;">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=398982
+-->
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<tooltip type="zzz">
+<treecols/>
+</tooltip>
+
+<script xmlns="http://www.w3.org/1999/xhtml" class="testbody" type="application/javascript">
+<![CDATA[
+function doe() {
+ document.getElementsByTagName('menuitem')[0].removeAttribute('style');
+ is(0, 0, "Test is successful if we get here without crashing");
+ SimpleTest.finish();
+}
+function do_test() {
+ setTimeout(doe, 200);
+}
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(do_test);
+]]>
+</script>
+<html:body></html:body> <!-- XXX SimpleTest.showReport() requires a html:body -->
+</menuitem>
diff --git a/layout/xul/test/test_bug398982-2.xhtml b/layout/xul/test/test_bug398982-2.xhtml
new file mode 100644
index 0000000000..865e688ea3
--- /dev/null
+++ b/layout/xul/test/test_bug398982-2.xhtml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ title="Test for Bug 398982">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=398982
+-->
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<popupgroup style="position: absolute; display: block;">
+<tooltip type="zzz">
+<treecols/>
+</tooltip>
+
+<script xmlns="http://www.w3.org/1999/xhtml" class="testbody" type="application/javascript">
+<![CDATA[
+function doe() {
+ document.getElementsByTagName('popupgroup')[0].removeAttribute('style');
+ is(0, 0, "Test is successful if we get here without crashing");
+ SimpleTest.finish();
+}
+function do_test() {
+ setTimeout(doe, 200);
+}
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(do_test);
+]]>
+</script>
+</popupgroup>
+<html:body></html:body> <!-- XXX SimpleTest.showReport() requires a html:body -->
+</window>
diff --git a/layout/xul/test/test_bug467442.xhtml b/layout/xul/test/test_bug467442.xhtml
new file mode 100644
index 0000000000..e966bb3fe4
--- /dev/null
+++ b/layout/xul/test/test_bug467442.xhtml
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=467442
+-->
+<window title="Mozilla Bug 467442"
+ onload="onload()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test code goes here -->
+ <popupset>
+ <panel id="panel">
+ Hello.
+ </panel>
+ </popupset>
+ <hbox>
+ <button id="anchor" label="Anchor hello on here" style="transform: translate(100px, 0)"/>
+ </hbox>
+ <script type="application/javascript">
+ <![CDATA[
+
+ SimpleTest.waitForExplicitFinish();
+
+ function onload() {
+ /** Test for Bug 467442 **/
+ let panel = document.getElementById("panel");
+ let anchor = document.getElementById("anchor");
+
+ panel.addEventListener("popupshown", function onpopupshown() {
+ let panelRect = panel.getBoundingClientRect();
+ let anchorRect = anchor.getBoundingClientRect();
+ is(panelRect.left, anchorRect.left, "Panel should be anchored to the button");
+ panel.addEventListener("popuphidden", function onpopuphidden() {
+ SimpleTest.finish();
+ }, { once: true });
+ panel.hidePopup();
+ }, { once: true });
+
+ panel.openPopup(anchor, "after_start", 0, 0, false, false);
+ }
+
+ ]]>
+ </script>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=467442"
+ target="_blank">Mozilla Bug 467442</a>
+ </body>
+</window>
diff --git a/layout/xul/test/test_bug477754.xhtml b/layout/xul/test/test_bug477754.xhtml
new file mode 100644
index 0000000000..b53c55723d
--- /dev/null
+++ b/layout/xul/test/test_bug477754.xhtml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=477754
+-->
+<window title="Mozilla Bug 477754"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=477754"
+ target="_blank">Mozilla Bug 477754</a>
+ </body>
+
+ <hbox pack="center">
+ <label id="anchor" style="direction: rtl;" value="Anchor"/>
+ </hbox>
+ <panel id="testPopup" onpopupshown="doTest();">
+ <label value="I am a popup"/>
+ </panel>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+ /** Test for Bug 477754 **/
+ SimpleTest.waitForExplicitFinish();
+
+ let testPopup, testAnchor;
+
+ addEventListener("load", function () {
+ removeEventListener("load", arguments.callee, false);
+
+ testPopup = document.getElementById("testPopup");
+ testAnchor = document.getElementById("anchor");
+
+ testPopup.openPopup(testAnchor, "after_start", 10, 0, false, false);
+ }, false);
+
+ function doTest() {
+ is(Math.round(testAnchor.getBoundingClientRect().right -
+ testPopup.getBoundingClientRect().right), 10,
+ "RTL popup's right offset should be equal to the x offset passed to openPopup");
+ testPopup.hidePopup();
+ SimpleTest.finish();
+ }
+
+ ]]></script>
+</window>
diff --git a/layout/xul/test/test_bug511075.html b/layout/xul/test/test_bug511075.html
new file mode 100644
index 0000000000..34e784ba56
--- /dev/null
+++ b/layout/xul/test/test_bug511075.html
@@ -0,0 +1,121 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=511075
+-->
+<head>
+ <title>Test for Bug 511075</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <style>
+ #scroller {
+ border: 1px solid black;
+ }
+ </style>
+</head>
+<body onload="runTests()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511075">Mozilla Bug 511075</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 511075 **/
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+
+var tests = [
+ function() {
+ ok(true, "Setting location.hash should scroll.");
+ nextTest();
+ // Click the top scroll arrow.
+ var x = scroller.getBoundingClientRect().width - 5;
+ var y = 5;
+ // On MacOSX the top scroll arrow can be below the slider just above
+ // the bottom scroll arrow.
+ if (navigator.platform.includes("Mac"))
+ y = scroller.getBoundingClientRect().height - 40;
+ synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
+ synthesizeMouse(scroller, x, y, { type: "mouseup" }, window);
+ },
+ function() {
+ ok(true, "Clicking the top scroll arrow should scroll.");
+ nextTest();
+ // Click the bottom scroll arrow.
+ var x = scroller.getBoundingClientRect().width - 5;
+ var y = scroller.getBoundingClientRect().height - 25;
+ synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
+ synthesizeMouse(scroller, x, y, { type: "mouseup" }, window);
+ },
+ function() {
+ ok(true, "Clicking the bottom scroll arrow should scroll.");
+ nextTest();
+ // Click the scrollbar.
+ var x = scroller.getBoundingClientRect().width - 5;
+ synthesizeMouse(scroller, x, 40, { type : "mousedown" }, window);
+ synthesizeMouse(scroller, x, 40, { type: "mouseup" }, window);
+ },
+ function() {
+ ok(true, "Clicking the scrollbar should scroll");
+ nextTest();
+ // Click the scrollbar.
+ var x = scroller.getBoundingClientRect().width - 5;
+ var y = scroller.getBoundingClientRect().height - 50;
+ synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
+ synthesizeMouse(scroller, x, y, { type: "mouseup" }, window);
+ },
+ function() {
+ scroller.onscroll = null;
+ ok(true, "Clicking the scrollbar should scroll");
+ finish();
+ }
+];
+
+document.onmousedown = function () { return false; };
+document.onmouseup = function () { return true; };
+
+
+var scroller;
+var timer = 0;
+
+function failure() {
+ ok(false, scroller.onscroll + " did not run!");
+ scroller.onscroll = null;
+ finish();
+}
+
+function nextTest() {
+ clearTimeout(timer);
+ scroller.onscroll = tests.shift();
+ timer = setTimeout(failure, 2000);
+}
+
+function runTests() {
+ scroller = document.getElementById("scroller");
+ nextTest();
+ window.location.hash = "initialPosition";
+}
+
+function finish() {
+ document.onmousedown = null;
+ document.onmouseup = null;
+ clearTimeout(timer);
+ window.location.hash = "topPosition";
+ SimpleTest.finish();
+}
+
+
+</script>
+</pre>
+<div id="scroller" style="overflow: scroll; width: 100px; height: 150px;">
+<a id="topPosition" name="topPosition">top</a>
+<div style="width: 20000px; height: 20000px;"></div>
+<a id="initialPosition" name="initialPosition">initialPosition</a>
+<div style="width: 20000px; height: 20000px;"></div>
+</div>
+</body>
+</html>
diff --git a/layout/xul/test/test_bug563416.html b/layout/xul/test/test_bug563416.html
new file mode 100644
index 0000000000..22abb5bdc3
--- /dev/null
+++ b/layout/xul/test/test_bug563416.html
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=563416
+-->
+<head>
+ <title>Test for Bug 563416</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=563416">Mozilla Bug 563416</a>
+<p id="display"><iframe id="test" srcdoc='<textarea style="box-sizing:content-box; overflow: hidden; -moz-appearance:none; height: 0px; padding: 0px;" cols="20" rows="10">hsldkjvmshlkkajskdlfksdjflskdjflskdjflskdjflskdjfddddddddd</textarea>'></iframe></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 563416 **/
+
+var result = -1;
+var expected = -2;
+var i = 0;
+
+function runTest() {
+ i = 0;
+ var frame = document.getElementById('test');
+ frame.onload = function() {
+ var t = frame.contentDocument.documentElement.getElementsByTagName("textarea")[0];
+ expected = t.clientWidth + 10;
+ t.style.width = expected + 'px';
+ result = t.clientWidth;
+ if (i == 0) {
+ i++;
+ setTimeout(function(){frame.contentWindow.location.reload();},0);
+ }
+ else {
+ is(result, expected, "setting style.width changes clientWidth");
+ SimpleTest.finish();
+ }
+ }
+ frame.contentWindow.location.reload();
+}
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(runTest);
+
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/layout/xul/test/test_bug703150.xhtml b/layout/xul/test/test_bug703150.xhtml
new file mode 100644
index 0000000000..f42460fa02
--- /dev/null
+++ b/layout/xul/test/test_bug703150.xhtml
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ title="Test for Bug 703150">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=703150
+-->
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+
+<scrollbar id="scrollbar" curpos="0" maxpos="500"/>
+
+<script class="testbody" type="application/javascript">
+<![CDATA[
+
+var scrollbar = document.getElementById("scrollbar");
+var scrollbarThumb;
+
+function doTest()
+{
+ scrollbarThumb = SpecialPowers.unwrap(
+ SpecialPowers.InspectorUtils.getChildrenForNode(scrollbar, true)[2]).childNodes[0];
+
+ function mousedownHandler(aEvent)
+ {
+ aEvent.stopPropagation();
+ }
+ window.addEventListener("mousedown", mousedownHandler, true);
+
+ // Wait for finishing reflow...
+ SimpleTest.executeSoon(function () {
+ synthesizeMouseAtCenter(scrollbarThumb, { type: "mousedown" });
+
+ is(scrollbar.getAttribute("curpos"), "0",
+ "scrollbar thumb has been moved already");
+
+ synthesizeMouseAtCenter(scrollbar, { type: "mousemove" });
+
+ ok(scrollbar.getAttribute("curpos") > 0,
+ "scrollbar thumb hasn't been dragged");
+
+ synthesizeMouseAtCenter(scrollbarThumb, { type: "mouseup" });
+
+ window.removeEventListener("mousedown", mousedownHandler, true);
+
+ SimpleTest.finish();
+ });
+}
+
+SimpleTest.waitForExplicitFinish();
+
+]]>
+</script>
+
+<body id="html_body" xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=703150">Mozilla Bug 703150</a>
+<p id="display"></p>
+
+<pre id="test">
+</pre>
+<script>
+addLoadEvent(doTest);
+</script>
+</body>
+
+
+</window>
diff --git a/layout/xul/test/test_bug987230.xhtml b/layout/xul/test/test_bug987230.xhtml
new file mode 100644
index 0000000000..425b4a1cd4
--- /dev/null
+++ b/layout/xul/test/test_bug987230.xhtml
@@ -0,0 +1,108 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=987230
+-->
+<window title="Mozilla Bug 987230"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="SimpleTest.waitForFocus(startTest, window)">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=987230"
+ target="_blank">Mozilla Bug 987230</a>
+ </body>
+
+ <vbox>
+ <toolbar>
+ <toolbarbutton id="toolbarbutton-anchor"
+ label="Anchor"
+ consumeanchor="toolbarbutton-anchor"
+ onclick="onAnchorClick(event)"
+ style="padding: 50px !important; list-style-image: url(chrome://branding/content/icon32.png)"/>
+ </toolbar>
+ <spacer flex="1"/>
+ <hbox id="hbox-anchor"
+ style="padding: 20px"
+ onclick="onAnchorClick(event)">
+ <hbox id="inner-anchor"
+ consumeanchor="hbox-anchor"
+ >
+ Another anchor
+ </hbox>
+ </hbox>
+ <spacer flex="1"/>
+ </vbox>
+
+ <panel id="mypopup"
+ type="arrow"
+ onpopupshown="onMyPopupShown(event)"
+ onpopuphidden="onMyPopupHidden(event)">This is a test popup</panel>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+ /** Test for Bug 987230 **/
+ SimpleTest.waitForExplicitFinish();
+
+ SimpleTest.requestCompleteLog();
+
+ let platform = navigator.platform.toLowerCase();
+ let isWindows = platform.startsWith("win");
+ let mouseMove = isWindows ? 1 : 5;
+
+ function onMyPopupHidden(e) {
+ ok(true, "Popup hidden");
+ if (outerAnchor.id == "toolbarbutton-anchor") {
+ popupHasShown = false;
+ outerAnchor = document.getElementById("hbox-anchor");
+ anchor = document.getElementById("inner-anchor");
+ nextTest();
+ } else {
+ //XXXgijs set mouse position back outside the iframe:
+ let frameRect = window.frameElement.getBoundingClientRect();
+ let utils = window.windowUtils;
+ let scale = utils.screenPixelsPerCSSPixel;
+ let outsideOfFrameX = (window.mozInnerScreenX + frameRect.width + 100) * scale;
+ let outsideOfFrameY = Math.max(0, window.mozInnerScreenY - 100) * scale;
+
+ info("Mousemove: " + outsideOfFrameX + ", " + outsideOfFrameY +
+ " (from innerscreen " + window.mozInnerScreenX + ", " + window.mozInnerScreenY +
+ " and rect width " + frameRect.width + " and scale " + scale + ")");
+ utils.sendNativeMouseEvent(outsideOfFrameX, outsideOfFrameY, mouseMove, 0, null);
+ SimpleTest.finish();
+ }
+ }
+
+ let popupHasShown = false;
+ function onMyPopupShown(e) {
+ popupHasShown = true;
+ synthesizeNativeMouseClick(outerAnchor, 5, 5);
+ }
+
+ function onAnchorClick(e) {
+ info("click: " + e.target.id);
+ ok(!popupHasShown, "Popup should only be shown once");
+ popup.openPopup(anchor, "bottomcenter topright");
+ }
+
+ let popup, outerAnchor, anchor;
+
+ function startTest() {
+ popup = document.getElementById("mypopup");
+ outerAnchor = document.getElementById("toolbarbutton-anchor");
+ anchor = outerAnchor.icon;
+ nextTest();
+ }
+
+ function nextTest(e) {
+ synthesizeMouse(outerAnchor, 5, 5, {});
+ }
+
+ ]]>
+ </script>
+</window>
diff --git a/layout/xul/test/test_menuitem_ctrl_click.xhtml b/layout/xul/test/test_menuitem_ctrl_click.xhtml
new file mode 100644
index 0000000000..04ff0b11d1
--- /dev/null
+++ b/layout/xul/test/test_menuitem_ctrl_click.xhtml
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1630828
+-->
+<window title="Mozilla Bug 1630828"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="">
+<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+<!-- test results are displayed in the html:body -->
+<body xmlns="http://www.w3.org/1999/xhtml">
+<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1630828"
+ target="_blank">Mozilla Bug 1630828</a>
+</body>
+
+<hbox align="center" pack="center">
+ <menulist id="menu">
+ <menupopup id="popup">
+ <menuitem label="Target" id="target" />
+ </menupopup>
+ </menulist>
+</hbox>
+<!-- test code goes here -->
+<script type="application/javascript">
+<![CDATA[
+
+const { AppConstants } = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm");
+
+function waitForEvent(target, event) {
+ info(`Waiting for ${event} event.`);
+ return new Promise(resolve => {
+ target.addEventListener(event, resolve, { once: true });
+ });
+}
+
+function waitForIdle() {
+ return new Promise(resolve => {
+ SpecialPowers.Services.tm.idleDispatchToMainThread(resolve);
+ });
+}
+
+add_task(async function init() {
+ await SimpleTest.promiseFocus();
+});
+
+add_task(async function test_ctrl_click() {
+ const isMac = AppConstants.platform === "macosx";
+
+ let popup = document.getElementById("popup");
+ let promise = waitForEvent(popup, "popupshown");
+ let menu = document.getElementById("menu");
+ synthesizeMouseAtCenter(menu, {});
+ // Wait for popup open.
+ await promise;
+
+ let commandReceived = false;
+ menu.addEventListener("command", function(e) {
+ ok(!isMac, `${AppConstants.platform} receives command event`);
+ commandReceived = true;
+ });
+
+ // Ctrl click in Mac won't dispatch command event and close popup, so we wait
+ // for idle instead.
+ promise = isMac ? waitForIdle() : waitForEvent(popup, "popuphidden");
+ let target = document.getElementById("target");
+ synthesizeMouseAtCenter(target, { ctrlKey: true });
+ await promise;
+
+ is(commandReceived, !isMac, `Check command event for ${AppConstants.platform}`);
+ is(popup.state, isMac ? "open" : "closed", `Check popup state for ${AppConstants.platform}`);
+});
+
+]]>
+</script>
+</window>
diff --git a/layout/xul/test/test_popupReflowPos.xhtml b/layout/xul/test/test_popupReflowPos.xhtml
new file mode 100644
index 0000000000..9b53951834
--- /dev/null
+++ b/layout/xul/test/test_popupReflowPos.xhtml
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<window title="XUL Panel reflow placement test"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ function openPopup()
+ {
+ synthesizeMouseAtCenter(document.getElementById("thebutton"), {}, window);
+ }
+
+ function popupShown(event)
+ {
+ document.getElementById("parent").className = "";
+
+ var buttonbcr = document.getElementById("thebutton").getBoundingClientRect();
+ var popupbcr = document.getElementById("thepopup").getOuterScreenRect();
+
+ ok(Math.abs(popupbcr.x - window.mozInnerScreenX - buttonbcr.x) < 3, "x pos is correct");
+ ok(Math.abs(popupbcr.y - window.mozInnerScreenY - buttonbcr.bottom) < 3, "y pos is correct");
+
+ event.target.hidePopup();
+ }
+
+ SimpleTest.waitForFocus(openPopup);
+ ]]></script>
+
+ <html:style>
+ .mbox {
+ display: inline-block;
+ width: 33%;
+ height: 50px;
+ background: green;
+ vertical-align: middle;
+ }
+ .orange {
+ background: orange;
+ }
+ .change > .mbox {
+ width: 60px;
+ }
+ </html:style>
+
+ <html:div style="width: 300px; height: 200px;">
+ <html:div id="parent" class="change" style="background: red; border: 1px solid black; width: 300px; height: 200px;">
+ <html:div class="mbox"></html:div>
+ <html:div class="mbox"></html:div>
+ <html:div class="mbox"></html:div>
+ <html:div class="mbox orange">
+
+ <button label="Show" type="menu" id="thebutton">
+ <menupopup id="thepopup" onpopupshown="popupShown(event)" onpopuphidden="SimpleTest.finish()">
+ <menuitem label="New"/>
+ <menuitem label="Open"/>
+ <menuitem label="Save"/>
+ <menuseparator/>
+ <menuitem label="Exit"/>
+ </menupopup>
+ </button>
+
+ </html:div>
+ </html:div>
+ </html:div>
+
+</window>
diff --git a/layout/xul/test/test_popupSizeTo.xhtml b/layout/xul/test/test_popupSizeTo.xhtml
new file mode 100644
index 0000000000..6e60f28e0a
--- /dev/null
+++ b/layout/xul/test/test_popupSizeTo.xhtml
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+XUL Panel sizeTo tests
+-->
+<window title="XUL Panel sizeTo tests"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ function openPopup()
+ {
+ document.getElementById("panel").
+ openPopupAtScreen(Math.round(window.mozInnerScreenX) + window.innerWidth - 130,
+ Math.round(window.mozInnerScreenY) + window.innerHeight - 130);
+ }
+
+ function sizeAndCheck(width, height) {
+ var panel = document.getElementById("panel");
+ panel.sizeTo(width, height);
+ is(panel.getBoundingClientRect().width, width, "width is correct");
+ is(panel.getBoundingClientRect().height, height, "height is correct");
+
+ }
+ function popupShown(event)
+ {
+ var panel = document.getElementById("panel");
+ var bcr = panel.getBoundingClientRect();
+ // resize to 10px bigger in both dimensions.
+ sizeAndCheck(bcr.width+10, bcr.height+10);
+ // Same width, different height (based on *new* size from last sizeAndCheck)
+ sizeAndCheck(bcr.width+10, bcr.height);
+ // Same height, different width (also based on *new* size from last sizeAndCheck)
+ sizeAndCheck(bcr.width, bcr.height);
+ event.target.hidePopup();
+ }
+
+ SimpleTest.waitForFocus(openPopup);
+ ]]></script>
+
+<panel id="panel" onpopupshown="popupShown(event)" onpopuphidden="SimpleTest.finish()">
+ <resizer id="resizer" dir="bottomend" width="16" height="16"/>
+ <hbox width="50" height="50" flex="1"/>
+</panel>
+
+</window>
diff --git a/layout/xul/test/test_popupZoom.xhtml b/layout/xul/test/test_popupZoom.xhtml
new file mode 100644
index 0000000000..b19b304a7b
--- /dev/null
+++ b/layout/xul/test/test_popupZoom.xhtml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<window title="XUL Panel zoom test"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ var savedzoom;
+
+ function openPopup()
+ {
+ docviewer = window.docShell.contentViewer;
+ savedzoom = SpecialPowers.getFullZoom(window);
+ SpecialPowers.setFullZoom(window, 2);
+
+ document.getElementById("panel").
+ openPopup(document.getElementById("anchor"), "after_start", 0, 0, false, false, null);
+ }
+
+ function popupShown(event)
+ {
+ var panel = document.getElementById("panel");
+ var panelbcr = panel.getBoundingClientRect();
+ var anchorbcr = document.getElementById("anchor").getBoundingClientRect();
+
+ ok(Math.abs(panelbcr.x - anchorbcr.x) < 3, "x pos is correct");
+ ok(Math.abs(panelbcr.y - anchorbcr.bottom) < 3, "y pos is correct");
+
+ SpecialPowers.setFullZoom(window, savedzoom);
+
+ event.target.hidePopup();
+ }
+
+ SimpleTest.waitForFocus(openPopup);
+ ]]></script>
+
+<description id="anchor" value="Sometext to this some texts"/>
+<panel id="panel" onpopupshown="popupShown(event)" onpopuphidden="SimpleTest.finish()">
+ <resizer id="resizer" dir="bottomend" width="16" height="16"/>
+ <hbox width="50" height="50" flex="1"/>
+</panel>
+
+
+</window>
diff --git a/layout/xul/test/test_resizer.xhtml b/layout/xul/test/test_resizer.xhtml
new file mode 100644
index 0000000000..5e027e5803
--- /dev/null
+++ b/layout/xul/test/test_resizer.xhtml
@@ -0,0 +1,94 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+XUL <resizer> tests
+-->
+<window title="XUL resizer tests"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+ SimpleTest.waitForExplicitFinish();
+ SimpleTest.ignoreAllUncaughtExceptions();
+
+ function openPopup()
+ {
+ document.getElementById("panel").
+ openPopupAtScreen(Math.round(window.mozInnerScreenX) + window.innerWidth - 130,
+ Math.round(window.mozInnerScreenY) + window.innerHeight - 130);
+ }
+
+ var step = 0;
+ function popupShown(event)
+ {
+ if (step == 0) {
+ // check to make sure that the popup cannot be resized past the edges of
+ // the content area
+ var resizerrect = document.getElementById("resizer").getBoundingClientRect();
+ synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mousedown" });
+ synthesizeMouse(document.documentElement, resizerrect.left + 2000, resizerrect.top + 2000, { type:"mousemove" });
+
+ // allow a one pixel variance as rounding is always done to the inside
+ // of a rectangle.
+ var popuprect = document.getElementById("panel").getBoundingClientRect();
+ ok(Math.round(popuprect.right) == window.innerWidth ||
+ Math.round(popuprect.right) == window.innerWidth - 1,
+ "resized to content edge width");
+ ok(Math.round(popuprect.bottom) == window.innerHeight ||
+ Math.round(popuprect.bottom) == window.innerHeight - 1,
+ "resized to content edge height");
+
+ resizerrect = document.getElementById("resizer").getBoundingClientRect();
+ synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mouseup" });
+ }
+ else {
+ // the popup is opened twice. Make sure that for the second time, the
+ // resized popup opens in the same direction as there should still be
+ // room for it
+ var popuprect = document.getElementById("panel").getBoundingClientRect();
+ is(Math.round(popuprect.left), window.innerWidth - 130, "reopen popup left");
+ is(Math.round(popuprect.top), window.innerHeight - 130, "reopen popup top");
+ }
+
+ event.target.hidePopup();
+ }
+
+ function doResizerWindowTests() {
+ step++;
+ if (step == 1) {
+ openPopup();
+ return;
+ }
+
+ if (/Mac/.test(navigator.platform)) {
+ window.openDialog("window_resizer.xhtml", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome,noopener", window);
+ }
+ else {
+ // Skip window_resizer.xhtml tests.
+ todo(false, "We can't test GTK and Windows native drag resizing implementations.");
+ // Run window_resizer_element.xhtml test only.
+ lastResizerTest();
+ }
+ }
+
+ function lastResizerTest()
+ {
+ window.openDialog("window_resizer_element.xhtml", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome,noopener", window);
+ }
+
+ SimpleTest.waitForFocus(openPopup);
+ ]]></script>
+
+<panel id="panel" onpopupshown="popupShown(event)" onpopuphidden="doResizerWindowTests()">
+ <resizer id="resizer" dir="bottomend" width="16" height="16"/>
+ <hbox width="50" height="50" flex="1"/>
+</panel>
+
+</window>
diff --git a/layout/xul/test/test_resizer_ctrl_click.xhtml b/layout/xul/test/test_resizer_ctrl_click.xhtml
new file mode 100644
index 0000000000..6321c46e7f
--- /dev/null
+++ b/layout/xul/test/test_resizer_ctrl_click.xhtml
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+ XUL Widget Test for the resizer element
+ -->
+<window title="Titlebar" width="200" height="200"
+ onload="setTimeout(test_resizer_ctrl_click, 0);"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+<resizer id="resizer" dir="bottomend" width="16" height="16"/>
+
+<!-- test code goes here -->
+<script type="application/javascript"><![CDATA[
+
+const { AppConstants } = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
+
+SimpleTest.waitForExplicitFinish();
+
+function test_resizer_ctrl_click()
+{
+ let resizer = document.getElementById("resizer");
+ let isCommandFired = false;
+
+ resizer.addEventListener("click", function(aEvent) {
+ // Delay check for command event, because it is fired after click event.
+ setTimeout(() => {
+ is(isCommandFired, AppConstants.platform != "macosx",
+ "Check if command event is fired");
+ SimpleTest.finish();
+ }, 0);
+ });
+ resizer.addEventListener("command", function(aEvent) {
+ isCommandFired = true;
+ ok(aEvent.ctrlKey, "Check ctrlKey for command event");
+ ok(!aEvent.shiftKey, "Check shiftKey for command event");
+ ok(!aEvent.altKey, "Check altKey for command event");
+ ok(!aEvent.metaKey, "Check metaKey for command event");
+ is(aEvent.inputSource, MouseEvent.MOZ_SOURCE_MOUSE,
+ "Check inputSource for command event");
+ });
+ synthesizeMouseAtCenter(resizer, { ctrlKey: true });
+}
+
+]]>
+</script>
+
+</window>
diff --git a/layout/xul/test/test_resizer_incontent.xhtml b/layout/xul/test/test_resizer_incontent.xhtml
new file mode 100644
index 0000000000..2d29dd3f8d
--- /dev/null
+++ b/layout/xul/test/test_resizer_incontent.xhtml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+This test ensures that a resizer in content doesn't resize the window.
+-->
+<window title="XUL resizer in content test"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ function testResizer()
+ {
+ var oldScreenX = window.screenX;
+ var oldScreenY = window.screenY;
+ var oldWidth = window.outerWidth;
+ var oldHeight = window.outerHeight;
+ var resizer = document.getElementById("resizer");
+ synthesizeMouseAtCenter(resizer, { type:"mousedown" });
+ synthesizeMouse(resizer, 32, 32, { type:"mousemove" });
+ synthesizeMouse(resizer, 32, 32, { type:"mouseup" });
+ is(window.screenX, oldScreenX, "window not moved for non-chrome window screenX");
+ is(window.screenY, oldScreenY, "window not moved for non-chrome window screenY");
+ is(window.outerWidth, oldWidth, "window not moved for non-chrome window outerWidth");
+ is(window.outerHeight, oldHeight, "window not moved for non-chrome window outerHeight");
+ SimpleTest.finish();
+ }
+
+ SimpleTest.waitForFocus(testResizer);
+ ]]></script>
+
+ <resizer id="resizer" dir="bottomend" width="16" height="16"/>
+
+</window>
diff --git a/layout/xul/test/test_splitter.xhtml b/layout/xul/test/test_splitter.xhtml
new file mode 100644
index 0000000000..c31bd6b84e
--- /dev/null
+++ b/layout/xul/test/test_splitter.xhtml
@@ -0,0 +1,101 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<?xml-stylesheet href="data:text/css, hbox { border: 1px solid red; } vbox { border: 1px solid green }" type="text/css"?>
+<!--
+XUL <splitter> collapsing tests
+-->
+<window title="XUL splitter collapsing tests"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ orient="horizontal">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ async function dragSplitter(offsetX) {
+ var splitterRect = splitter.getBoundingClientRect();
+ var splitterWidth = splitterRect.width;
+ synthesizeMouse(splitter, splitterWidth / 2, 2, {type: "mousedown"});
+ synthesizeMouse(splitter, splitterWidth / 2, 1, {type: "mousemove"});
+ await new Promise(SimpleTest.executeSoon);
+ SimpleTest.is(splitter.getAttribute("state"), "dragging", "The splitter should be dragged");
+ synthesizeMouse(splitter, offsetX, 1, {type: "mousemove"});
+ synthesizeMouse(splitter, offsetX, 1, {type: "mouseup"});
+ await new Promise(SimpleTest.executeSoon);
+ var newSplitterRect = splitter.getBoundingClientRect();
+ is(
+ offsetX > 0,
+ newSplitterRect.left > splitterRect.left,
+ `Should move in the right direction ${splitterRect.left} -> ${newSplitterRect.left}, ${offsetX}`
+ );
+ }
+
+ function shouldBeCollapsed(where) {
+ SimpleTest.is(splitter.getAttribute("state"), "collapsed", "The splitter should be collapsed");
+ SimpleTest.is(splitter.getAttribute("substate"), where, "The splitter should be collapsed " + where);
+ }
+
+ function shouldNotBeCollapsed() {
+ SimpleTest.is(splitter.getAttribute("state"), "", "The splitter should not be collapsed");
+ }
+
+ async function runPass(isRTL, rightCollapsed, leftCollapsed) {
+ var containerWidth = splitter.parentNode.getBoundingClientRect().width;
+ await dragSplitter(containerWidth);
+ if (rightCollapsed) {
+ shouldBeCollapsed(isRTL ? "before" : "after");
+ } else {
+ shouldNotBeCollapsed();
+ }
+ await dragSplitter(-containerWidth * 2);
+ if (leftCollapsed) {
+ shouldBeCollapsed(isRTL ? "after" : "before");
+ } else {
+ shouldNotBeCollapsed();
+ }
+ await dragSplitter(containerWidth / 2);
+ // the splitter should never be collapsed in the middle
+ shouldNotBeCollapsed();
+ }
+
+ var splitter;
+ async function runTests(rtl, splitterId) {
+ splitter = document.getElementById(splitterId);
+ await runPass(rtl, false, false);
+ splitter.setAttribute("collapse", "before");
+ await runPass(rtl, rtl, !rtl);
+ splitter.setAttribute("collapse", "after");
+ await runPass(rtl, !rtl, rtl);
+ splitter.setAttribute("collapse", "both");
+ await runPass(rtl, true, true);
+ }
+
+ async function runAllTests() {
+ await runTests(false, "ltr-splitter");
+ await runTests(true, "rtl-splitter");
+ SimpleTest.finish();
+ }
+
+ addLoadEvent(function() {SimpleTest.executeSoon(runAllTests);});
+ ]]></script>
+
+ <hbox style="max-width: 200px; height: 300px; direction: ltr;">
+ <vbox style="width: 100px; height: 300px;" flex="1"/>
+ <splitter id="ltr-splitter" width="5"/>
+ <vbox style="width: 100px; height: 300px;" flex="1"/>
+ </hbox>
+
+ <hbox style="max-width: 200px; height: 300px; direction: rtl;">
+ <vbox style="width: 100px; height: 300px;" flex="1"/>
+ <splitter id="rtl-splitter" width="5"/>
+ <vbox style="width: 100px; height: 300px;" flex="1"/>
+ </hbox>
+
+</window>
diff --git a/layout/xul/test/test_submenuClose.xhtml b/layout/xul/test/test_submenuClose.xhtml
new file mode 100644
index 0000000000..47337e61b9
--- /dev/null
+++ b/layout/xul/test/test_submenuClose.xhtml
@@ -0,0 +1,91 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1181560
+-->
+<window title="Mozilla Bug 1181560"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="SimpleTest.waitForFocus(nextTest, window)">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1181560"
+ target="_blank">Mozilla Bug 1181560</a>
+ </body>
+
+ <vbox>
+ <menubar>
+ <menu id="menu" label="MyMenu">
+ <menupopup>
+ <menuitem label="A"/>
+ <menu id="b" label="B">
+ <menupopup>
+ <menuitem label="B1"/>
+ </menupopup>
+ </menu>
+ <menu id="c" label="C">
+ <menupopup>
+ <menuitem label="C1"/>
+ </menupopup>
+ </menu>
+ </menupopup>
+ </menu>
+ </menubar>
+ </vbox>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+ /** Test for Bug 1181560 **/
+ SimpleTest.waitForExplicitFinish();
+
+ let menuB, menuC, mainMenu, menuBOpen, menuCOpen;
+ let menuBOpenCount = 0;
+
+ function handleBOpens() {
+ menuBOpenCount++;
+ menuBOpen = true;
+ ok(!menuCOpen, "Menu C should not be open when menu B has opened");
+ if (menuBOpenCount >= 2) {
+ SimpleTest.finish();
+ return;
+ }
+ sendKey("LEFT", window);
+ sendKey("DOWN", window);
+ sendKey("RIGHT", window);
+ }
+
+ function handleBCloses() {
+ menuBOpen = false;
+ }
+
+ function handleCOpens() {
+ menuCOpen = true;
+ ok(!menuBOpen, "Menu B should not be open when menu C has opened");
+ synthesizeMouseAtCenter(menuB, {}, window);
+ }
+
+ function handleCCloses() {
+ menuCOpen = false;
+ }
+
+ function nextTest(e) {
+ mainMenu = document.getElementById("menu");
+ menuB = document.getElementById("b");
+ menuC = document.getElementById("c");
+ menuB.menupopup.addEventListener("popupshown", handleBOpens);
+ menuB.menupopup.addEventListener("popuphidden", handleBCloses);
+ menuC.menupopup.addEventListener("popupshown", handleCOpens);
+ menuC.menupopup.addEventListener("popuphidden", handleCCloses);
+ mainMenu.addEventListener("popupshown", ev => {
+ synthesizeMouseAtCenter(menuB, {}, window);
+ });
+ mainMenu.open = true;
+ }
+ ]]>
+ </script>
+</window>
diff --git a/layout/xul/test/test_titlebar_ctrl_click.xhtml b/layout/xul/test/test_titlebar_ctrl_click.xhtml
new file mode 100644
index 0000000000..d58bfa7eb7
--- /dev/null
+++ b/layout/xul/test/test_titlebar_ctrl_click.xhtml
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+ XUL Widget Test for the titlebar element
+ -->
+<window title="Titlebar" width="200" height="200"
+ onload="setTimeout(test_titlebar_ctrl_click, 0);"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+<titlebar id="titlebar">
+ <label id="label" value="Titlebar"/>
+</titlebar>
+
+<!-- test code goes here -->
+<script type="application/javascript"><![CDATA[
+
+const { AppConstants } = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
+
+SimpleTest.waitForExplicitFinish();
+
+function test_titlebar_ctrl_click()
+{
+ let titlebar = document.getElementById("titlebar");
+ let isCommandFired = false;
+
+ titlebar.addEventListener("click", function(aEvent) {
+ // Delay check for command event, because it is fired after click event.
+ setTimeout(() => {
+ is(isCommandFired, AppConstants.platform != "macosx",
+ "Check if command event is fired");
+ SimpleTest.finish();
+ }, 0);
+ });
+ titlebar.addEventListener("command", function(aEvent) {
+ isCommandFired = true;
+ ok(aEvent.ctrlKey, "Check ctrlKey for command event");
+ ok(!aEvent.shiftKey, "Check shiftKey for command event");
+ ok(!aEvent.altKey, "Check altKey for command event");
+ ok(!aEvent.metaKey, "Check metaKey for command event");
+ is(aEvent.inputSource, MouseEvent.MOZ_SOURCE_MOUSE,
+ "Check inputSource for command event");
+ });
+ synthesizeMouseAtCenter(titlebar, { ctrlKey: true });
+}
+
+]]>
+</script>
+
+</window>
diff --git a/layout/xul/test/test_toolbarbutton_ctrl_click.xhtml b/layout/xul/test/test_toolbarbutton_ctrl_click.xhtml
new file mode 100644
index 0000000000..b09300dc4f
--- /dev/null
+++ b/layout/xul/test/test_toolbarbutton_ctrl_click.xhtml
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+ XUL Widget Test for the toolbarbutton element
+ -->
+<window title="Titlebar" width="200" height="200"
+ onload="setTimeout(test_resizer_ctrl_click, 0);"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+<toolbarbutton id="toolbarbutton" width="16" height="16"/>
+
+<!-- test code goes here -->
+<script type="application/javascript"><![CDATA[
+
+const { AppConstants } = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
+
+SimpleTest.waitForExplicitFinish();
+
+function test_resizer_ctrl_click()
+{
+ let toolbarbutton = document.getElementById("toolbarbutton");
+ let isCommandFired = false;
+
+ toolbarbutton.addEventListener("click", function(aEvent) {
+ // Delay check for command event, because it is fired after click event.
+ setTimeout(() => {
+ is(isCommandFired, AppConstants.platform != "macosx",
+ "Check if command event is fired");
+ SimpleTest.finish();
+ }, 0);
+ });
+ toolbarbutton.addEventListener("command", function(aEvent) {
+ isCommandFired = true;
+ ok(aEvent.ctrlKey, "Check ctrlKey for command event");
+ ok(!aEvent.shiftKey, "Check shiftKey for command event");
+ ok(!aEvent.altKey, "Check altKey for command event");
+ ok(!aEvent.metaKey, "Check metaKey for command event");
+ is(aEvent.inputSource, MouseEvent.MOZ_SOURCE_MOUSE,
+ "Check inputSource for command event");
+ });
+ synthesizeMouseAtCenter(toolbarbutton, { ctrlKey: true });
+}
+
+]]>
+</script>
+
+</window>
diff --git a/layout/xul/test/test_windowminmaxsize.xhtml b/layout/xul/test/test_windowminmaxsize.xhtml
new file mode 100644
index 0000000000..7d58a0e49e
--- /dev/null
+++ b/layout/xul/test/test_windowminmaxsize.xhtml
@@ -0,0 +1,235 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<window title="Window Minimum and Maximum Size Tests" onload="nextTest()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+<panel id="panel" onpopupshown="doPanelTest(this)" onpopuphidden="nextPopupTest(this)"
+ align="start" pack="start" style="-moz-appearance: none; margin: 0; border: 0; padding: 0;">
+ <resizer id="popupresizer" dir="bottomright" flex="1" width="60" height="60"
+ style="-moz-appearance: none; margin: 0; border: 0; padding: 0;"/>
+</panel>
+
+<script>
+<![CDATA[
+
+SimpleTest.waitForExplicitFinish();
+
+var gTestId = -1;
+
+// width and height in the tests below specify the expected size of the window.
+// note, win8 has a minimum inner window size of around 122 pixels. Don't go below this on min-width tests.
+var tests = [
+ { testname: "unconstrained",
+ src: "windowminmaxsize1.xhtml",
+ width: 150, height: 150 },
+ { testname: "constraint min style",
+ src: "windowminmaxsize2.xhtml",
+ width: 180, height: 210 },
+ { testname: "constraint max style",
+ src: "windowminmaxsize3.xhtml",
+ width: 125, height: 140 },
+ { testname: "constraint min attributes",
+ src: "windowminmaxsize4.xhtml",
+ width: 240, height: 220 },
+ { testname: "constraint min attributes with width and height set",
+ src: "windowminmaxsize5.xhtml",
+ width: 215, height: 235 },
+ { testname: "constraint max attributes",
+ src: "windowminmaxsize6.xhtml",
+ width: 125, height: 95 },
+ // this gets the inner width as <window minwidth='210'> makes the box 210 pixels wide
+ { testname: "constraint min width attribute only",
+ src: "windowminmaxsize7.xhtml",
+ width: 210, height: 150 },
+ { testname: "constraint max width attribute only",
+ src: "windowminmaxsize8.xhtml",
+ width: 128, height: 150 },
+ { testname: "constraint max width attribute with minheight",
+ src: "windowminmaxsize9.xhtml",
+ width: 195, height: 180 },
+ { testname: "constraint minwidth, minheight, maxwidth and maxheight set",
+ src: "windowminmaxsize10.xhtml",
+ width: 150, height: 150, last: true }
+];
+
+var popupTests = [
+ { testname: "popup unconstrained",
+ width: 60, height: 60
+ },
+ { testname: "popup with minimum size",
+ minwidth: 150, minheight: 180,
+ width: 150, height: 180
+ },
+ { testname: "popup with maximum size",
+ maxwidth: 50, maxheight: 45,
+ width: 50, height: 45,
+ },
+ { testname: "popup with minimum and size",
+ minwidth: 80, minheight: 70, maxwidth: 250, maxheight: 220,
+ width: 80, height: 70, last: true
+ }
+];
+
+function nextTest()
+{
+ // Run through each of the tests above by opening a simple window with
+ // the attributes or style defined for that test. The comparisons will be
+ // done by windowOpened. gTestId holds the index into the tests array.
+ if (++gTestId >= tests.length) {
+ // Now do the popup tests
+ gTestId = -1;
+ SimpleTest.waitForFocus(function () { nextPopupTest(document.getElementById("panel")) } );
+ }
+ else {
+ tests[gTestId].window = window.browsingContext.topChromeWindow.open(tests[gTestId].src, "_blank", "chrome,resizable=yes");
+ SimpleTest.waitForFocus(windowOpened, tests[gTestId].window);
+ }
+}
+
+function windowOpened(otherWindow)
+{
+ // Check the width and the width plus one due to bug 696746.
+ ok(otherWindow.innerWidth == tests[gTestId].width ||
+ otherWindow.innerWidth == tests[gTestId].width + 1,
+ tests[gTestId].testname + " width of " + otherWindow.innerWidth + " matches " + tests[gTestId].width);
+ is(otherWindow.innerHeight, tests[gTestId].height, tests[gTestId].testname + " height");
+
+ // On the last test, try moving the resizer to a size larger than the maximum
+ // and smaller than the minimum. This test is only done on Mac as the other
+ // platforms use native resizing.
+ if ('last' in tests[gTestId] && (navigator.platform.indexOf("Mac") == 0)) {
+ var resizer = otherWindow.document.documentElement.firstChild;
+ synthesizeMouse(resizer, 4, 4, { type:"mousedown" }, otherWindow);
+ synthesizeMouse(resizer, 800, 800, { type:"mousemove" }, otherWindow);
+ is(otherWindow.innerWidth, 480, "Width after maximum resize");
+ is(otherWindow.innerHeight, 470, "Height after maximum resize");
+
+ synthesizeMouse(resizer, -100, -100, { type:"mousemove" }, otherWindow);
+ is(otherWindow.innerWidth, 120, "Width after minimum resize");
+ is(otherWindow.innerHeight, 110, "Height after minimum resize");
+
+ synthesizeMouse(resizer, 4, 4, { type:"mouseup" }, otherWindow);
+
+ // Change the minimum and maximum size and try resizing the window again.
+ otherWindow.document.documentElement.minWidth = 140;
+ otherWindow.document.documentElement.minHeight = 130;
+ otherWindow.document.documentElement.maxWidth = 380;
+ otherWindow.document.documentElement.maxHeight = 360;
+
+ synthesizeMouse(resizer, 4, 4, { type:"mousedown" }, otherWindow);
+ synthesizeMouse(resizer, 800, 800, { type:"mousemove" }, otherWindow);
+ is(otherWindow.innerWidth, 380, "Width after changed maximum resize");
+ is(otherWindow.innerHeight, 360, "Height after changed maximum resize");
+
+ synthesizeMouse(resizer, -100, -100, { type:"mousemove" }, otherWindow);
+ is(otherWindow.innerWidth, 140, "Width after changed minimum resize");
+ is(otherWindow.innerHeight, 130, "Height after changed minimum resize");
+
+ synthesizeMouse(resizer, 4, 4, { type:"mouseup" }, otherWindow);
+ }
+
+ otherWindow.close();
+ nextTest();
+}
+
+function doPanelTest(panel)
+{
+ var rect = panel.getBoundingClientRect();
+ is(rect.width, popupTests[gTestId].width, popupTests[gTestId].testname + " width");
+ is(rect.height, popupTests[gTestId].height, popupTests[gTestId].testname + " height");
+
+ if ('last' in popupTests[gTestId]) {
+ var resizer = document.getElementById("popupresizer");
+ synthesizeMouse(resizer, 4, 4, { type:"mousedown" });
+ synthesizeMouse(resizer, 800, 800, { type:"mousemove" });
+
+ rect = panel.getBoundingClientRect();
+ is(rect.width, 250, "Popup width after maximum resize");
+ is(rect.height, 220, "Popup height after maximum resize");
+
+ synthesizeMouse(resizer, -100, -100, { type:"mousemove" });
+
+ rect = panel.getBoundingClientRect();
+ is(rect.width, 80, "Popup width after minimum resize");
+ is(rect.height, 70, "Popup height after minimum resize");
+
+ synthesizeMouse(resizer, 4, 4, { type:"mouseup" });
+ }
+
+ panel.hidePopup();
+}
+
+function nextPopupTest(panel)
+{
+ if (++gTestId >= popupTests.length) {
+ // Next, check a panel that has a titlebar to ensure that it is accounted for
+ // properly in the size.
+ var titledPanelWindow = window.browsingContext.topChromeWindow.open("titledpanelwindow.xhtml", "_blank", "chrome,resizable=yes");
+ SimpleTest.waitForFocus(titledPanelWindowOpened, titledPanelWindow);
+ }
+ else {
+ function setattr(attr) {
+ if (attr in popupTests[gTestId])
+ panel.setAttribute(attr, popupTests[gTestId][attr]);
+ else
+ panel.removeAttribute(attr);
+ }
+ setattr("minwidth");
+ setattr("minheight");
+ setattr("maxwidth");
+ setattr("maxheight");
+
+ // Remove the flexibility as it causes the resizer to not shrink down
+ // when resizing.
+ if ("last" in popupTests[gTestId])
+ document.getElementById("popupresizer").removeAttribute("flex");
+
+ // Prevent event loop starvation as a result of popup events being
+ // synchronous. See bug 1131576.
+ SimpleTest.executeSoon(() => {
+ // Non-chrome shells require focus to open a popup.
+ SimpleTest.waitForFocus(() => { panel.openPopup() });
+ });
+ }
+}
+
+function titledPanelWindowOpened(panelwindow)
+{
+ var panel = panelwindow.document.documentElement.firstChild;
+ panel.openPopup();
+ panel.addEventListener("popupshown", () => doTitledPanelTest(panel));
+ panel.addEventListener("popuphidden", () => done(panelwindow));
+}
+
+function doTitledPanelTest(panel)
+{
+ var rect = panel.getBoundingClientRect();
+ is(rect.width, 120, "panel with titlebar width");
+ is(rect.height, 140, "panel with titlebar height");
+ panel.hidePopup();
+}
+
+function done(panelwindow)
+{
+ panelwindow.close();
+ SimpleTest.finish();
+}
+
+]]>
+</script>
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+<p id="display">
+</p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+</pre>
+</body>
+
+</window>
diff --git a/layout/xul/test/titledpanelwindow.xhtml b/layout/xul/test/titledpanelwindow.xhtml
new file mode 100644
index 0000000000..ab9dc13f2d
--- /dev/null
+++ b/layout/xul/test/titledpanelwindow.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0;'>
+<panel noautohide='true' titlebar='normal' minwidth='120' minheight='140'/><label value='Test'/>
+</window>
diff --git a/layout/xul/test/window_resizer.xhtml b/layout/xul/test/window_resizer.xhtml
new file mode 100644
index 0000000000..8e3ca6d159
--- /dev/null
+++ b/layout/xul/test/window_resizer.xhtml
@@ -0,0 +1,113 @@
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ screenX="200" screenY="200" width="300" height="300"
+ onload="setTimeout(doTest, 0)">
+<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+<script><![CDATA[
+var is = window.arguments[0].SimpleTest.is;
+
+function doTest() {
+ // from test_resizer.xhtml
+ var expectX = 200;
+ var expectY = 200;
+ var expectXMost = 500;
+ var expectYMost = 500;
+ var screenScale = expectX/window.screenX;
+ var root = document.documentElement;
+
+ var oldScreenX = window.screenX;
+ var oldScreenY = window.screenY;
+ var oldWidth = window.outerWidth;
+ var oldHeight = window.outerHeight;
+
+ function testResizer(dx, dy) {
+ var offset = 20;
+ var scale = 5;
+ // target the centre of the resizer
+ var offsetX = window.innerWidth/2 + (window.innerWidth/3)*dx;
+ var offsetY = window.innerHeight/2 + (window.innerHeight/3)*dy;
+
+ for (var mouseX = -1; mouseX <= 1; ++mouseX) {
+ for (var mouseY = -1; mouseY <= 1; ++mouseY) {
+ var newExpectX = expectX;
+ var newExpectXMost = expectXMost;
+ var newExpectY = expectY;
+ var newExpectYMost = expectYMost;
+ if (dx < 0) {
+ newExpectX += mouseX*scale;
+ } else if (dx > 0) {
+ newExpectXMost += mouseX*scale;
+ }
+ if (dy < 0) {
+ newExpectY += mouseY*scale;
+ } else if (dy > 0) {
+ newExpectYMost += mouseY*scale;
+ }
+
+ synthesizeMouse(root, offsetX, offsetY, { type:"mousedown" });
+ synthesizeMouse(root, offsetX + mouseX*scale, offsetY + mouseY*scale, { type:"mousemove" });
+ is(window.screenX*screenScale, newExpectX,
+ "Bad x for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
+ is(window.screenY*screenScale, newExpectY,
+ "Bad y for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
+ is(window.outerWidth, newExpectXMost - newExpectX,
+ "Bad width for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
+ is(window.outerHeight, newExpectYMost - newExpectY,
+ "Bad height for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
+
+ // move it back before we release! Adjust for any window movement
+ synthesizeMouse(root, offsetX - (newExpectX - expectX),
+ offsetY - (newExpectY - expectY), { type:"mousemove" });
+ synthesizeMouse(root, offsetX, offsetY, { type:"mouseup" });
+ }
+ }
+ }
+
+ testResizer(-1, -1);
+ testResizer(-1, 0);
+ testResizer(-1, 1);
+ testResizer(0, -1);
+ testResizer(0, 1);
+ testResizer(1, -1);
+ testResizer(1, 0);
+ testResizer(1, 1);
+
+ var resizers = document.getElementsByTagName("resizer");
+ Array.prototype.forEach.call(resizers, function (element) {
+ is(getComputedStyle(element, "").cursor,
+ element.getAttribute("expectedcursor"),
+ "cursor for " + element.getAttribute("dir"));
+ });
+
+ // now check the cursors in rtl. The bottomend resizer
+ // should be reversed
+ document.documentElement.setAttribute("localedir", "rtl");
+ Array.prototype.forEach.call(resizers, function (element) {
+ is(getComputedStyle(element, "").cursor,
+ element.getAttribute("dir") == "bottomend" ? "sw-resize" :
+ element.getAttribute("expectedcursor"),
+ "cursor for " + element.getAttribute("dir"));
+ });
+
+ window.close();
+ window.arguments[0].lastResizerTest();
+}
+]]></script>
+ <hbox id="container" flex="1">
+ <vbox flex="1">
+ <resizer dir="topleft" expectedcursor="nw-resize" flex="1"/>
+ <resizer dir="left" expectedcursor="ew-resize" flex="1"/>
+ <resizer dir="bottomleft" expectedcursor="sw-resize" flex="1"/>
+ </vbox>
+ <vbox flex="1">
+ <resizer dir="top" expectedcursor="ns-resize" flex="1"/>
+ <resizer id="bottomend" dir="bottomend" expectedcursor="se-resize" flex="1"/>
+ <resizer dir="bottom" expectedcursor="ns-resize" flex="1"/>
+ </vbox>
+ <vbox flex="1">
+ <resizer dir="topright" expectedcursor="ne-resize" flex="1"/>
+ <resizer dir="right" expectedcursor="ew-resize" flex="1"/>
+ <resizer dir="bottomright" expectedcursor="se-resize" flex="1"/>
+ </vbox>
+ </hbox>
+</window>
diff --git a/layout/xul/test/window_resizer_element.xhtml b/layout/xul/test/window_resizer_element.xhtml
new file mode 100644
index 0000000000..9741556e14
--- /dev/null
+++ b/layout/xul/test/window_resizer_element.xhtml
@@ -0,0 +1,188 @@
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ align="start">
+<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+<script><![CDATA[
+var is = window.arguments[0].SimpleTest.is;
+window.onerror = window.arguments[0].onerror;
+
+const anchorPositions =
+ [ "before_start", "before_end", "after_start", "after_end",
+ "start_before", "start_after", "end_before", "end_after", "overlap", "screen"];
+var currentPosition;
+
+function testResizer(resizerid, noShrink, hResize, vResize, testid)
+{
+ var rect = document.getElementById(resizerid + "-container").getBoundingClientRect();
+ var resizer = document.getElementById(resizerid);
+ var resizerrect = resizer.getBoundingClientRect();
+
+ var originalX = resizerrect.left;
+ var originalY = resizerrect.top;
+
+ const scale = 20;
+ for (var mouseX = -1; mouseX <= 1; ++mouseX) {
+ for (var mouseY = -1; mouseY <= 1; ++mouseY) {
+ var expectedWidth = rect.width + hResize * mouseX * scale;
+ var expectedHeight = rect.height + vResize * mouseY * scale;
+
+ if (noShrink) {
+ if (mouseX == -1)
+ expectedWidth = rect.width;
+ if (mouseY == -1)
+ expectedHeight = rect.height;
+ }
+
+ synthesizeMouse(document.documentElement, originalX + 5, originalY + 5, { type:"mousedown" });
+ synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
+ originalY + 5 + mouseY * scale, { type:"mousemove" });
+
+ var newrect = document.getElementById(resizerid + "-container").getBoundingClientRect();
+ is(Math.round(newrect.width), Math.round(expectedWidth), "resize element " + resizerid +
+ " " + testid + " width moving " + mouseX + "," + mouseY + ",,," + hResize);
+ is(Math.round(newrect.height), Math.round(expectedHeight), "resize element " + resizerid +
+ " " + testid + " height moving " + mouseX + "," + mouseY);
+ // release
+ synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
+ originalY + 5 + mouseY * scale, { type:"mouseup" });
+ // return to the original size
+ synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
+ originalY + 5 + mouseY * scale, { type:"dblclick" });
+ var newrect = document.getElementById(resizerid + "-container").getBoundingClientRect();
+ is(Math.round(newrect.width), Math.round(rect.width), "resize element " + resizerid +
+ " " + testid + " doubleclicking to restore original size");
+ is(Math.round(newrect.height), Math.round(rect.height), "resize element " + resizerid +
+ " " + testid + " doubleclicking to restore original size");
+ }
+ }
+}
+
+function doTest() {
+ // first, check if a resizer with a element attribute set to an element that
+ // does not exist does not cause a problem
+ var resizer = document.getElementById("notfound");
+ synthesizeMouse(resizer, 5, 5, { type:"mousedown" });
+ synthesizeMouse(resizer, 10, 10, { type:"mousemove" });
+ synthesizeMouse(resizer, 5, 5, { type:"mouseup" });
+
+ testResizer("outside", true, 1, 1, "");
+ testResizer("html", true, 1, 1, "");
+ testResizer("inside", true, 1, 1, "");
+ testResizer("inside-large", false, 1, 1, "");
+ testResizer("inside-with-border", true, 1, 1, "");
+
+ document.getElementById("inside-popup-container").
+ openPopupAtScreen(Math.ceil(window.mozInnerScreenX) + 100, Math.ceil(window.mozInnerScreenY) + 100);
+}
+
+function popupShown(event)
+{
+ testResizer("inside-popup", false, 1, 1, "");
+ document.getElementById("inside-popup-container").id = "outside-popup-container";
+ testResizer("outside-popup", false, 1, 1, "");
+
+ var resizerrect = document.getElementById("inside-popup").getBoundingClientRect();
+ synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mousedown" });
+ synthesizeMouse(document.documentElement, resizerrect.left + 2000, resizerrect.top + 2000, { type:"mousemove" });
+
+ var isMac = (navigator.platform.includes("Mac"));
+ var popuprect = document.getElementById("outside-popup-container").getBoundingClientRect();
+ // subtract 3 due to space left for panel dropshadow
+ is(Math.ceil(window.mozInnerScreenX) + popuprect.right,
+ (isMac ? screen.availLeft + screen.availWidth : screen.left + screen.width) - 3, "resized to edge width");
+ is(Math.ceil(window.mozInnerScreenY) + popuprect.bottom,
+ (isMac ? screen.availTop + screen.availHeight : screen.top + screen.height) - 3, "resized to edge height");
+
+ resizerrect = document.getElementById("inside-popup").getBoundingClientRect();
+ synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mouseup" });
+
+ event.target.hidePopup();
+}
+
+function popupHidden()
+{
+ if (anchorPositions.length == 0) {
+ window.close();
+ window.arguments[0].SimpleTest.finish();
+ return;
+ }
+
+ currentPosition = anchorPositions.shift();
+ var anchor = document.getElementById("anchor");
+ var popup = document.getElementById("anchored-panel-container");
+
+ if (currentPosition == "screen")
+ popup.openPopupAtScreen(window.screenX + 100, window.screenY + 100);
+ else
+ popup.openPopup(anchor, currentPosition);
+}
+
+function anchoredPopupShown(event)
+{
+ var leftAllowed = (!currentPosition.includes("end_") && !currentPosition.includes("_start"));
+ var rightAllowed = (!currentPosition.includes("start_") && !currentPosition.includes("_end"));
+ var topAllowed = (!currentPosition.includes("after_") && !currentPosition.includes("_before"));
+ var bottomAllowed = (!currentPosition.includes("before_") && !currentPosition.includes("_after"));
+
+ if (currentPosition == "overlap") {
+ leftAllowed = topAllowed = false;
+ rightAllowed = bottomAllowed = true;
+ }
+
+ var resizerTypes = [ "topleft", "top", "topright", "left", "right",
+ "bottomleft", "bottom", "bottomright", "bottomend" ];
+ for (var r = 0; r < resizerTypes.length; r++) {
+ var resizerType = resizerTypes[r];
+ var horiz = 0, vert = 0;
+ if (leftAllowed && resizerType.includes("left")) horiz = -1;
+ else if (rightAllowed && (resizerType.includes("right") || resizerType == "bottomend")) horiz = 1;
+
+ if (topAllowed && resizerType.includes("top")) vert = -1;
+ else if (bottomAllowed && resizerType.includes("bottom")) vert = 1;
+
+ document.getElementById("anchored-panel").dir = resizerType;
+ testResizer("anchored-panel", false, horiz, vert, currentPosition + " " + resizerType);
+ }
+
+ event.target.hidePopup();
+}
+
+window.arguments[0].SimpleTest.waitForFocus(doTest, window);
+]]></script>
+
+<resizer id="outside" dir="bottomend" element="outside-container"/>
+<resizer id="notfound" dir="bottomend" element="nothing"/>
+<hbox id="outside-container">
+ <hbox minwidth="46" minheight="39"/>
+</hbox>
+<html:div id="html-container" xmlns:html="http://www.w3.org/1999/xhtml">
+ <html:button>One</html:button><html:br/>
+ <resizer id="html" dir="bottomend" element="_parent"/>
+</html:div>
+<hbox id="anchor" align="start" style="margin-left: 100px;">
+ <hbox id="inside-container" align="start">
+ <hbox minwidth="45" minheight="41"/>
+ <resizer id="inside" dir="bottomend" element="_parent"/>
+ </hbox>
+ <hbox id="inside-large-container" width="70" height="70" align="start">
+ <resizer id="inside-large" dir="bottomend" element="_parent"/>
+ </hbox>
+ <hbox id="inside-with-border-container" style="border: 5px solid red; padding: 2px; margin: 2px;" align="start">
+ <hbox minwidth="35" minheight="30"/>
+ <resizer id="inside-with-border" dir="bottomend" element="_parent"/>
+ </hbox>
+</hbox>
+
+<panel id="inside-popup-container" align="start" onpopupshown="popupShown(event)" onpopuphidden="popupHidden()">
+ <resizer id="inside-popup" dir="bottomend"/>
+ <hbox width="50" height="50" flex="1"/>
+</panel>
+<resizer id="outside-popup" dir="bottomend" element="outside-popup-container"/>
+
+<panel id="anchored-panel-container" align="start" onpopupshown="anchoredPopupShown(event)"
+ onpopuphidden="popupHidden()">
+ <hbox width="50" height="50" flex="1"/>
+ <resizer id="anchored-panel" width="20" height="20"/>
+</panel>
+
+</window>
diff --git a/layout/xul/test/windowminmaxsize1.xhtml b/layout/xul/test/windowminmaxsize1.xhtml
new file mode 100644
index 0000000000..fff337da23
--- /dev/null
+++ b/layout/xul/test/windowminmaxsize1.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0;'>
+<resizer dir='bottomright' flex='1' width='150' height='150' style='-moz-appearance: none; margin: 0; border: 0; padding: 0;'/>
+</window>
diff --git a/layout/xul/test/windowminmaxsize10.xhtml b/layout/xul/test/windowminmaxsize10.xhtml
new file mode 100644
index 0000000000..bf20fd4ce2
--- /dev/null
+++ b/layout/xul/test/windowminmaxsize10.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0;' minwidth='120' maxwidth='480' minheight='110' maxheight='470'>
+<resizer dir='bottomright' flex='1' width='150' height='150' style='-moz-appearance: none; margin: 0; border: 0; padding: 0;'/>
+</window>
diff --git a/layout/xul/test/windowminmaxsize2.xhtml b/layout/xul/test/windowminmaxsize2.xhtml
new file mode 100644
index 0000000000..96053b76f8
--- /dev/null
+++ b/layout/xul/test/windowminmaxsize2.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0; min-width: 180px; min-height: 210px;'>
+<resizer dir='bottomright' flex='1' width='150' height='150' style='-moz-appearance: none; margin: 0; border: 0; padding: 0;'/>
+</window>
diff --git a/layout/xul/test/windowminmaxsize3.xhtml b/layout/xul/test/windowminmaxsize3.xhtml
new file mode 100644
index 0000000000..2eca783041
--- /dev/null
+++ b/layout/xul/test/windowminmaxsize3.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0; max-width: 125px; max-height: 140px'>
+<resizer dir='bottomright' flex='1' width='150' height='150' style='-moz-appearance: none; margin: 0; border: 0; padding: 0;'/>
+</window>
diff --git a/layout/xul/test/windowminmaxsize4.xhtml b/layout/xul/test/windowminmaxsize4.xhtml
new file mode 100644
index 0000000000..81b07ca5c0
--- /dev/null
+++ b/layout/xul/test/windowminmaxsize4.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0;' minwidth='240' minheight='220'>
+<resizer dir='bottomright' flex='1' width='150' height='150' style='-moz-appearance: none; margin: 0; border: 0; padding: 0;'/>
+</window>
diff --git a/layout/xul/test/windowminmaxsize5.xhtml b/layout/xul/test/windowminmaxsize5.xhtml
new file mode 100644
index 0000000000..b4365e5388
--- /dev/null
+++ b/layout/xul/test/windowminmaxsize5.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0;' width='190' height='220' minwidth='215' minheight='235'>
+<resizer dir='bottomright' flex='1' width='150' height='150' style='-moz-appearance: none; margin: 0; border: 0; padding: 0;'/>
+</window>
diff --git a/layout/xul/test/windowminmaxsize6.xhtml b/layout/xul/test/windowminmaxsize6.xhtml
new file mode 100644
index 0000000000..76a8b6b3f0
--- /dev/null
+++ b/layout/xul/test/windowminmaxsize6.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0;' maxwidth='125' maxheight='95'>
+<resizer dir='bottomright' flex='1' width='150' height='150' style='-moz-appearance: none; margin: 0; border: 0; padding: 0;'/>
+</window>
diff --git a/layout/xul/test/windowminmaxsize7.xhtml b/layout/xul/test/windowminmaxsize7.xhtml
new file mode 100644
index 0000000000..9d037fd27d
--- /dev/null
+++ b/layout/xul/test/windowminmaxsize7.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0;' minwidth='210'>
+<resizer dir='bottomright' flex='1' width='150' height='150' style='-moz-appearance: none; margin: 0; border: 0; padding: 0;'/>
+</window>
diff --git a/layout/xul/test/windowminmaxsize8.xhtml b/layout/xul/test/windowminmaxsize8.xhtml
new file mode 100644
index 0000000000..52847e91af
--- /dev/null
+++ b/layout/xul/test/windowminmaxsize8.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0;' maxwidth='128'>
+<resizer dir='bottomright' flex='1' width='150' height='150' style='-moz-appearance: none; margin: 0; border: 0; padding: 0;'/>
+</window>
diff --git a/layout/xul/test/windowminmaxsize9.xhtml b/layout/xul/test/windowminmaxsize9.xhtml
new file mode 100644
index 0000000000..515fe1b243
--- /dev/null
+++ b/layout/xul/test/windowminmaxsize9.xhtml
@@ -0,0 +1,4 @@
+<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
+<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0;' maxwidth='195' width='230' height='120' minheight='180'>
+<resizer dir='bottomright' flex='1' width='150' height='150' style='-moz-appearance: none; margin: 0; border: 0; padding: 0;'/>
+</window>