summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/chrome/frame_popup_anchor.xul
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/content/tests/chrome/frame_popup_anchor.xul
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/content/tests/chrome/frame_popup_anchor.xul')
-rw-r--r--toolkit/content/tests/chrome/frame_popup_anchor.xul82
1 files changed, 82 insertions, 0 deletions
diff --git a/toolkit/content/tests/chrome/frame_popup_anchor.xul b/toolkit/content/tests/chrome/frame_popup_anchor.xul
new file mode 100644
index 000000000..be6254ce0
--- /dev/null
+++ b/toolkit/content/tests/chrome/frame_popup_anchor.xul
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+
+<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+<menupopup id="popup" onpopupshowing="if (isSecondTest) popupShowing(event)" onpopupshown="popupShown()"
+ onpopuphidden="nextTest()">
+ <menuitem label="One"/>
+ <menuitem label="Two"/>
+</menupopup>
+
+<button id="button" label="OK" popup="popup"/>
+
+<script class="testbody" type="application/javascript">
+<![CDATA[
+
+var isSecondTest = false;
+
+function openPopup()
+{
+ document.getElementById("popup").openPopup(parent.document.getElementById("outerbutton"), "after_start", 3, 1);
+}
+
+function popupShowing(event)
+{
+ var buttonrect = document.getElementById("button").getBoundingClientRect();
+ parent.opener.wrappedJSObject.SimpleTest.is(event.clientX, buttonrect.left + 6, "popup clientX with mouse");
+ parent.opener.wrappedJSObject.SimpleTest.is(event.clientY, buttonrect.top + 6, "popup clientY with mouse");
+}
+
+function popupShown()
+{
+ var left, top;
+ var popuprect = document.getElementById("popup").getBoundingClientRect();
+ if (isSecondTest) {
+ var buttonrect = document.getElementById("button").getBoundingClientRect();
+ left = buttonrect.left + 6;
+ top = buttonrect.top + 6;
+ }
+ else {
+ var iframerect = parent.document.getElementById("frame").getBoundingClientRect();
+ var buttonrect = parent.document.getElementById("outerbutton").getBoundingClientRect();
+
+ // The popup should appear anchored on the bottom left edge of the button, however
+ // the client rectangle is relative to the iframe's document. Thus the coordinates
+ // are:
+ // left = iframe's left - anchor button's left - 3 pixel offset passed to openPopup +
+ // iframe border (17px) + iframe padding (0)
+ // top = iframe's top - anchor button's bottom - 1 pixel offset passed to openPopup +
+ // iframe border (0) + iframe padding (3px);
+ left = -(Math.round(iframerect.left) - Math.round(buttonrect.left) + 14);
+ top = -(Math.round(iframerect.top) - Math.round(buttonrect.bottom) + 2);
+ }
+
+ var testid = isSecondTest ? "with mouse" : "anchored to parent frame";
+ parent.opener.wrappedJSObject.SimpleTest.is(Math.round(popuprect.left), left, "popup left " + testid);
+ parent.opener.wrappedJSObject.SimpleTest.is(Math.round(popuprect.top), top, "popup top " + testid);
+
+ document.getElementById("popup").hidePopup();
+}
+
+function nextTest()
+{
+ if (isSecondTest) {
+ parent.opener.wrappedJSObject.SimpleTest.finish();
+ parent.close();
+ }
+ else {
+ // this second test ensures that the popupshowing coordinates when a popup in
+ // a frame is opened are correct
+ isSecondTest = true;
+ synthesizeMouse(document.getElementById("button"), 6, 6, { });
+ }
+}
+
+]]>
+</script>
+
+</page>