import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

View file

@ -0,0 +1,200 @@
<!DOCTYPE HTML>
<html>
<head>
<title>nsIDOMWindowUtils::nodesFromRect test - bug 489127</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript;version=1.8">
var SimpleTest = window.opener.SimpleTest;
function ok() { window.opener.ok.apply(window.opener, arguments); }
function done() { window.opener.done.apply(window.opener, arguments); }
let e = {};
let dwu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
/*
nsIDOMNodeList nodesFromRect(in float aX,
in float aY,
in float aTopSize,
in float aRightSize,
in float aBottomSize,
in float aLeftSize,
in boolean aIgnoreRootScrollFrame,
in boolean aFlushLayout);
*/
function check(x, y, top, right, bottom, left, list) {
let nodes = dwu.nodesFromRect(x, y, top, right, bottom, left, true, false);
list.push(e.body);
list.push(e.html);
if (nodes.length != list.length) {
ok(false, "Different number of nodes for rect" +
"[" + x + "," + y + "], " +
"[" + top + "," + right + "," + bottom + "," + left + "]");
return;
}
for (var i = 0; i < nodes.length; i++) {
if (nodes[i] != list[i]) {
ok(false, "Unexpected node #" + i + " for rect " +
"[" + x + "," + y + "], " +
"[" + top + "," + right + "," + bottom + "," + left + "]");
return;
}
}
ok(true, "All correct nodes found for rect " +
"[" + x + "," + y + "], " +
"[" + top + "," + right + "," + bottom + "," + left + "]");
}
function doTest() {
// Set up shortcut access to elements
e['html'] = document.getElementsByTagName("html")[0];
['h1', 'd1', 'd2', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'span',
'a1', 'a2', 'a3', 'transf', 'iframe1', 'body'].forEach(function(a) {
e[a] = document.getElementById(a);
});
window.scrollTo(0, 0);
// Top, Right, Bottom, Left directions:
check(53, 71, 0, 0, 0, 0, []);
check(53, 71, 10, 0, 0, 0, [e.h1]);
check(53, 71, 0, 10, 0, 0, [e.p3]);
check(53, 71, 0, 0, 10, 0, [e.d1]);
check(152, 105, 0, 0, 0, 10, [e.d1]);
check(152, 105, 10, 10, 10, 10, [e.p4, e.p3, e.d1]);
// e.p1 is invisible and shouldn't appear:
check(153,193,0,0,0,0,[e.p5]);
check(153,193,0,20,0,20, [e.p5, e.d2]);
// Precise pixel checks:
check(144, 183, 0, 0, 0, 0, []);
check(144, 183, 0, 0, 1, 0, [e.p5]);
check(144, 183, 0, 0, 0, 1, [e.d2]);
check(144, 183, 0, 0, 1, 1, [e.p5, e.d2]);
check(77, 240, 0, 0, 0, 0, [e.p2]);
check(77, 240, 1, 0, 0, 0, [e.p5, e.p2]);
check(77, 240, 0, 0, 1, 0, [e.span, e.p2]);
check(77, 240, 1, 0, 1, 0, [e.p5, e.span, e.p2]);
// Expanding area checks:
check(39, 212, 0, 0, 0, 0, []);
check(39, 212, 10, 0, 0, 0, [e.d2]);
check(39, 212, 0, 0, 10, 0, [e.p2]);
check(39, 212, 10, 1, 30, 0, [e.d2, e.p2]);
check(39, 212, 10, 5, 30, 0, [e.span, e.d2, e.p2]);
check(39, 212, 10, 15, 30, 0, [e.p5, e.span, e.d2, e.p2]);
// Elements inside iframe shouldn't be returned:
check(15, 410, 0, 30, 50, 0, [e.iframe1]);
// Area with links and text nodes:
let [x1, y1] = getCenterFor(e.a1);
let [x2, y2] = getCenterFor(e.a2);
let [x3, y3] = getCenterFor(e.a3);
let [xt, yt] = [(x2 + x1) / 2, y1]; //text node between a1 and a2
check(x1, y1, 0, 0, 0, 0, [e.a1.firstChild, e.a1, e.p6]);
check(x1, y1, 0, 0, y3 - y1, 0, [e.a3.firstChild, e.a3, e.a1.firstChild, e.a1, e.p6]);
check(x1, y1, 0, xt - x1, 0, 0, [e.p6.childNodes[1], e.a1.firstChild, e.a1, e.p6]);
check(x1, y1, 0, x2 - x1, 0, 0, [e.a2.firstChild, e.a2, e.p6.childNodes[1], e.a1.firstChild, e.a1, e.p6]);
check(x1, y1, 0, x2 - x1, y3 - y1, 0, [e.a3.firstChild, e.a3, e.a2.firstChild, e.a2, e.p6.childNodes[1], e.a1.firstChild, e.a1, e.p6]);
// 2d transform:
check(61, 671, 0, 0, 0, 0, []);
check(61, 671, 0, 30, 0, 10, [e.transf]);
check(61, 671, 0, 30, 90, 10, [e.transf.firstChild, e.transf]);
done();
}
function getCenterFor(element) {
let rect = element.getBoundingClientRect();
return [(rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2];
}
addLoadEvent(doTest);
</script>
<style type="text/css">
body {
margin: 8px;
padding: 0;
}
h1, div, p, span, iframe {
display: block;
width: 100px;
height: 30px;
border: 3px solid black;
padding: 10px;
margin: 10px;
}
span {
display: inline-block;
}
#iframe1 {
height: 100px;
margin-top: 60px;
}
#p6 {
height: 50px;
margin-top: 30px;
}
#transf {
margin-top: 60px;
-moz-transform: rotate(-45deg);
}
#decimal {
position: relative;
left: 0.5px;
top: 50.5px;
}
</style>
</head>
<body id="body">
<h1 id="h1"></h1>
<div id="d1"></div>
<!-- floated element -->
<div id="d2" style="float: left"></div>
<!-- hidden element -->
<p id="p1" style="float: left; visibility: hidden"></p>
<p id="p2" style="clear: left"><span id="span"></span></p>
<!-- absolute position -->
<p id="p3" style="position:absolute; top: 10px; left:50px; height:50px;"></p>
<!-- fixed position -->
<p id="p4" style="position: fixed; top: 30px; left: 150px; height: 50px; background-color: blue;"></p>
<!-- relative position -->
<p id="p5" style="position:relative; top: -100px; left: 30px; margin-bottom: -70px; background-color: green"></p>
<!-- decimal CSS pixels -->
<div id="decimal"></div>
<iframe id="iframe1" src="data:text/html,<div>div</div><p>p</p>"></iframe>
<p id="p6"><a href="#" id="a1">A</a> / <a href="#" id="a2">A</a><br/><a href="#" id="a3">A</a></p>
<div id="transf">text</div>
</body>
</html>

View file

@ -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"?>
<!--
Test for Persistent Storage in chrome
-->
<window id="sample-window" width="400" height="400"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/chrome-harness.js"></script>
<script type="application/javascript">
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
document.addEventListener("DOMWindowCreated", function(e) {
var otherWindow = e.target.defaultView.wrappedJSObject;
SimpleTest.is(e.type, "DOMWindowCreated", "DOMWindowCreated: " + otherWindow);
otherWindow.doneFunction = function() {
SimpleTest.ok(true, "doneFunction was called");
SimpleTest.finish();
window.close();
};
}, false);
var root = getRootDirectory(window.location.href);
var el = document.createElement("iframe");
el.setAttribute('type', 'content');
el.setAttribute('src', root + 'DOMWindowCreated_content.html');
document.documentElement.appendChild(el);
</script>
</window>

View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<head>
<title>DOMWindowCreated helper</title>
<script type="application/javascript">
window.doneFunction();
</script>
<body>
<h1>DOMWindowCreated Helper</h1>

View file

@ -0,0 +1,110 @@
<?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"?>
<!--
Test that "MozDOMFullscreen:*" events are dispatched to chrome on documents that use DOM fullscreen.
Test Description:
This chrome window has a browser. The browser's contentDocument (the "outer document")
in turn has an iframe (the "inner document").
We request fullscreen in the outer document, and check that MozDOMFullscreen:Entered and
MozDOMFullscreen:NewOrigin are dispatched to chrome, targeted at the outer document.
Then we request fullscreen in the inner document, and check that MozDOMFullscreen:NewOrigin
is dispatched to chrome, targeted at the inner document.
Then we cancel fullscreen in the inner document, and check that MozDOMFullscreen:NewOrigin is
dispatched again to chrome, targeted at the outer document.
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="start();">
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"><![CDATA[
function ok(condition, msg) {
window.opener.wrappedJSObject.ok(condition, msg);
}
function is(a, b, msg) {
window.opener.wrappedJSObject.is(a, b, msg);
}
var gBrowser = null;
var gOuterDoc = null;
var gInnerDoc = null;
var gReceivedFullscreenEnteredEvent = false;
var gReceivedNewOriginEvent = false;
function firstEntry(event) {
if (event.type == "MozDOMFullscreen:Entered") {
window.removeEventListener("MozDOMFullscreen:Entered", firstEntry, false);
ok(!gReceivedFullscreenEnteredEvent, "MozDOMFullscreen:Entered shouldn't have been triggered twice");
is(event.target, gOuterDoc.body, "First MozDOMFullscreen:Entered should be targeted at outer body");
gReceivedFullscreenEnteredEvent = true;
} else if (event.type == "MozDOMFullscreen:NewOrigin") {
window.removeEventListener("MozDOMFullscreen:NewOrigin", firstEntry, false);
ok(!gReceivedNewOriginEvent, "MozDOMFullscreen:NewOrigin shouldn't have been triggered twice");
is(event.target, gOuterDoc, "First MozDOMFullscreen:NewOrigin should be targeted at outer doc");
gReceivedNewOriginEvent = true;
} else {
ok(false, "Unknown event received");
}
if (!gReceivedFullscreenEnteredEvent || !gReceivedNewOriginEvent) {
return;
}
ok(gOuterDoc.fullscreenElement != null, "Outer doc should be in fullscreen");
gInnerDoc = gOuterDoc.getElementById("innerFrame").contentDocument;
window.addEventListener("MozDOMFullscreen:NewOrigin", secondEntry, false);
gInnerDoc.defaultView.focus();
gInnerDoc.body.requestFullscreen();
}
function secondEntry(event) {
is(event.target, gInnerDoc, "Second MozDOMFullscreen:NewOrigin should be targeted at inner doc");
ok(gInnerDoc.fullscreenElement != null, "Inner doc should be in fullscreen");
window.removeEventListener("MozDOMFullscreen:NewOrigin", secondEntry, false);
window.addEventListener("MozDOMFullscreen:NewOrigin", thirdEntry, false);
gInnerDoc.exitFullscreen();
}
function thirdEntry(event) {
is(event.target, gOuterDoc, "Third MozDOMFullscreen:NewOrigin should be targeted at outer doc");
ok(gOuterDoc.fullscreenElement != null, "Outer doc return to fullscreen after cancel fullscreen in inner doc");
window.removeEventListener("MozDOMFullscreen:NewOrigin", thirdEntry, false);
window.removeEventListener("MozDOMFullscreen:Exited", earlyExit, false);
window.addEventListener("MozDOMFullscreen:Exited", lastExit, false);
gOuterDoc.exitFullscreen();
}
function earlyExit(event) {
ok(false, "MozDOMFullscreen:Exited should only be triggered after cancel all fullscreen");
}
function lastExit(event) {
is(event.target, gOuterDoc, "MozDOMFullscreen:Exited should be targeted at the last exited doc");
ok(gOuterDoc.fullscreenElement == null, "Fullscreen should have been fully exited");
window.opener.wrappedJSObject.done();
}
function start() {
SimpleTest.waitForFocus(
function() {
gBrowser = document.getElementById("browser");
gOuterDoc = gBrowser.contentDocument;
gBrowser.contentWindow.focus();
window.addEventListener("MozDOMFullscreen:Entered", firstEntry, false);
window.addEventListener("MozDOMFullscreen:NewOrigin", firstEntry, false);
gOuterDoc.body.requestFullscreen();
});
}
]]>
</script>
<browser type="content" id="browser" width="400" height="400" src="file_MozDomFullscreen.html"/>
</window>

View file

@ -0,0 +1,57 @@
<html id="t13">
<body id="inner-document">
<input id="t19" value="Input" accesskey="b">
<input id="t14" tabindex="2" type="password" value="test">
<button id="t20">Button</button>
<div style="float: left; margin-top: 30px;">
<button id="t21">Button 2</button>
</div>
<div id="abs" style="position: absolute; top: 40px; left: 250px;">
<button id="t22" accesskey="c">Button 3</button>
<p><span>
<select id="t15" tabindex="2" accesskey="e">
<option>One
</select>
</span></p>
</div>
<div id="t16" tabindex="2" style="overflow: scroll; max-height: 20px;">
This is a scrollable area with some sufficiently long text contained within it.
</div>
<img id="n5" src="happy.png"/>
<img id="t23" tabindex="0" src="happy.png"/>
<a id="t17" tabindex="2" accesskey="f">1</a>
<a id="t24" tabindex="0" href="#">2</a>
<a id="t25" href="#">Link 3</a>
<br>
<span id="hiddenspan" style="display: none;"></span>
<input id="t26" tabindex="0" type="checkbox" accesskey="a">
<input id="o11" tabindex="-1" type="checkbox">
<div style="display: none;"><input/></div>
<div id="t27" style="overflow: scroll; max-height: 20px;">
This is a scrollable area with some sufficiently long text contained within it.
This is a scrollable area with some sufficiently long text contained within it.
<button id="inscroll" tabindex="-1">Button 4</button>
</div>
<map name="map1">
<area id="t31" href="#" shape="rect" coords="0,0,5,5">
<area id="t32" href="#" shape="rect" coords="10,10,15,15">
<area id="t18" href="#" shape="circle" coords="0,8,4" tabindex="2">Button 5</area>
<area id="t33" href="#" shape="poly" coords="10,1,16,3,14,10,7,10,10,1">
</map>
<input type="hidden"/>
<fieldset style="float: right;">
<legend id="legend">Options</legend>
<input id="t28" type="radio" name="options" value="optionone">One
<label id="ad" accesskey="d">Label:<input id="t29" type="radio" name="options" value="optiontwo">Two</label>
</fieldset>
<div id="t30" tabindex="0">abc</div>
<input id="o18" accesskey="u" disabled size="3"/>
<label id="ag" accesskey="g" for="n6">L</label>
<input id="n6" tabindex="-1" type="button"/>
<span id="n7" accesskey="t">s</span>
<img id="image" src="data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%18%00%00%00%18%02%03%00%00%00%9D%19%D5k%00%00%00%04gAMA%00%00%B1%8F%0B%FCa%05%00%00%00%0CPLTE%FF%FF%FF%FF%FF%FF%F7%DC%13%00%00%00%03%80%01X%00%00%00%01tRNS%08N%3DPT%00%00%00%01bKGD%00%88%05%1DH%00%00%00%09pHYs%00%00%0B%11%00%00%0B%11%01%7Fd_%91%00%00%00%07tIME%07%D2%05%0C%14%0C%0D%D8%3F%1FQ%00%00%00%5CIDATx%9C%7D%8E%CB%09%C0%20%10D%07r%B7%20%2F%E9wV0%15h%EA%D9%12D4%BB%C1x%CC%5C%1E%0C%CC%07%C0%9C0%9Dd7()%C0A%D3%8D%E0%B8%10%1DiCHM%D0%AC%D2d%C3M%F1%B4%E7%FF%10%0BY%AC%25%93%CD%CBF%B5%B2%C0%3Alh%CD%AE%13%DF%A5%F7%E0%03byW%09A%B4%F3%E2%00%00%00%00IEND%AEB%60%82"
usemap="#map1" ismap>
</body>
</html>

View file

@ -0,0 +1,90 @@
[DEFAULT]
skip-if = os == 'android'
support-files =
489127.html
DOMWindowCreated_chrome.xul
DOMWindowCreated_content.html
MozDomFullscreen_chrome.xul
child_focus_frame.html
file_DOM_element_instanceof.xul
file_MozDomFullscreen.html
file_bug799299.xul
file_bug800817.xul
file_bug830858.xul
file_bug1224790-1_modal.xul
file_bug1224790-1_nonmodal.xul
file_bug1224790-2_modal.xul
file_bug1224790-2_nonmodal.xul
file_subscript_bindings.js
focus_frameset.html
focus_window2.xul
fullscreen.xul
queryCaretRectUnix.html
queryCaretRectWin.html
selectAtPoint.html
sizemode_attribute.xul
window_activation.xul
window_callback_wrapping.xul
window_docshell_swap.xul
window_focus.xul
window_focus_docnav.xul
!/dom/tests/mochitest/general/file_clonewrapper.html
!/dom/tests/mochitest/general/file_moving_nodeList.html
!/dom/tests/mochitest/general/file_moving_xhr.html
!/dom/tests/mochitest/geolocation/network_geolocation.sjs
[test_DOMWindowCreated.xul]
[test_DOM_element_instanceof.xul]
[test_activation.xul]
tags = fullscreen
[test_bug799299.xul]
[test_bug800817.xul]
[test_bug830396.xul]
[test_bug830858.xul]
[test_bug1224790-1.xul]
tags = openwindow
# synthesizeNativeOSXClick does not work on 10.6
skip-if = os != 'mac' || os_version == '10.6'
[test_bug1224790-2.xul]
tags = openwindow
# synthesizeNativeOSXClick does not work on 10.6
skip-if = os != 'mac' || os_version == '10.6'
[test_callback_wrapping.xul]
[test_clonewrapper.xul]
[test_cyclecollector.xul]
[test_docshell_swap.xul]
[test_focus.xul]
skip-if = os == 'linux' && !debug # bug 1296622
[test_focus_docnav.xul]
[test_focus_switchbinding.xul]
[test_focused_link_scroll.xul]
[test_fullscreen.xul]
tags = fullscreen
# disabled on linux for timeouts--bug-867745
skip-if = os == 'linux'
[test_geolocation.xul]
[test_indexedSetter.html]
[test_moving_nodeList.xul]
[test_moving_xhr.xul]
[test_MozDomFullscreen_event.xul]
tags = fullscreen
# disabled on OS X for intermittent failures--bug-798848
skip-if = toolkit == 'cocoa'
[test_nodesFromRect.html]
[test_parsingMode.html]
[test_popup_blocker_chrome.xul]
[test_queryCaretRect.html]
[test_resize_move_windows.xul]
# disabled on linux for timeouts--bug-834716
skip-if = os == 'linux'
[test_sandbox_bindings.xul]
[test_sandbox_eventhandler.xul]
[test_sandbox_image.xul]
[test_sandbox_postMessage.html]
[test_selectAtPoint.html]
[test_sizemode_attribute.xul]
tags = fullscreen
skip-if = os != 'win'
[test_subscript_bindings.xul]
[test_xray_event_constructor.xul]
[test_clipboard_events_chrome.html]

View file

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<window title="Mozilla Bug 824917"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<iframe type="content"></iframe>
<script type="application/javascript">
<![CDATA[
/** Test for Bug 799299 **/
var SimpleTest = opener.wrappedJSObject.SimpleTest;
var ok = opener.wrappedJSObject.ok;
var doc = frames[0].document;
ok(doc.createElement("body") instanceof HTMLBodyElement,
"Should be instance of HTMLBodyElement");
ok(doc.createElement("div") instanceof HTMLDivElement,
"Should be instance of HTMLDivElement");
ok(doc.createElement("frameset") instanceof HTMLFrameSetElement,
"Should be instance of HTMLFrameSetElement");
ok(doc.createElement("h1") instanceof HTMLHeadingElement,
"Should be instance of HTMLHeadingElement");
ok(doc.createElement("label") instanceof HTMLLabelElement,
"Should be instance of HTMLLabelElement");
window.close();
opener.wrappedJSObject.SimpleTest.finish();
]]>
</script>
</window>

View file

@ -0,0 +1,8 @@
<html>
<head>
</head>
<body style="background-color: blue;">
<p>Outer doc</p>
<iframe id="innerFrame" src="http://mochi.test:8888/"></iframe>
</body>
</html>

View file

@ -0,0 +1,33 @@
<?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=1224790
-->
<dialog title="Mozilla Bug 1224790"
buttons="accept"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.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[
/** Test for Bug 1224790 **/
function runTests() {
window.openDialog('file_bug1224790-1_nonmodal.xul', '', 'dialog=no');
}
function nonModalClosed() {
window.close();
opener.wrappedJSObject.modalClosed();
}
SimpleTest.waitForFocus(runTests);
]]>
</script>
</dialog>

View file

@ -0,0 +1,28 @@
<?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=1224790
-->
<window title="Mozilla Bug 1224790"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.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[
/** Test for Bug 1224790 **/
function runTests() {
window.close();
opener.wrappedJSObject.nonModalClosed();
}
SimpleTest.waitForFocus(runTests);
]]>
</script>
</window>

View file

@ -0,0 +1,35 @@
<?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=1224790
-->
<dialog title="Mozilla Bug 1224790"
buttons="accept"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.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[
/** Test for Bug 1224790 **/
var nonModal = null;
function runTests() {
nonModal = window.openDialog('file_bug1224790-2_nonmodal.xul', '', 'dialog=no');
}
function nonModalOpened() {
window.close();
nonModal.wrappedJSObject.modalClosed(opener);
}
SimpleTest.waitForFocus(runTests);
]]>
</script>
</dialog>

View file

@ -0,0 +1,46 @@
<?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=1224790
-->
<window title="Mozilla Bug 1224790"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.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[
/** Test for Bug 1224790 **/
function runTests() {
opener.wrappedJSObject.nonModalOpened()
}
function modalClosed(grandparent) {
// Request cycle collection to trigger destructor for parent modal window,
// that mutates mAncestorLink of this window.
const Ci = Components.interfaces;
const Cu = Components.utils;
var { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
var windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils);
Services.obs.notifyObservers(null, "child-cc-request", null);
windowUtils.cycleCollect();
// Wait for a while.
setTimeout(function() {
window.close();
grandparent.wrappedJSObject.nonModalClosed();
}, 3000);
}
SimpleTest.waitForFocus(runTests);
]]>
</script>
</window>

View file

@ -0,0 +1,66 @@
<?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=799299
-->
<window title="Mozilla Bug 799299"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" 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=799299"
target="_blank">Mozilla Bug 799299</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 799299 **/
function sendClick(win) {
var wu = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
}
function runTests() {
var b1 = document.getElementById("b1");
var b2 = document.getElementById("b2");
b1.contentWindow.focus();
opener.wrappedJSObject.is(document.activeElement, b1,
"Focused first iframe");
var didCallDummy = false;
b2.contentWindow.addEventListener("mousedown", function(e) { didCallDummy = true; });
sendClick(b2.contentWindow);
opener.wrappedJSObject.ok(didCallDummy, "dummy mousedown handler should fire");
opener.wrappedJSObject.is(document.activeElement, b2,
"Focus shifted to second iframe");
b1.contentWindow.focus();
opener.wrappedJSObject.is(document.activeElement, b1,
"Re-focused first iframe for the first time");
var didCallListener = false;
b2.contentWindow.addEventListener("mousedown", function(e) { didCallListener = true; e.preventDefault(); });
sendClick(b2.contentWindow);
opener.wrappedJSObject.ok(didCallListener, "mousedown handler should fire");
opener.wrappedJSObject.is(document.activeElement, b2,
"focus should move to the second iframe");
window.close();
opener.wrappedJSObject.SimpleTest.finish();
}
SimpleTest.waitForFocus(runTests);
]]>
</script>
<hbox flex="1">
<browser id="b1" type="content" src="about:blank" flex="1" style="border: 1px solid black;"/>
<browser id="b2" type="content" src="about:blank" flex="1" style="border: 1px solid black;"/>
</hbox>
</window>

View file

@ -0,0 +1,80 @@
<?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=800817
-->
<window title="Mozilla Bug 800817"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" 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=800817"
target="_blank">Mozilla Bug 800817</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 800817 **/
function sendClick(win) {
var wu = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
}
function runTests() {
var b1 = document.getElementById("b1");
var b2 = document.getElementById("b2");
var testMozBrowser = opener.wrappedJSObject.testMozBrowser;
if (testMozBrowser) {
b1.setAttribute("mozbrowser", "true");
b2.setAttribute("mozbrowser", "true");
}
if (testMozBrowser)
opener.wrappedJSObject.info("Testing with mozbrowser=true");
else
opener.wrappedJSObject.info("Testing without mozbrowser");
b1.contentWindow.focus();
opener.wrappedJSObject.is(document.activeElement, b1,
"Focused first iframe");
var didCallDummy = false;
b2.contentWindow.addEventListener("mousedown", function(e) { didCallDummy = true; });
sendClick(b2.contentWindow);
opener.wrappedJSObject.ok(didCallDummy, "dummy mousedown handler should fire");
opener.wrappedJSObject.is(document.activeElement, b2,
"Focus shifted to second iframe");
b1.contentWindow.focus();
opener.wrappedJSObject.is(document.activeElement, b1,
"Re-focused first iframe for the first time");
var didCallListener = false;
b2.contentWindow.addEventListener("mousedown", function(e) { didCallListener = true; e.preventDefault(); });
sendClick(b2.contentWindow);
opener.wrappedJSObject.ok(didCallListener, "mousedown handler should fire");
opener.wrappedJSObject.is(document.activeElement, b1,
"Did not move focus to the second iframe");
window.close();
opener.wrappedJSObject.finishedTests();
}
SimpleTest.waitForFocus(runTests);
]]>
</script>
<iframe xmlns="http://www.w3.org/1999/xhtml"
id="b1" type="content" src="about:blank"
style="width: 300px; height: 550px; border: 1px solid black;"/>
<iframe xmlns="http://www.w3.org/1999/xhtml"
id="b2" type="content" src="about:blank"
style="width: 300px; height: 550px; border: 1px solid black;"/>
</window>

View file

@ -0,0 +1,67 @@
<?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=830858
-->
<window title="Mozilla Bug 830858"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" 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=830858"
target="_blank">Mozilla Bug 830858</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 830858 **/
function runTests() {
var b = document.getElementById("b");
var win = b.contentWindow;
var doc = win.document;
var wu = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
var docListenerCalled = 0;
doc.addEventListener("foo", function() { ++docListenerCalled; }, true);
var winListenerCalled = 0;
win.addEventListener("foo", function() { ++winListenerCalled; }, true);
var iframeListenerCalled = 0;
b.addEventListener("foo", function() { ++iframeListenerCalled; }, true);
doc.dispatchEvent(new Event("foo"));
opener.wrappedJSObject.is(docListenerCalled, 1, "Normal dispatch to Document");
opener.wrappedJSObject.is(winListenerCalled, 1, "Normal dispatch to Document");
opener.wrappedJSObject.is(iframeListenerCalled, 1, "Normal dispatch to Document");
win.dispatchEvent(new Event("foo"));
opener.wrappedJSObject.is(docListenerCalled, 1, "Normal dispatch to Window");
opener.wrappedJSObject.is(winListenerCalled, 2, "Normal dispatch to Window");
opener.wrappedJSObject.is(iframeListenerCalled, 2, "Normal dispatch to Window");
wu.dispatchEventToChromeOnly(doc, new Event("foo"));
opener.wrappedJSObject.is(docListenerCalled, 1, "Chrome-only dispatch to Document");
opener.wrappedJSObject.is(winListenerCalled, 2, "Chrome-only dispatch to Document");
opener.wrappedJSObject.is(iframeListenerCalled, 3, "Chrome-only dispatch to Document");
wu.dispatchEventToChromeOnly(win, new Event("foo"));
opener.wrappedJSObject.is(docListenerCalled, 1, "Chrome-only dispatch to Window");
opener.wrappedJSObject.is(winListenerCalled, 2, "Chrome-only dispatch to Window");
opener.wrappedJSObject.is(iframeListenerCalled, 4, "Chrome-only dispatch to Window");
window.close();
opener.wrappedJSObject.finishedTests();
}
SimpleTest.waitForFocus(runTests);
]]>
</script>
<iframe xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="b" type="content" src="about:blank"
style="width: 300px; height: 550px; border: 1px solid black;"/>
</window>

View file

@ -0,0 +1 @@
new window.XMLHttpRequest();

View file

@ -0,0 +1,26 @@
<html id="outer">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
if (opener)
SimpleTest.waitForFocus(() => opener.framesetWindowLoaded(window));
// Don't try to call finish() in this frame, since it will get upset that we
// ran no tests.
SimpleTest.waitForExplicitFinish();
</script>
<frameset rows="30%, 70%">
<frame src="data:text/html,&lt;html id='f1' &gt;&lt;body id='framebody1'&gt;&lt;input id='f2'&gt;&lt;body&gt;&lt;/html&gt;">
<frameset cols="30%, 33%, 34%">
<frame src="data:text/html,&lt;html id='f3'&gt;&lt;body id='framebody2'&gt;&lt;input id='f4'&gt;&lt;body&gt;&lt;/html&gt;">
<frame src="data:text/html,&lt;html id='f5'&gt;&lt;body id='framebody3'&gt;&lt;input id='f6' tabindex='2'&gt;&lt;body&gt;&lt;/html&gt;">
<frame src="data:text/html,&lt;html id='f7'&gt;&lt;body id='framebody4'&gt;&lt;input id='f8'&gt;&lt;body&gt;&lt;/html&gt;">
</frameset>
<noframes>
<input id="unused1"/>
<input id="unused2" tabindex="1"/>
</noframes>
</frameset>
</html>

View file

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window id="other-document"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
<![CDATA[
function focused()
{
if (window.arguments)
setTimeout(() => window.arguments[0](window, window.arguments[1]), 0);
}
SimpleTest.waitForFocus(focused);
]]>
</script>
<button id="other" label="OK"/>
<textbox id="other-textbox" value="test"/>
</window>

View file

@ -0,0 +1,27 @@
<?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"?>
<!--
Test for fullscreen sizemode in chrome
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
sizemode="fullscreen">
<script>
window.addEventListener("fullscreen", onFullScreen, true);
function onFullScreen(event)
{
window.opener.wrappedJSObject.done(window.fullScreen);
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<button id="find-button" label="Find"/>
<button id="cancel-button" label="Cancel"/>
</body>
</window>

View file

@ -0,0 +1,214 @@
<!DOCTYPE HTML>
<html>
<head>
<title>nsIDOMWindowUtils::sendQueryContentEvent w/QUERY_CARET_RECT test</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<style>
#text {
position: absolute;
left: 0em;
top: 0em;
font-size: 10pt;
font-family: monospace;
line-height: 20px;
letter-spacing: 0px;
margin-top:-1px; /* nix the text area border */
overflow: hidden;
width:800px;
height:400px;
}
#div-hor {
position: absolute;
left: 0em;
border-top:1px solid lightgray;
width: 1000px;
pointer-events:none;
}
#div-ver {
position: absolute;
top: 0em;
border-left:1px solid lightgray;
height: 500px;
pointer-events:none;
}
</style>
<script type="application/javascript;version=1.8">
var SimpleTest = window.opener.SimpleTest;
var Ci = Components.interfaces;
function ok() { window.opener.ok.apply(window.opener, arguments); }
function done() { window.opener.done.apply(window.opener, arguments); }
function dumpLn() {
for (let idx = 0; idx < arguments.length; idx++)
dump(arguments[idx] + " ");
dump("\n");
}
// drawn grid is 20x20
function drawGrid() {
for (var idx = 0; idx < 20; idx++) {
var e = document.createElement("div");
e.setAttribute("id", "div-hor");
e.style.top = (idx*20) + "px";
document.getElementById("container").appendChild(e);
}
for (var idx = 0; idx < 40; idx++) {
var e = document.createElement("div");
e.setAttribute("id", "div-ver");
e.style.left = (idx*20) + "px";
document.getElementById("container").appendChild(e);
}
}
function getSelection(aElement) {
if (aElement instanceof Ci.nsIDOMNSEditableElement) {
return aElement.QueryInterface(Ci.nsIDOMNSEditableElement)
.editor.selection;
}
return null;
}
function testCaretPosition(aDomWinUtils, aOffset, aRectDims) {
let rect = aDomWinUtils.sendQueryContentEvent(
aDomWinUtils.QUERY_CARET_RECT,
aOffset, 0, 0, 0,
aDomWinUtils.QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK);
ok(rect, "rect returned");
ok(rect.succeeded, "call succeeded");
info("left:" + rect.left + " top:" + rect.top);
ok(rect.left > aRectDims.min.left, "rect.left > " + aRectDims.min.left);
ok(rect.left < aRectDims.max.left, "rect.left < " + aRectDims.max.left);
ok(rect.top > aRectDims.min.top, "rect.top > " + aRectDims.min.top);
ok(rect.top < aRectDims.max.top, "rect.top < " + aRectDims.max.top);
}
function doTest() {
let domWinUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let text = document.getElementById("text");
text.focus();
let textrect = text.getBoundingClientRect();
let cp = document.caretPositionFromPoint(10, 395);
let input = cp.offsetNode;
let offset = cp.offset;
input.selectionStart = input.selectionEnd = offset;
let selection = getSelection(text);
testCaretPosition(domWinUtils, input.selectionStart, {
min: { left: 5, top: 380 },
max: { left: 25, top: 390 },
});
testCaretPosition(domWinUtils, input.selectionEnd, {
min: { left: 5, top: 380 },
max: { left: 25, top: 390 },
});
testCaretPosition(domWinUtils, text.selectionStart, {
min: { left: 5, top: 380 },
max: { left: 25, top: 390 },
});
testCaretPosition(domWinUtils, text.selectionEnd, {
min: { left: 5, top: 380 },
max: { left: 25, top: 390 },
});
testCaretPosition(domWinUtils, selection.anchorOffset, {
min: { left: 5, top: 380 },
max: { left: 25, top: 390 },
});
testCaretPosition(domWinUtils, selection.focusOffset, {
min: { left: 5, top: 380 },
max: { left: 25, top: 390 },
});
cp = document.caretPositionFromPoint(395, 395);
input = cp.offsetNode;
offset = cp.offset;
input.selectionStart = input.selectionEnd = offset;
selection = getSelection(text);
testCaretPosition(domWinUtils, input.selectionStart, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
testCaretPosition(domWinUtils, input.selectionEnd, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
testCaretPosition(domWinUtils, text.selectionStart, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
testCaretPosition(domWinUtils, text.selectionEnd, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
testCaretPosition(domWinUtils, selection.anchorOffset, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
testCaretPosition(domWinUtils, selection.focusOffset, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
done();
}
</script>
<body onload="doTest()">
<textarea id="text" wrap="on">
Alice was beginning to get very tired of sitting by her sister on the bank,
and of having nothing to do: once or twice she had peeped into the book
her sister was reading, but it had no pictures or conversations in it,
`and what is the use of a book,' thought Alice `without pictures or
conversation?'
So she was considering in her own mind (as well as she could, for the
hot day made her feel very sleepy and stupid), whether the pleasure of
making a daisy-chain would be worth the trouble of getting up and
picking the daisies, when suddenly a White Rabbit with pink In another
moment down went Alice after it, never once considering how in the world
she was to get out again.
The rabbit-hole went straight on like a tunnel for some way, and then
dipped suddenly down, so suddenly that Alice had not a moment to think
about stopping herself before she found herself falling down a very deep
well.
Either the well was very deep, or she fell very slowly, for she had
plenty of time as she went down to look about her and to wonder what was
going to happen next. First, she tried to look down and make out what
she was coming to, but it was too dark to see anything; then she looked
at the sides of the well, and noticed that they were filled with
cupboards and book-shelves; here and there she saw maps and pictures
hung upon pegs. She took down a jar from one of the shelves as she
passed; it was labelled `ORANGE MARMALADE', but to her great
disappointment it was empty: she did not like to drop the jar for fear
of killing somebody, so managed to put it into one of the cupboards as
she fell past it.
</textarea>
<div id="container"></div>
</body>
</html>

View file

@ -0,0 +1,223 @@
<!DOCTYPE HTML>
<html>
<head>
<title>nsIDOMWindowUtils::sendQueryContentEvent w/QUERY_CARET_RECT test</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<!--
#########################################################
# WARNING: this file has Windows line endings. If you
# update this file please maintain them. Line endings are
# taken into account when calculating query caret rect
# values.
#########################################################
-->
<style>
#text {
position: absolute;
left: 0em;
top: 0em;
font-size: 10pt;
font-family: monospace;
line-height: 20px;
letter-spacing: 0px;
margin-top:-1px; /* nix the text area border */
overflow: hidden;
width:800px;
height:400px;
}
#div-hor {
position: absolute;
left: 0em;
border-top:1px solid lightgray;
width: 1000px;
pointer-events:none;
}
#div-ver {
position: absolute;
top: 0em;
border-left:1px solid lightgray;
height: 500px;
pointer-events:none;
}
</style>
<script type="application/javascript;version=1.8">
var SimpleTest = window.opener.SimpleTest;
var Ci = Components.interfaces;
function ok() { window.opener.ok.apply(window.opener, arguments); }
function done() { window.opener.done.apply(window.opener, arguments); }
function dumpLn() {
for (let idx = 0; idx < arguments.length; idx++)
dump(arguments[idx] + " ");
dump("\n");
}
// drawn grid is 20x20
function drawGrid() {
for (var idx = 0; idx < 20; idx++) {
var e = document.createElement("div");
e.setAttribute("id", "div-hor");
e.style.top = (idx*20) + "px";
document.getElementById("container").appendChild(e);
}
for (var idx = 0; idx < 40; idx++) {
var e = document.createElement("div");
e.setAttribute("id", "div-ver");
e.style.left = (idx*20) + "px";
document.getElementById("container").appendChild(e);
}
}
function getSelection(aElement) {
if (aElement instanceof Ci.nsIDOMNSEditableElement) {
return aElement.QueryInterface(Ci.nsIDOMNSEditableElement)
.editor.selection;
}
return null;
}
function testCaretPosition(aDomWinUtils, aOffset, aRectDims) {
let rect = aDomWinUtils.sendQueryContentEvent(
aDomWinUtils.QUERY_CARET_RECT,
aOffset, 0, 0, 0,
aDomWinUtils.QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK);
ok(rect, "rect returned");
ok(rect.succeeded, "call succeeded");
info("left:" + rect.left + " top:" + rect.top);
ok(rect.left > aRectDims.min.left, "rect.left > " + aRectDims.min.left);
ok(rect.left < aRectDims.max.left, "rect.left < " + aRectDims.max.left);
ok(rect.top > aRectDims.min.top, "rect.top > " + aRectDims.min.top);
ok(rect.top < aRectDims.max.top, "rect.top < " + aRectDims.max.top);
}
function doTest() {
let domWinUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let text = document.getElementById("text");
text.focus();
let textrect = text.getBoundingClientRect();
let cp = document.caretPositionFromPoint(10, 395);
let input = cp.offsetNode;
let offset = cp.offset;
input.selectionStart = input.selectionEnd = offset;
let selection = getSelection(text);
testCaretPosition(domWinUtils, input.selectionStart, {
min: { left: 10, top: 380 },
max: { left: 25, top: 390 },
});
testCaretPosition(domWinUtils, input.selectionEnd, {
min: { left: 10, top: 380 },
max: { left: 25, top: 390 },
});
testCaretPosition(domWinUtils, text.selectionStart, {
min: { left: 10, top: 380 },
max: { left: 25, top: 390 },
});
testCaretPosition(domWinUtils, text.selectionEnd, {
min: { left: 10, top: 380 },
max: { left: 25, top: 390 },
});
testCaretPosition(domWinUtils, selection.anchorOffset, {
min: { left: 10, top: 380 },
max: { left: 25, top: 390 },
});
testCaretPosition(domWinUtils, selection.focusOffset, {
min: { left: 10, top: 380 },
max: { left: 25, top: 390 },
});
cp = document.caretPositionFromPoint(395, 395);
input = cp.offsetNode;
offset = cp.offset;
input.selectionStart = input.selectionEnd = offset;
selection = getSelection(text);
testCaretPosition(domWinUtils, input.selectionStart, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
testCaretPosition(domWinUtils, input.selectionEnd, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
testCaretPosition(domWinUtils, text.selectionStart, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
testCaretPosition(domWinUtils, text.selectionEnd, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
testCaretPosition(domWinUtils, selection.anchorOffset, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
testCaretPosition(domWinUtils, selection.focusOffset, {
min: { left: 390, top: 380 },
max: { left: 400, top: 390 },
});
done();
}
</script>
<body onload="doTest()">
<textarea id="text" wrap="on">
Alice was beginning to get very tired of sitting by her sister on the bank,
and of having nothing to do: once or twice she had peeped into the book
her sister was reading, but it had no pictures or conversations in it,
`and what is the use of a book,' thought Alice `without pictures or
conversation?'
So she was considering in her own mind (as well as she could, for the
hot day made her feel very sleepy and stupid), whether the pleasure of
making a daisy-chain would be worth the trouble of getting up and
picking the daisies, when suddenly a White Rabbit with pink In another
moment down went Alice after it, never once considering how in the world
she was to get out again.
The rabbit-hole went straight on like a tunnel for some way, and then
dipped suddenly down, so suddenly that Alice had not a moment to think
about stopping herself before she found herself falling down a very deep
well.
Either the well was very deep, or she fell very slowly, for she had
plenty of time as she went down to look about her and to wonder what was
going to happen next. First, she tried to look down and make out what
she was coming to, but it was too dark to see anything; then she looked
at the sides of the well, and noticed that they were filled with
cupboards and book-shelves; here and there she saw maps and pictures
hung upon pegs. She took down a jar from one of the shelves as she
passed; it was labelled `ORANGE MARMALADE', but to her great
disappointment it was empty: she did not like to drop the jar for fear
of killing somebody, so managed to put it into one of the cupboards as
she fell past it.
</textarea>
<div id="container"></div>
</body>
</html>

View file

@ -0,0 +1,281 @@
<!DOCTYPE HTML>
<html>
<head>
<title>nsIDOMWindowUtils::selectAtPoint test</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript;version=1.8">
var SimpleTest = window.opener.SimpleTest;
var Ci = Components.interfaces;
function ok() { window.opener.ok.apply(window.opener, arguments); }
function done() { window.opener.done.apply(window.opener, arguments); }
function dumpLn() {
for (let idx = 0; idx < arguments.length; idx++)
dump(arguments[idx] + " ");
dump("\n");
}
function getCharacterDims() {
let span = document.getElementById("measure");
let rect = span.getBoundingClientRect();
return { width: rect.right - rect.left,
height: rect.bottom - rect.top };
}
function setStart(aDWU, aX, aY, aSelectType)
{
// Clear any existing selection
let selection = document.getSelection();
selection.removeAllRanges();
// Select text
let result = aDWU.selectAtPoint(aX, aY, aSelectType);
ok(result == true, "selectAtPoint secceeded?");
}
function setEnd(aDWU, aX, aY, aSelectType)
{
// Select text
let result = aDWU.selectAtPoint(aX, aY, aSelectType);
ok(result == true, "selectAtPoint secceeded?");
}
function setSingle(aDWU, aX, aY, aSelectType, aSelectTypeStr, aExpectedSelectionText) {
// Clear any existing selection
let selection = document.getSelection();
selection.removeAllRanges();
// Select text
let result = aDWU.selectAtPoint(aX, aY, aSelectType);
ok(result == true, "selectAtPoint secceeded?");
}
function checkSelection(aDoc, aSelectTypeStr, aExpectedSelectionText) {
// Retrieve text selected
let selection = aDoc.getSelection();
let text = selection.toString();
// Test
let result = (text == aExpectedSelectionText);
ok(result, aSelectTypeStr + " selection text matches?");
if (!result) {
dumpLn(aSelectTypeStr + " selection text:", "[" + text + "] expected:[" + aExpectedSelectionText + "]" );
}
}
function doTest() {
let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let os = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime).OS;
let isLinux = (os == "Linux");
let isMac = (os == "Darwin");
let isWindows = (os == "WINNT");
if (!isLinux && !isMac && !isWindows) {
done();
return;
}
window.scrollTo(0, 0);
// Trick to get character spacing - get the bounds around a
// single character trapped in a div.
let charDims = getCharacterDims();
// dumpLn("character dims:", charDims.width, charDims.height);
//
// Root frame selection
//
// First div in the main page
let div = document.getElementById("div1");
let rect = div.getBoundingClientRect();
// Centered on the first character in the sentence div
let targetPoint = { xPos: rect.left + (charDims.width / 2),
yPos: rect.top + (charDims.height / 2) };
setSingle(dwu, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_WORDNOSPACE);
checkSelection(document, "SELECT_WORDNOSPACE", "ttestselection1");
setSingle(dwu, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_WORD);
if (isLinux || isMac) {
checkSelection(document, "SELECT_WORD", "ttestselection1");
} else if (isWindows) {
checkSelection(document, "SELECT_WORD", "ttestselection1 ");
}
setSingle(dwu, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_PARAGRAPH);
checkSelection(document, "SELECT_PARAGRAPH", "ttestselection1 Lorem ipsum dolor sit amet, at duo debet graeci, vivendum vulputate per ut. Ne labore incorrupte vix. Cu copiosae postulant tincidunt ius, in illud appetere contentiones eos. Ei munere officiis assentior pro, nibh decore ius at.");
// Centered on the second character in the sentence div
targetPoint = { xPos: rect.left + (charDims.width + (charDims.width / 2)),
yPos: rect.top + (charDims.height / 2) };
setSingle(dwu, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_CHARACTER);
checkSelection(document, "SELECT_CHARACTER", "te");
setSingle(dwu, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_CLUSTER);
checkSelection(document, "SELECT_CLUSTER", "te");
// Separate character blocks in a word 't(te)s(ts)election1'
targetPoint = { xPos: rect.left + (charDims.width + (charDims.width / 2)),
yPos: rect.top + (charDims.height / 2) };
setStart(dwu, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_CHARACTER);
targetPoint = { xPos: rect.left + ((charDims.width * 4) + (charDims.width / 2)),
yPos: rect.top + (charDims.height / 2) };
setEnd(dwu, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_CHARACTER);
if (isLinux || isMac) {
// XXX I think this is a bug, the right hand selection is 4.5 characters over with a
// monspaced font. what we want: t(te)s(ts)election1 what we get: t(te)st(se)lection1
checkSelection(document, "split selection", "tese");
} else if (isWindows) {
checkSelection(document, "split selection", "tets");
}
// Trying to select where there's no text, should fail but not throw
let result = dwu.selectAtPoint(rect.left - 20, rect.top - 20, Ci.nsIDOMWindowUtils.SELECT_CHARACTER, false);
ok(result == false, "couldn't select?");
// Second div in the main page
div = document.getElementById("div2");
rect = div.getBoundingClientRect();
// Centered on the first line, first character in the paragraph div
targetPoint = { xPos: rect.left + (charDims.width / 2),
yPos: rect.top + (charDims.height / 2) };
setSingle(dwu, targetPoint.xPos + 50, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_PARAGRAPH);
checkSelection(document, "SELECT_PARAGRAPH", "Lorem ipsum dolor sit amet, at duo debet graeci, vivendum vulputate per ut. Ne labore incorrupte vix. Cu copiosae postulant tincidunt ius, in illud appetere contentiones eos.");
//
// Inner IFRAME selection tests
//
let frame = document.getElementById("frame1");
let dwuFrame = frame.contentDocument
.defaultView
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
frame.contentWindow.scrollTo(0, 0);
rect = frame.getBoundingClientRect();
targetPoint = { xPos: charDims.width / 2,
yPos: charDims.height / 2 };
setSingle(dwuFrame, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_WORDNOSPACE);
checkSelection(frame.contentWindow.document, "SELECT_WORDNOSPACE", "ttestselection2");
setSingle(dwuFrame, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_WORD);
if (isLinux || isMac) {
checkSelection(frame.contentWindow.document, "SELECT_WORD", "ttestselection2");
} else if (isWindows) {
checkSelection(frame.contentWindow.document, "SELECT_WORD", "ttestselection2 ");
}
setSingle(dwuFrame, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_PARAGRAPH);
checkSelection(frame.contentWindow.document, "SELECT_PARAGRAPH", "ttestselection2 Lorem ipsum dolor sit amet, at duo debet graeci, vivendum vulputate per ut.");
// Outside the frame should throw. This is a failure in coordinate setup of
// nsDOMWindowUtils::SelectAtPoint.
let thr = false;
try {
dwuFrame.selectAtPoint(rect.right + 50, rect.top, Ci.nsIDOMWindowUtils.SELECT_WORD, false);
} catch (ex) { thr = true; }
ok(thr == true, "selectAtPoint expected throw?");
done();
}
let frameLoad = false;
let pageLoad = false;
let painted = false;
function testReady() {
if (frameLoad && pageLoad && painted)
doTest();
}
function onFrameLoad() {
// Exit the onload handler before trying the test, because we need
// to ensure that paint unsupression has happened.
setTimeout(function() {
frameLoad = true;
testReady();
}, 0);
}
function onPageLoad() {
// Exit the onload handler before trying the test, because we need
// to ensure that paint unsupression has happened
// XXXroc why do we need to separately test for the loading of the frame
// and a paint? That should not be necessary for this test.
setTimeout(function() {
pageLoad = true;
testReady();
}, 0);
}
function onPaint() {
window.removeEventListener("MozAfterPaint", onPaint, false);
painted = true;
testReady();
}
window.addEventListener("MozAfterPaint", onPaint, false);
</script>
<style type="text/css">
body {
font-family: monospace;
margin-left: 40px;
margin-top: 40px;
padding: 0;
}
#div1 {
border: 1px solid red;
width: 400px;
height: 100px;
}
#frame1 {
display: block;
height: 100px;
width: 300px;
border: 1px solid blue;
padding: 0;
margin: 0;
}
#div2 {
border: 1px solid green;
}
#measure {
padding: 0px;
margin: 0px;
border: 1px solid red;
}
</style>
</head>
<body id="body" onload="onPageLoad();">
<div id="div1">ttestselection1 Lorem ipsum dolor sit amet, at duo debet graeci, vivendum vulputate per ut. Ne labore incorrupte vix. Cu copiosae postulant tincidunt ius, in illud appetere contentiones eos. Ei munere officiis assentior pro, nibh decore ius at.</div>
<br />
<iframe id="frame1" src="data:text/html,<html><body style='margin: 0; padding: 0; font-family: monospace;' onload='window.parent.onFrameLoad();'><div id='sel2'>ttestselection2 Lorem ipsum dolor sit amet, at duo debet graeci, vivendum vulputate per ut.</div><br/><br/></body></html>"></iframe>
<br/>
<div id="div2">Lorem ipsum dolor sit amet, at duo debet graeci, vivendum vulputate per ut. Ne labore incorrupte vix. Cu copiosae postulant tincidunt ius, in illud appetere contentiones eos.</div>
<br />
<span id="measure">t</span>
</body>
</html>

View file

@ -0,0 +1,87 @@
<?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"?>
<!--
Test for fullscreen sizemode in chrome
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
persist="sizemode"
sizemode="normal"
onload="nextStep()">
<script type="text/javascript;version=1.8">
let tests = [
function test1() {
checkAndContinue("normal");
},
function test2() {
listen("fullscreen", () => checkAndContinue("fullscreen"));
window.fullScreen = true;
},
function test3() {
listen("fullscreen", () => checkAndContinue("normal"));
window.fullScreen = false;
},
function test4() {
listen("resize", () => checkAndContinue("maximized"));
window.maximize();
},
function test5() {
listen("fullscreen", () => checkAndContinue("fullscreen"));
window.fullScreen = true;
},
function test6() {
listen("fullscreen", () => checkAndContinue("maximized"));
window.fullScreen = false;
},
function test7() {
listen("resize", () => checkAndContinue("normal"));
window.restore();
},
function test8() {
window.opener.wrappedJSObject.done();
}
];
function nextStep() {
tests.shift()();
}
function listen(event, fn) {
window.addEventListener(event, function listener() {
window.removeEventListener(event, listener, false);
fn();
}, false);
}
function checkAndContinue(sizemode) {
let windowStates = {
"fullscreen": window.STATE_FULLSCREEN,
"normal": window.STATE_NORMAL,
"maximized": window.STATE_MAXIMIZED
};
setTimeout(function() {
is(window.document.documentElement.getAttribute("sizemode"), sizemode, "sizemode attribute should match actual window state");
is(window.fullScreen, sizemode == "fullscreen", "window.fullScreen should match actual window state");
is(window.windowState, windowStates[sizemode], "window.sizeMode should match actual window state");
nextStep();
}, 0);
}
let is = window.opener.wrappedJSObject.is;
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
</body>
</window>

View file

@ -0,0 +1,29 @@
<?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"?>
<!--
Test for Persistent Storage in chrome
-->
<window id="sample-window" width="400" height="400"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/chrome-harness.js"></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>
<script>
SimpleTest.waitForExplicitFinish();
var root = getRootDirectory(window.location.href);
window.open(root + "DOMWindowCreated_chrome.xul", "_blank", "chrome,width=600,height=550");
</script>
</window>

View file

@ -0,0 +1,34 @@
<?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=824917
-->
<window title="Mozilla Bug 824917"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" 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=824917"
target="_blank">Mozilla Bug 824917</a>
</body>
<iframe type="content"></iframe>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 824917 **/
function runTests() {
window.open("file_DOM_element_instanceof.xul", "_blank", "chrome,width=600,height=550");
}
addLoadEvent(runTests);
SimpleTest.waitForExplicitFinish();
]]>
</script>
</window>

View file

@ -0,0 +1,56 @@
<?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"?>
<!--
Test that "MozShowFullScreenWarning" is dispatched to chrome on restricted keypress.
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" width="400" height="400">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
// Ensure the full-screen api is enabled, and will be disabled on test exit.
var gPrevEnabled = SpecialPowers.getBoolPref("full-screen-api.enabled");
var gPrevTrusted = SpecialPowers.getBoolPref("full-screen-api.allow-trusted-requests-only");
var newwindow;
var Cc = Components.classes;
var Ci = Components.interfaces;
function make_uri(url) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return ios.newURI(url, null, null);
}
// Ensure "fullscreen" permissions are not present on the test URI.
var pm = Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager);
var uri = make_uri("http://mochi.test:8888");
var ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
var principal = ssm.createCodebasePrincipal(uri, {});
pm.removeFromPrincipal(principal, "fullscreen");
SpecialPowers.pushPrefEnv({"set": [
['full-screen-api.enabled', true],
['full-screen-api.allow-trusted-requests-only', false],
['full-screen-api.transition-duration.enter', '0 0'],
['full-screen-api.transition-duration.leave', '0 0']
]}, setup);
function setup() {
newwindow = window.open("MozDomFullscreen_chrome.xul", "_blank","chrome,resizable=yes,width=400,height=400");
}
function done()
{
newwindow.close();
SimpleTest.finish();
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
</window>

View file

@ -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"?>
<?xml-stylesheet href="data:text/css,
%23box {
background: blue;
}
%23box:-moz-window-inactive {
background: cyan;
}
" type="text/css"?>
<!--
Test for the :-moz-window-inactive pseudoclass
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
sizemode="fullscreen">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<box id="box" height="100"/>
<script>
SimpleTest.waitForExplicitFinish();
newwindow = window.open("window_activation.xul", "_blank","chrome,width=300,height=200");
function complete()
{
newwindow.close();
SimpleTest.finish();
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
</window>

View file

@ -0,0 +1,71 @@
<?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=1224790
-->
<window title="Mozilla Bug 1224790"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 1224790 **/
/*
* 1. Opens modal dialog
* 2. Open non-modal window from modal dialog
* 3. Close non-modal window
* 4. Close modal dialog
* 5. Click button to ensure mouse event is working
*/
function startTest() {
window.openDialog('file_bug1224790-1_modal.xul', '', 'modal');
}
function modalClosed() {
SimpleTest.waitForFocus(gotFocus);
}
var timer = null;
function gotFocus() {
var button = document.getElementById('button');
synthesizeMouseAtCenter(button, { type: 'mousemove' }, window);
function click() {
// The bug is not reproducible with synthesizeMouseAtCenter.
// Need to emulate native mouse event.
synthesizeNativeOSXClick(button.boxObject.screenX + button.boxObject.width / 2,
button.boxObject.screenY + button.boxObject.height / 2);
}
click();
// On debug build, it's possible that the click event handler is not
// triggered by the first click in case the click is dispatched too early
// before Firefox gets ready for input.
// Click the button again after 1 sec when we don't get click event.
timer = setTimeout(click, 1000);
}
function onClick() {
if (timer) {
// Avoid clicking unrelated thing.
clearTimeout(timer);
}
ok(true, "Click event should be fired");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(startTest);
]]>
</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=1224790"
target="_blank">Mozilla Bug 1224790</a>
</body>
<button id="button" label="button" oncommand="onClick()" />
</window>

View file

@ -0,0 +1,72 @@
<?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=1224790
-->
<window title="Mozilla Bug 1224790"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 1224790 **/
/*
* 1. Opens modal dialog
* 2. Open non-modal window from modal dialog
* 3. Close modal dialog
* 4. Wait for a while for destructor for modal dialog
* 5. Close non-modal window
* 6. Click button to ensure mouse event is working
*/
function startTest() {
window.openDialog('file_bug1224790-2_modal.xul', '', 'modal');
}
function nonModalClosed() {
SimpleTest.waitForFocus(gotFocus);
}
var timer = null;
function gotFocus() {
var button = document.getElementById('button');
synthesizeMouseAtCenter(button, { type: 'mousemove' }, window);
function click() {
// The bug is not reproducible with synthesizeMouseAtCenter.
// Need to emulate native mouse event.
synthesizeNativeOSXClick(button.boxObject.screenX + button.boxObject.width / 2,
button.boxObject.screenY + button.boxObject.height / 2);
}
click();
// On debug build, it's possible that the click event handler is not
// triggered by the first click in case the click is dispatched too early
// before Firefox gets ready for input.
// Click the button again after 1 sec when we don't get click event.
timer = setTimeout(click, 1000);
}
function onClick() {
if (timer) {
// Avoid clicking unrelated thing.
clearTimeout(timer);
}
ok(true, "Click event should be fired");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(startTest);
]]>
</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=1224790"
target="_blank">Mozilla Bug 1224790</a>
</body>
<button id="button" label="button" oncommand="onClick()" />
</window>

View file

@ -0,0 +1,31 @@
<?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=799299
-->
<window title="Mozilla Bug 799299" onload="runTests()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" 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=799299"
target="_blank">Mozilla Bug 799299</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 799299 **/
function runTests() {
window.open("file_bug799299.xul", "_blank", "chrome,width=600,height=550");
}
SimpleTest.waitForExplicitFinish();
]]>
</script>
</window>

View file

@ -0,0 +1,43 @@
<?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=800817
-->
<window title="Mozilla Bug 800817" onload="runTests()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" 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=800817"
target="_blank">Mozilla Bug 800817</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 800817 **/
var testMozBrowser = false;
function runTests() {
// Run a first round of tests for non-mozbrowser iframes.
window.open("file_bug800817.xul", "_blank", "chrome,width=600,height=550");
}
function finishedTests() {
if (!testMozBrowser) {
testMozBrowser = true;
// Run a second round of tests for mozbrowser iframes.
window.open("file_bug800817.xul", "_blank", "chrome,width=600,height=550");
} else {
SimpleTest.finish();
}
}
SimpleTest.waitForExplicitFinish();
]]>
</script>
</window>

View file

@ -0,0 +1,39 @@
<?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=830396
-->
<window title="Mozilla Bug 830396"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script class="testbody" type="application/javascript">
<![CDATA[
function runTests()
{
var doc = frames[0].document;
var cs = doc.defaultView.getComputedStyle(doc.body);
var nsIDOMCSSValueList = Components.interfaces.nsIDOMCSSValueList;
ok(cs.getPropertyCSSValue("cursor") instanceof nsIDOMCSSValueList,
"CSSValueList should be a nsIDOMCSSValueList");
SimpleTest.finish();
}
]]>
</script>
<body onload="runTests();" xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=830396">Mozilla Bug 830396</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<iframe type="content"></iframe>
</body>
</window>

View file

@ -0,0 +1,36 @@
<?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=830858
-->
<window title="Mozilla Bug 830858"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="runTests()">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 830858 **/
function runTests() {
window.open("file_bug830858.xul", "_blank", "chrome,width=600,height=550");
}
function finishedTests() {
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
]]>
</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=830858"
target="_blank">Mozilla Bug 830858</a>
</body>
</window>

View file

@ -0,0 +1,22 @@
<?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=742222
-->
<window title="Mozilla Bug 742222"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" 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=742222"
target="_blank">Mozilla Bug 742222</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
window.open("window_callback_wrapping.xul");
</script>
</window>

View file

@ -0,0 +1,63 @@
<html>
<body onload="runTest()">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script>
// This test checks that the dom.event.clipboardevents.enabled does not apply to chrome shells.
SimpleTest.waitForExplicitFinish();
function runTest()
{
SpecialPowers.pushPrefEnv({"set": [['dom.event.clipboardevents.enabled', false]]}, function() {
window.open("data:text/html,<body onload='window.opener.doChecks(this)'><input id='i' value='Sample Text'></body>",
"_blank", "chrome,width=200,height=200");
});
}
var event_fired = false;
function doChecks(win)
{
var windowFocused = function() {
var textbox = win.document.getElementById("i");
textbox.value = "Sample Text";
textbox.oncut = function() { event_fired = true; };
textbox.oncopy = function() { event_fired = true; };
textbox.onpaste = function() { event_fired = true; };
textbox.select();
textbox.focus();
textbox.setSelectionRange(1, 4);
synthesizeKey("x", {accelKey: 1}, win);
is(textbox.value, "Sle Text", "cut changed text when preference is disabled");
ok(event_fired, "cut event fired when preference is disabled")
event_fired = false;
textbox.setSelectionRange(4, 6);
synthesizeKey("c", {accelKey: 1}, win);
is(textbox.value, "Sle Text", "cut changed text when preference is disabled");
ok(event_fired, "copy event fired when preference is disabled")
event_fired = false;
textbox.setSelectionRange(1, 4);
synthesizeKey("v", {accelKey: 1}, win);
is(textbox.value, "STeText", "paste changed text when preference is disabled");
ok(event_fired, "paste event fired when preference is disabled")
win.close();
SimpleTest.finish();
}
SimpleTest.waitForFocus(windowFocused, win);
}
</script>
<p id="display"></p>
</body></html>

View file

@ -0,0 +1,117 @@
<?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=667388
-->
<window title="Mozilla Bug 667388"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
// Setup.
const Cu = Components.utils;
SimpleTest.waitForExplicitFinish();
window.testObject = { myNumber: 42,
myDomain: window.location.domain };
// Wait for both frames to load before proceeding.
var framesLoaded = [null, false, false, false];
function onFrameLoaded(id) {
// Mark this frame as loaded.
framesLoaded[id] = true;
// Allow it to call various helpers.
window.frames[id].wrappedJSObject.is = is;
window.frames[id].wrappedJSObject.ok = ok;
window.frames[id].wrappedJSObject.info = info;
// If all the frames are loaded, start the test.
if (framesLoaded[1] && framesLoaded[2] && framesLoaded[3])
startTest();
}
function reject(e) {
ok(false, "Rejected Promise: " + e);
SimpleTest.finish();
}
function startTest() {
runChromeContentTest(window.frames[1]).then(
runContentContentTest.bind(null, window.frames[1], window.frames[2],
true, "Should be able to clone same-origin"), reject).then(
runContentContentTest.bind(null, window.frames[2], window.frames[3],
false, "Should not be able to clone cross-origin"), reject).then(function() {
// Colaborate with document.domain, then try again.
frames[2].document.domain = 'example.org';
frames[3].document.domain = 'example.org';
return runContentContentTest(window.frames[2], window.frames[3],
true, "Should be able to clone cross-origin with document.domain")
}, reject).then(SimpleTest.finish.bind(SimpleTest), reject);
}
// Tests cloning between chrome and content.
function runChromeContentTest(contentWin) {
// We should be able to clone a content object.
tryToClone(contentWin.wrappedJSObject.testObject,
true,
"Chrome should be able to clone content object");
return Promise.resolve();
}
// Test cloning between content and content.
//
// Note - the way we do this is kind of sketchy. Because we're grabbing the
// test object from win1 by waiving Xray (via .wrappedJSObject), the object
// we're passing from win1 to win2 is actually the waived object (which has
// a distinct identity in the compartment of win2). So this means that we're
// actually giving win2 Xray waivers to win1! This doesn't affect things as
// long as the security wrappers check documentDomainMakesSameOrigin directly
// for the puncture case rather than checking IsTransparent(), but it still
// gives rise to a situation that wouldn't really happen in practice.
function runContentContentTest(win1, win2, shouldSucceed, msg) {
var p = win1.wrappedJSObject.tryToClone(win2.wrappedJSObject.testObject,
shouldSucceed, msg);
if (!shouldSucceed)
return;
return new Promise(function(resolve) {
p.then(function(cloneResult) {
is(Cu.waiveXrays(cloneResult).toSource(), win2.wrappedJSObject.testObject.toSource(),
"Clone should create an identical object");
resolve();
});
});
}
function tryToClone(obj, shouldSucceed, message) {
var success = false;
var sink = window.frames[0];
try { sink.postMessage(obj, '*'); success = true; }
catch (e) { message = message + ' (threw: ' + e.message + ')'; }
is(success, shouldSucceed, message);
}
]]>
</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=667388"
target="_blank">Mozilla Bug 667388</a>
<iframe id="sink" />
<!-- The first two are same-origin, the third is not. -->
<iframe id="frame1" onload="onFrameLoaded(1);" src="http://test1.example.org/tests/dom/tests/mochitest/general/file_clonewrapper.html" />
<iframe id="frame2" onload="onFrameLoaded(2);" src="http://test1.example.org/tests/dom/tests/mochitest/general/file_clonewrapper.html" />
<iframe id="frame3" onload="onFrameLoaded(3);" src="http://test2.example.org/tests/dom/tests/mochitest/general/file_clonewrapper.html" />
</body>
</window>

View file

@ -0,0 +1,55 @@
<?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=
-->
<window title="Mozilla Bug "
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" 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="
target="_blank">Mozilla Bug </a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug **/
let Ci = Components.interfaces;
var obs = Components.classes["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
var didCall = false;
var observer = {
QueryInterface: function QueryInterface(aIID) {
if (aIID.equals(Ci.nsIObserver) ||
aIID.equals(Ci.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
observe: function(subject, topic, data) {
obs.removeObserver(observer, "cycle-collector-begin");
observer = null;
didCall = true;
}
};
// Start an incremental GC, to make sure that calling ccSlice
// when an IGC is running finishes the GC.
SpecialPowers.Cu.getJSTestingFunctions().gcslice(1);
// Make sure that we call the observer even if we're in the middle
// of an ICC when we add the observer. See bug 981033.
SpecialPowers.finishCC();
SpecialPowers.ccSlice(1);
obs.addObserver(observer, "cycle-collector-begin", false);
SpecialPowers.DOMWindowUtils.cycleCollect();
ok(didCall, "Observer should have been called!");
]]>
</script>
</window>

View file

@ -0,0 +1,74 @@
<?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"?>
<window title="Docshell swap test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.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();
// Create two identical windows, each with a <browser> element.
let win1 = window.openDialog("window_docshell_swap.xul", "_blank","chrome,width=300,height=200");
let win2 = window.openDialog("window_docshell_swap.xul", "_blank","chrome,width=300,height=200");
let loadCount = 0;
function loadHandler() {
loadCount++;
if (loadCount < 2)
return;
let browser1 = win1.document.getElementById("browser");
let browser2 = win2.document.getElementById("browser");
let flo1 = browser1.QueryInterface(Components.interfaces.nsIFrameLoaderOwner);
let flo2 = browser2.QueryInterface(Components.interfaces.nsIFrameLoaderOwner);
let pongCount = 0;
function gotPong(target_ok) {
pongCount++;
ok(target_ok, "message went to correct target");
if (pongCount == 1) {
win1.close();
win2.close();
SimpleTest.finish();
}
}
let mm1 = flo1.frameLoader.messageManager;
let mm2 = flo2.frameLoader.messageManager;
// Swap docshells. Everything should be identical to before, since there was nothing to
// distinguish these docshells.
flo1.swapFrameLoaders(flo2);
// mm1 shouldn't change here, but we update it in case it does due to a bug.
mm1 = flo1.frameLoader.messageManager;
// Load ping-pong code into first window.
mm1.loadFrameScript("data:,addMessageListener('ping', () => sendAsyncMessage('pong'));", false);
// A pong message received in win1 means success.
win1.messageManager.addMessageListener("pong", () => { gotPong(true); });
// A pong message received in win2 means failure!
win2.messageManager.addMessageListener("pong", () => { gotPong(false); });
// Send the ping to win1.
mm1.sendAsyncMessage("ping");
}
win1.addEventListener("load", loadHandler, false);
win2.addEventListener("load", loadHandler, false);
]]>
</script>
</window>

View file

@ -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 title="Focus Tests"
onload="setTimeout(runTest, 0);"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script>
if (navigator.platform.startsWith("Win")) {
SimpleTest.expectAssertions(0, 1);
}
SimpleTest.waitForExplicitFinish();
function runTest()
{
window.open("window_focus.xul", "_blank", "chrome,width=600,height=550");
}
</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>

View file

@ -0,0 +1,28 @@
<?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 onload="runTest();"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script>
SimpleTest.waitForExplicitFinish();
function runTest()
{
window.open("window_focus_docnav.xul", "_blank", "chrome,width=600,height=550");
}
</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>

View file

@ -0,0 +1,57 @@
<?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="Focus Switch Binding Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script>
SimpleTest.waitForExplicitFinish();
function switchBinding()
{
$("box").style.MozBinding = "url(#second)";
}
</script>
<xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<xbl:binding id="first">
<xbl:content>
<xul:button label="First"/>
</xbl:content>
<xbl:implementation>
<xbl:constructor>
document.getAnonymousNodes(this)[0].focus();
setTimeout(switchBinding, 0);
</xbl:constructor>
</xbl:implementation>
</xbl:binding>
<xbl:binding id="second">
<xbl:content>
<xul:button label="Second"/>
</xbl:content>
<xbl:implementation>
<xbl:constructor>
$("after").focus();
</xbl:constructor>
</xbl:implementation>
</xbl:binding>
</xbl:bindings>
<box id="box" style="-moz-binding: url(#first)"/>
<button id="after" label="After" onfocus="is(document.activeElement, $('after'), 'focus set'); SimpleTest.finish()"/>
<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>

View file

@ -0,0 +1,48 @@
<?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="Focus Scroll Tests"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<body xmlns="http://www.w3.org/1999/xhtml">
<div id="div" style="width:500px;height:48px;overflow:auto;font-size:16px;line-height:16px;">
aaaaaaaaa<br/>bbbbbbbb<br/>
<a href="about:blank;" id="a">ccccccccc<br/>ddddddddd</a>
</div>
<p id="display">
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<script>
SimpleTest.waitForExplicitFinish();
function runTest()
{
var fm = Components.classes["@mozilla.org/focus-manager;1"].
getService(Components.interfaces.nsIFocusManager);
var div = document.getElementById('div');
var a = document.getElementById('a');
synthesizeMouse(a, 4, 4, { type: "mousedown" }, window);
is(fm.focusedElement, a,
"The anchor element isn't set focus by the mouse down event");
is(div.scrollTop, 0,
"The div element was scrolled by the mouse down event");
SimpleTest.finish();
}
SimpleTest.waitForFocus(runTest);
</script>
</window>

View file

@ -0,0 +1,37 @@
<?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"?>
<!--
Test for fullscreen sizemode in chrome
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
sizemode="fullscreen">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
newwindow = window.open("fullscreen.xul", "_blank","chrome,resizable=yes");
function done()
{
// because we are cancelling the fullscreen event, it
// takes a bit for the fullScreen property to be set
setTimeout("complete()", 0);
}
function complete()
{
ok(newwindow.fullScreen, "window.fullScreen is true.");
newwindow.close();
SimpleTest.finish();
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
</window>

View file

@ -0,0 +1,35 @@
<?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"?>
<!--
Test for Geolocation in chrome
-->
<window id="sample-window" width="400" height="400"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
var Ci = Components.interfaces;
var Cc = Components.classes;
var geolocation = Cc["@mozilla.org/geolocation;1"].getService(Ci.nsISupports);
geolocation.getCurrentPosition(done, error);
function error(error)
{
ok(0, "error occured trying to get geolocation from chrome");
SimpleTest.finish();
}
function done(position)
{
ok(position, "geolocation was found from chrome");
SimpleTest.finish();
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
</window>

View file

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=715156
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 715156</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
/** Test for Bug 715156 **/
function runTests() {
var doc = document.getElementById("testFrame").contentDocument;
var options = doc.createElement("select").options;
ok(Components.utils.isXrayWrapper(options), "should be an Xray wrapper");
var option = doc.createElement("option");
options[4] = option;
is(options.length, 5, "setting an indexed property through an Xray wrapper should work")
is(options[4], option, "setting an indexed property through an Xray wrapper should work")
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(runTests);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=715156">Mozilla Bug 715156</a>
<p id="display"></p>
<iframe id="testFrame"></iframe>
<pre id="test">
</pre>
</body>
</html>

View file

@ -0,0 +1,45 @@
<?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=684115
-->
<window title="Mozilla Bug 684115"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></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=654370"
target="_blank">Mozilla Bug 684115</a>
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
var firstWindow, secondWindow;
function iframe_loaded() {
if (!firstWindow || !secondWindow)
return;
var nodeList = firstWindow.document.childNodes;
ok(!("expando" in nodeList), "shouldn't be able to see expandos on the NodeList");
nodeList = firstWindow.wrappedJSObject.getNodeList();
ok(("expando" in nodeList), "should be able to see expandos on the NodeList");
options = firstWindow.wrappedJSObject.getOptions();
is(options.selectedIndex, -1, "can access selectedIndex in chrome");
secondWindow.wrappedJSObject.tryToUseNodeList(nodeList, ok);
nodeList = document.childNodes;
secondWindow.wrappedJSObject.tryToUseNodeList(nodeList, ok);
SimpleTest.finish();
}
]]></script>
<iframe id="one" src="http://mochi.test:8888/tests/dom/tests/mochitest/general/file_moving_nodeList.html"
onload="firstWindow = this.contentWindow; iframe_loaded()" />
<iframe id="two" src="http://example.org/tests/dom/tests/mochitest/general/file_moving_nodeList.html"
onload="secondWindow = this.contentWindow; iframe_loaded()" />
</window>

View file

@ -0,0 +1,41 @@
<?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=684115
-->
<window title="Mozilla Bug 684115"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></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=654370"
target="_blank">Mozilla Bug 684115</a>
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
var firstWindow, secondWindow;
function iframe_loaded() {
if (!firstWindow || !secondWindow)
return;
var xhr = firstWindow.wrappedJSObject.createXHR();
ok(("expando" in xhr), "should be able to see expandos on the XHR");
is(xhr.readyState, XMLHttpRequest.UNSENT, "can access readyState in chrome");
secondWindow.wrappedJSObject.tryToUseXHR(xhr, ok);
secondWindow.wrappedJSObject.tryToUseXHR(new XMLHttpRequest(), ok);
SimpleTest.finish();
}
]]></script>
<iframe id="one" src="http://mochi.test:8888/tests/dom/tests/mochitest/general/file_moving_xhr.html"
onload="firstWindow = this.contentWindow; iframe_loaded()" />
<iframe id="two" src="http://example.org/tests/dom/tests/mochitest/general/file_moving_xhr.html"
onload="secondWindow = this.contentWindow; iframe_loaded()" />
</window>

View file

@ -0,0 +1,21 @@
<!DOCTYPE HTML>
<html>
<head>
<title>nsIDOMWindowUtils::nodesFromRect test - bug 489127</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
function done() {
testwindow.close();
SimpleTest.finish();
}
var testwindow = window.open("489127.html", '_new', 'width=600,height=400');
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</body>
</html>

View file

@ -0,0 +1,67 @@
<!DOCTYPE HTML>
<html>
<head>
<title>CSSStyleSheet parsingMode test - bug 1230491</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
function run() {
const Cc = Components.classes;
const Ci = Components.interfaces;
const sss = Cc["@mozilla.org/content/style-sheet-service;1"]
.getService(Ci.nsIStyleSheetService);
const domutils = Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(Ci.inIDOMUtils);
const utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
const userUrl = encodeURI("data:text/css,body { color: seagreen; }");
utils.loadSheetUsingURIString(userUrl, sss.USER_SHEET);
const agentUrl = encodeURI("data:text/css,body { color: tomato; }");
utils.loadSheetUsingURIString(agentUrl, sss.AGENT_SHEET);
const authorUrl = "chrome://mochikit/content/tests/SimpleTest/test.css";
let results = [];
for (let sheet of domutils.getAllStyleSheets(document)) {
if (sheet.href === agentUrl) {
is(sheet.parsingMode, "agent", "agent sheet has expected mode");
results[sss.AGENT_SHEET] = 1;
} else if (sheet.href === userUrl) {
is(sheet.parsingMode, "user", "user sheet has expected mode");
results[sss.USER_SHEET] = 1;
} else if (sheet.href === authorUrl) {
is(sheet.parsingMode, "author",
"author sheet has expected mode");
results[sss.AUTHOR_SHEET] = 1;
} else if (sheet.href === "about:PreferenceStyleSheet") {
is(sheet.parsingMode, "agent",
"about:PreferenceStyleSheet has agent mode");
continue;
} else {
// Ignore sheets we don't care about.
continue;
}
// Check that re-parsing preserves the mode.
let mode = sheet.parsingMode;
domutils.parseStyleSheet(sheet, "body { color: chartreuse; }");
is(sheet.parsingMode, mode,
"check that re-parsing preserved mode " + mode);
}
ok(results[sss.AGENT_SHEET] && results[sss.USER_SHEET] &&
results[sss.AUTHOR_SHEET],
"all sheets seen");
SimpleTest.finish();
}
</script>
</head>
<body onload="run()">
<div> What? </div>
</body>
</html>

View file

@ -0,0 +1,54 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=662519
-->
<window title="Mozilla Bug 662519"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></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=662519"
target="_blank">Mozilla Bug 662519</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 662519 **/
SimpleTest.waitForExplicitFinish();
// We have to enable dom.disable_open_during_load which is disabled
// by the test harness.
let prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var gLastDomLoadValue = prefs.getBoolPref("dom.disable_open_during_load");
prefs.setBoolPref("dom.disable_open_during_load", true);
let w = window.open("data:text/html,foobar", "", "width=200,height=200");
ok(w, "The window object shouldn't be null");
SimpleTest.waitForFocus(function() {
w.close();
ok(true, "The popup appeared");
SimpleTest.waitForFocus(function() {
let w = window.open("data:text/html,foobar", "", "width=200,height=200");
ok(w, "The window object shouldn't be null");
SimpleTest.waitForFocus(function() {
w.close();
ok(true, "The popup appeared");
prefs.setBoolPref("dom.disable_open_during_load", gLastDomLoadValue);
SimpleTest.finish();
}, w, false);
});
}, w, false);
]]>
</script>
</window>

View file

@ -0,0 +1,22 @@
<!DOCTYPE HTML>
<html>
<head>
<title>nsIDOMWindowUtils::sendQueryContentEvent w/QUERY_CARET_RECT test</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
function done() {
testwindow.close();
SimpleTest.finish();
}
var isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
var testwindow = window.open("queryCaretRect" + (isWindows ? "Win" : "Unix") + ".html",
"_new", "width=800,height=800");
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</body>
</html>

View file

@ -0,0 +1,282 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=565541
-->
<window title="Mozilla Bug 565541"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></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=565541"
target="_blank">Mozilla Bug 565541</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 565541 **/
var previousX, previousY, previousWidth, previousHeight;
function backValues()
{
previousX = window.top.screenX;
previousY = window.top.screenY;
previousWidth = window.top.innerWidth;
previousHeight = window.top.innerHeight;
}
function restoreValues()
{
window.top.screenX = previousX;
window.top.screenY = previousY;
window.top.innerWidth = previousWidth;
window.top.innerHeight = previousHeight;
}
function getNewWidth(aWindow)
{
return (aWindow.innerWidth > (screen.width / 2)) ? 100 : screen.width;
}
function getNewHeight(aWindow)
{
return (aWindow.innerHeight > (screen.height / 2)) ? 100 : screen.height;
}
function getNewX(aWindow)
{
return (aWindow.screenX > ((screen.width - aWindow.outerWidth) / 2))
? 0 : screen.width - aWindow.outerWidth;
}
function getNewY(aWindow)
{
return (aWindow.screenY > ((screen.height - aWindow.outerHeight) / 2))
? 0 : screen.height - aWindow.outerHeight;
}
/**
* hitEventLoop is called when we want to check something but we can't rely on
* an event or a specific number of event loop hiting.
* This method can be called by specifying a condition, a test (using SimpleTest
* API), how many times the event loop has to be hitten and what to call next.
* If times < 0, the event loop will be hitten as long as the condition isn't
* true or the test doesn't time out.
*/
function hitEventLoop(condition, test, times, next) {
if (condition() || times == 0) {
test();
next();
return;
}
setTimeout(hitEventLoop, 0, condition, test, times - 1, next);
}
function checkChangeIsEnabled(aWindow, aNext)
{
// Something should happen. We are not going to go to the next test until
// it does.
var hits = -1;
var prevWidth;
var prevHeight;
var prevX;
var prevY;
var oWidth;
var oHeight;
function sizeChangeCondition() {
return aWindow.innerWidth != prevWidth && aWindow.innerHeight != prevHeight;
}
function sizeChangeTest() {
isnot(aWindow.innerWidth, prevWidth, "Window width should have changed");
isnot(aWindow.innerHeight, prevHeight, "Window height should have changed");
prevWidth = aWindow.innerWidth;
prevHeight = aWindow.innerHeight;
}
function posChangeCondition() {
// With GTK, sometimes, only one dimension changes.
if (navigator.platform.indexOf('Linux') != -1) {
return aWindow.screenX != prevX || aWindow.screenY != prevY;
}
return aWindow.screenX != prevX && aWindow.screenY != prevY;
}
function posChangeConditionIgnoreLinux() {
if (posChangeCondition()) {
return true;
}
if (navigator.platform.indexOf('Linux') != -1) {
return true;
}
}
function posChangeTest() {
// With GTK, sometimes, only one dimension changes.
if (navigator.platform.indexOf('Linux') != -1) {
// With GTK, sometimes, aWindow.screenX changes during two calls.
// So we call it once and save the returned value.
var x = aWindow.screenX;
var y = aWindow.screenY;
if (x != prevX) {
isnot(x, prevX, "Window x position should have changed");
}
if (y != prevY) {
isnot(y, prevY, "Window y position should have changed");
}
} else {
isnot(aWindow.screenX, prevX, "Window x position should have changed");
isnot(aWindow.screenY, prevY, "Window y position should have changed");
}
prevX = aWindow.screenX;
prevY = aWindow.screenY;
}
function outerChangeCondition() {
return aWindow.outerWidth != oWidth && aWindow.outerHeight != oHeight;
}
function outerChangeTest() {
isnot(aWindow.outerWidth, oWidth, "Window outerWidth should have changed");
isnot(aWindow.outerHeight, oHeight, "Window outerHeight should have changed");
aWindow.outerWidth = oWidth;
aWindow.outerHeight = oHeight;
}
/**
* Size checks.
*/
prevWidth = aWindow.innerWidth;
prevHeight = aWindow.innerHeight;
aWindow.innerWidth = getNewWidth(aWindow);
aWindow.innerHeight = getNewHeight(aWindow);
hitEventLoop(sizeChangeCondition, sizeChangeTest, hits, function () {
aWindow.resizeTo(getNewWidth(aWindow), getNewHeight(aWindow));
hitEventLoop(sizeChangeCondition, sizeChangeTest, hits, function () {
aWindow.resizeBy(getNewWidth(aWindow) - aWindow.innerWidth,
getNewHeight(aWindow) - aWindow.innerHeight);
hitEventLoop(sizeChangeCondition, sizeChangeTest, hits, function () {
prevWidth = aWindow.innerWidth = getNewWidth(aWindow);
prevHeight = aWindow.innerHeight = getNewHeight(aWindow);
aWindow.sizeToContent();
hitEventLoop(sizeChangeCondition, sizeChangeTest, hits, function () {
/**
* Position checks.
*/
prevX = aWindow.screenX;
prevY = aWindow.screenY;
aWindow.screenX = getNewX(aWindow);
aWindow.screenY = getNewY(aWindow);
hitEventLoop(posChangeCondition, posChangeTest, hits, function () {
aWindow.moveTo(getNewX(aWindow), getNewY(aWindow));
hitEventLoop(posChangeCondition, posChangeTest, hits, function () {
aWindow.moveBy(getNewX(aWindow) - aWindow.screenX,
getNewY(aWindow) - aWindow.screenY);
hitEventLoop(posChangeConditionIgnoreLinux, posChangeTest, hits, function () {
/**
* Outer width/height checks.
*/
oWidth = aWindow.outerWidth;
oHeight = aWindow.outerHeight;
aWindow.outerWidth = oWidth * 2;
aWindow.outerHeight = oHeight * 2;
hitEventLoop(outerChangeCondition, outerChangeTest, hits, aNext);
});
});
});
});
});
});
});
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
if (screen.width <= 200 || screen.height <= 200) {
todo(false, "The screen is too small to run this test.");
SimpleTest.finish();
}
backValues();
// We are in a chrome context, we can change the size and position.
checkChangeIsEnabled(window.top, function() {
// We create a window and check that the size and position can be set with
// window.open parameters and can be changed by the created window.
var w = window.open("data:text/html,<script>" +
"function check(next) {" +
" var is_range = function(aTest, aValue, aRange, aMsg) {" +
" ok(aTest < aValue + aRange && aTest > aValue - aRange, aMsg);" +
" };" +
" is_range(window.innerWidth, 170, 5, 'parameter width should be taken into account');" +
" is_range(window.innerHeight, 170, 5, 'parameter height should be taken into account');" +
" is_range(window.screenX, 25, 5, 'parameter screenX should be taken into account');" +
" is_range(window.screenY, 25, 5, 'parameter screenY should be taken into account');" +
" checkChangeIsEnabled(window, next);" +
"} <\/script>", '',
'width=170,height=170,screenX=25,screenY=25');
SimpleTest.waitForFocus(function() {
// This test relies on passing cross-origin windows to a chrome function,
// which is generally forbidden if we don't twiddle the knob below.
Components.utils.forcePermissiveCOWs();
w.wrappedJSObject.ok = SimpleTest.ok;
w.wrappedJSObject.checkChangeIsEnabled = window.checkChangeIsEnabled;
w.wrappedJSObject.check(function() {
// The current window can change the size and position of the created one.
checkChangeIsEnabled(w, function() {
w.close();
// If we call window.open with an empty string as a third parameter,
// by default, it will create a new tab instead of a new window.
// In a chrome context, the size and position can change.
w = window.open("data:text/html,<script>" +
"function check(next) {" +
" checkChangeIsEnabled(window, next);" +
"} <\/script>", '', '');
SimpleTest.waitForFocus(function() {
w.wrappedJSObject.checkChangeIsEnabled = window.checkChangeIsEnabled;
w.wrappedJSObject.check(function() {
// The current window can change the size and position of the new tab.
// Because we are in a chrome context.
checkChangeIsEnabled(w, function() {
w.close();
restoreValues();
SimpleTest.finish();
});
});
}, w, false);
});
});
}, w, false);
});
});
]]>
</script>
</window>

View file

@ -0,0 +1,318 @@
<?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=741267
-->
<window title="Mozilla Bug 741267"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript">
</script>
<iframe id="t"></iframe>
<!-- 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=741267"
target="_blank">Mozilla Bug 741267</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 741267 **/
const Cu = Components.utils;
function isXrayWrapper(x) {
return Components.utils.isXrayWrapper(x);
}
function doTest() {
var win = $("t").contentWindow;
ok(isXrayWrapper(win),
"We want to be testing things with an Xray as sandboxPrototype here");
var sandbox = Components.utils.Sandbox(win, { sandboxPrototype: win });
is(sandbox._content, undefined, "_content does nothing over Xray");
try {
var css = Components.utils.evalInSandbox("CSSStyleDeclaration", sandbox);
is(String(css.prototype), "[object CSSStyleDeclarationPrototype]",
"'CSSStyleDeclaration.prototype' in a sandbox should return the CSSStyleDeclaration interface prototype object");
} catch (e) {
ok(false, "'CSSStyleDeclaration' shouldn't throw in a sandbox");
}
try {
var et = Components.utils.evalInSandbox("EventTarget", sandbox);
ok(et, "'EventTarget' in a sandbox should return the EventTarget interface object");
ok(isXrayWrapper(et), "Getting an interface object on an Xray wrapper should return an Xray wrapper");
} catch (e) {
ok(false, "'EventTarget' shouldn't throw in a sandbox");
}
try {
var xhr = Components.utils.evalInSandbox("XMLHttpRequest.prototype", sandbox);
ok(xhr, "'XMLHttpRequest.prototype' in a sandbox should return the XMLHttpRequest interface prototype object");
ok(isXrayWrapper(xhr), "Getting an interface prototype object on an Xray wrapper should return an Xray wrapper");
ok(isXrayWrapper(xhr.constructor), "Getting the constructor property on an Xray wrapper of an interface prototype object should return an Xray wrapper");
isnot(Object.getOwnPropertyDescriptor(xhr, "send"), undefined,
"We should claim to have a send() method");
isnot(Object.keys(xhr).indexOf("responseType"), -1,
"We should claim to have a responseType property");
isnot(Object.getOwnPropertyNames(xhr).indexOf("open"), -1,
"We should claim to have an open() method");
isnot(Object.getOwnPropertyDescriptor(xhr, "constructor"), undefined,
"We should claim to have a 'constructor' property");
} catch (e) {
ok(false, "'XMLHttpRequest.prototype' shouldn't throw in a sandbox");
}
try {
var img = Components.utils.evalInSandbox("Image.prototype", sandbox);
ok(img, "'Image.prototype' in a sandbox should return the interface prototype object");
ok(isXrayWrapper(img), "Getting an interface prototype object on an Xray wrapper should return an Xray wrapper");
} catch (e) {
ok(false, "'Image.prototype' shouldn't throw in a sandbox");
}
try {
var xhr = Components.utils.evalInSandbox("XMLHttpRequest", sandbox);
xhr.prototype = "notok";
} finally {
isnot(xhr.prototype, "notok", "'XMLHttpRequest.prototype' should be readonly");
}
var constructorWritable = false;
try {
var xhr = Components.utils.evalInSandbox("XMLHttpRequest.prototype", sandbox);
xhr.constructor = "ok";
is(xhr.constructor, "ok", "'XMLHttpRequest.prototype.constructor' should be writeable");
} catch (e) {
ok(false, "'XMLHttpRequest.prototype.constructor' should be writeable");
}
try {
var xhr = Components.utils.evalInSandbox("XMLHttpRequest", sandbox);
is(String(xhr), String(XMLHttpRequest), "'XMLHttpRequest' in a sandbox should return the XMLHttpRequest interface object");
ok(isXrayWrapper(xhr.prototype), "Getting the prototype property on an Xray wrapper of an interface object should return an Xray wrapper");
isnot(Object.getOwnPropertyDescriptor(xhr, "UNSENT"), undefined,
"We should claim to have an UNSENT constant");
isnot(Object.keys(xhr).indexOf("OPENED"), -1,
"We should claim to have an OPENED constant");
isnot(Object.getOwnPropertyNames(xhr).indexOf("DONE"), -1,
"We should claim to have a DONE constant");
isnot(Object.getOwnPropertyDescriptor(xhr, "prototype"), undefined,
"We should claim to have 'prototype' property");
} catch (e) {
ok(false, "'XMLHttpRequest' shouldn't throw in a sandbox");
}
try {
var xhr = Components.utils.evalInSandbox("new XMLHttpRequest()", sandbox);
is("" + xhr, new XMLHttpRequest() + "", "'new XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
} catch (e) {
ok(false, "'new XMLHttpRequest()' shouldn't throw in a sandbox (1)");
}
try {
var xhr = Components.utils.evalInSandbox("XMLHttpRequest.toString = function () { return 'Failed'; }; XMLHttpRequest;", sandbox);
is(xhr.toString(), XMLHttpRequest + "", "XMLHttpRequest.toString in the sandbox should not override the native toString behaviour");
} catch (e) {
ok(false, "'XMLHttpRequest' shouldn't throw in a sandbox");
}
try {
var xhr = Components.utils.evalInSandbox("XMLHttpRequest.prototype.toString = function () { return 'Failed'; }; new XMLHttpRequest();", sandbox);
is(xhr.toString(), new XMLHttpRequest() + "", "XMLHttpRequest.prototype.toString in the sandbox should not override the native toString behaviour");
} catch (e) {
ok(false, "'new XMLHttpRequest()' shouldn't throw in a sandbox (2)");
}
try {
// have to run this test before document.defaultView.XMLHttpRequest
// gets munged in the sandbox.
var proto = Components.utils.evalInSandbox("XMLHttpRequest.prototype", sandbox);
props = [];
for (var i in proto) {
props.push(i);
}
isnot(props.indexOf("dispatchEvent"), -1,
"'dispatchEvent' property should be enumerable on XMLHttpRequest.prototype");
props = Object.getOwnPropertyNames(proto);
is(props.indexOf("dispatchEvent"), -1,
"'dispatchEvent' is not an own property on XMLHttpRequest.prototype; it's on EventTarget.prototype")
} catch (e) {
ok(false, "XMLHttpRequest.prototype manipulation via an Xray shouldn't throw" + e);
}
try {
Components.utils.evalInSandbox("XMLHttpRequest.prototype.a = 'expando a'", sandbox);
Components.utils.evalInSandbox("XMLHttpRequest.prototype.b = 'expando b'", sandbox);
Components.utils.evalInSandbox("XMLHttpRequest.prototype", sandbox).b = 'xrayexpando';
var xhr = Components.utils.evalInSandbox("new XMLHttpRequest()", sandbox);
is(xhr.a, undefined, "'XMLHttpRequest()' in a sandbox should not have expandos from inside the sandbox");
is(xhr.b, "xrayexpando", "'new XMLHttpRequest()' in a sandbox should have Xray expandos");
} catch (e) {
ok(false, "'new XMLHttpRequest()' shouldn't throw in a sandbox");
}
try {
Components.utils.evalInSandbox("document.defaultView.XMLHttpRequest = function() {};", sandbox);
var win = Components.utils.evalInSandbox("document.defaultView", sandbox);
var xhr = new win.XMLHttpRequest();
is("" + xhr, new XMLHttpRequest() + "", "'new XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
} catch (e) {
ok(false, "'new XMLHttpRequest()' shouldn't throw in a sandbox");
}
try {
var canvas = Components.utils.evalInSandbox("document.createElement('canvas').getContext('2d')", sandbox);
is(canvas.DRAWWINDOW_DRAW_CARET, CanvasRenderingContext2D.DRAWWINDOW_DRAW_CARET, "Constants should be defined on DOM objects in a sandbox");
} catch (e) {
ok(false, "'document.createElement('canvas').getContext('2D')' shouldn't throw in a sandbox");
}
try {
var classList = Components.utils.evalInSandbox("document.body.className = 'a b'; document.body.classList", sandbox);
is(classList.toString(), "a b", "Stringifier should be called");
} catch (e) {
ok(false, "Stringifying shouldn't throw in a sandbox");
}
try {
var ctx = Components.utils.evalInSandbox("var ctx = document.createElement('canvas').getContext('2d'); ctx.foopy = 5; ctx", sandbox);
ok(!("foopy" in ctx), "We should have an Xray here");
var data = ctx.createImageData(1, 1);
for (var i = 0; i < data.data.length; ++i) {
// Watch out for premultiplied bits... just set all the alphas to 255
if (i % 4 == 3) {
// Note - We need to waive Xrays here because indexed access on Typed
// Arrays is forbidden over Xrays for performance reasons.
Cu.waiveXrays(data.data)[i] = 255;
} else {
Cu.waiveXrays(data.data)[i] = i;
}
}
ctx.putImageData(data, 0, 0);
var data2 = ctx.getImageData(0, 0, 1, 1);
is(data2.data.length, data.data.length, "Lengths must match");
for (i = 0; i < data.data.length; ++i)
is(Cu.waiveXrays(data.data)[i], Cu.waiveXrays(data2.data)[i], "Data at " + i + " should match");
} catch (e) {
ok(false, "Imagedata manipulation via an Xray shouldn't throw " + e);
}
try {
var list = Components.utils.evalInSandbox("document.getElementsByTagName('*')", sandbox);
props = [];
for (var i in list) {
props.push(i);
}
is(props.indexOf("constructor"), -1,
"'constructor' property should not be enumerable on list object");
props = Object.getOwnPropertyNames(list);
is(props.indexOf("constructor"), -1,
"'constructor' property should not be an own property name on list object");
} catch (e) {
ok(false, "NodeList.prototype manipulation via an Xray shouldn't throw" + e);
}
try {
var proto = Components.utils.evalInSandbox("NodeList.prototype", sandbox);
props = [];
for (var i in proto) {
props.push(i);
}
is(props.indexOf("constructor"), -1,
"'constructor' property should not be enumerable on proto directly");
props = Object.getOwnPropertyNames(proto);
isnot(props.indexOf("constructor"), -1,
"'constructor' property should be an own property name on proto");
} catch (e) {
ok(false, "NodeList.prototype manipulation via an Xray shouldn't throw" + e);
}
try {
var url = Components.utils.evalInSandbox("URL", sandbox);
for (var i in url) {
url[i];
}
isnot(url.createObjectURL, undefined, "Should have a createObjectURL");
ok(true, "We didn't crash!");
} catch (e) {
ok(false, "URL interface object manipulation via an Xray shouldn't throw" + e);
}
try {
url.revokeObjectURL("");
} catch (e) {
// Just testing whether revokeObjectURL crashes us
}
ok(true, "We didn't crash!");
// And now tests that don't use a window-associated sandbox
sandbox = Components.utils.Sandbox(win.document.nodePrincipal,
{ sandboxPrototype: win });
try {
var ws = Components.utils.evalInSandbox('var ws = new WebSocket("ws://example.org"); ws', sandbox);
// Test that we actually got a WebSocket object, probably
ok("bufferedAmount" in ws, "What is this object?");
} catch (e) {
ok(false, "Should be able to create a WebSocket in a sandbox " + e);
}
try {
var es = Components.utils.evalInSandbox('var es = new EventSource("about:blank"); es', sandbox);
// Test that we actually got a EventSource object, probably
is(es.url, "about:blank", "What is this object?");
} catch (e) {
ok(false, "Should be able to create an EventSource in a sandbox " + e);
}
try {
var nodeFilterIface = Components.utils.evalInSandbox(
'NodeFilter.myExpando = "FAIL"; NodeFilter', sandbox);
is(nodeFilterIface.myExpando, undefined,
"Should have Xrays for callback interface objects");
} catch (e) {
ok(false, "Should be able to return NodeFilter from a sandbox " + e);
}
try {
var eventCtor = Components.utils.evalInSandbox("Event", sandbox);
var e = new eventCtor("test", { bubbles: true });
is(e.bubbles, true, "Dictionary argument should work");
} catch (e) {
ok(false, "Should be able to construct my event " + e);
}
try {
var elem = Components.utils.evalInSandbox('document.createElement("p")', sandbox);
elem.expando = 5;
elem.expando = 7;
is(elem.expando, 7, "Should be able to set expandos on Xrays for DOM bindings");
var doc = Components.utils.evalInSandbox('document', sandbox);
doc.expando = 5;
doc.expando = 7;
is(doc.expando, 7, "Should be able to set expandos on Xrays for DOM bindings with named properties");
} catch (e) {
ok(false, "Setting expandos on Xrays shouldn't throw " + e);
}
// Test that binding a bareword window method produces something
// which has a .call
try {
var binary = Components.utils.evalInSandbox(
'btoa.bind(window).call(null, "foo")', sandbox);
is(binary, "Zm9v", "Should get the right result from .call on bound btoa");
} catch (e) {
ok(false, ".call on bound btoa shouldn't throw " + e);
}
// Test that binding a bareword window method produces something
// which has a .apply
try {
var binary = Components.utils.evalInSandbox(
'btoa.bind(window).apply(null, ["foo"])', sandbox);
is(binary, "Zm9v", "Should get the right result from .apply on bound btoa");
} catch (e) {
ok(false, ".apply on bound btoa shouldn't throw " + e);
}
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
]]>
</script>
</window>

View file

@ -0,0 +1,38 @@
<?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=817284
-->
<window title="Mozilla Bug 817284"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" 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=817284"
target="_blank">Mozilla Bug 817284</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 817284 **/
var cu = Components.utils;
var sb = cu.Sandbox("http://example.com", { wantGlobalProperties: ["XMLHttpRequest"] });
// Test event handler calls
var xhr = cu.evalInSandbox(
'var xhr = new XMLHttpRequest();\
var called = false;\
xhr.onload = function() { called = true; };\
xhr', sb);
var e = document.createEvent("Events");
e.initEvent("load", false, false);
xhr.dispatchEvent(e);
is(cu.evalInSandbox('called', sb), true, "Event handler should have been called");
]]>
</script>
</window>

View file

@ -0,0 +1,37 @@
<?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=616397
-->
<window title="Mozilla Bug 616397"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<iframe id="t"></iframe>
<!-- 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=616397"
target="_blank">Mozilla Bug 616397</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 616397 **/
function doTest() {
var win = $("t").contentWindow;
var sandbox = Components.utils.Sandbox(win, { sandboxPrototype: win });
var result = Components.utils.evalInSandbox("new Image()", sandbox);
isnot(result, null, "Should have an image");
is(result.tagName, "IMG", "Should have the right tag name");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
]]>
</script>
</window>

View file

@ -0,0 +1,36 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Testing postMessage from sandbox</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
function doTest() {
var sandbox = Components.utils.Sandbox("http://mochi.test:8888/", { wantXrays: true });
var win = window.frames["sameDomain"];
sandbox.win = win;
sandbox.is = is;
sandbox.done = SimpleTest.finish;
result = Components.utils.evalInSandbox('var data = {some:"data"};'
+'win.addEventListener("message", receiveMessage, false);'
+'function receiveMessage(event)'
+'{'
+' is(JSON.stringify(event.data), JSON.stringify(data), "Received the expected message data");'
+' done();'
+'}'
+'win.postMessage(data, "*")'
, sandbox);
}
addLoadEvent(doTest);
</script>
</head>
<body>
<iframe src="http://mochi.test:8888/"
id="sameDomain" name="sameDomain">
</iframe>
</body>
</html>

View file

@ -0,0 +1,21 @@
<!DOCTYPE HTML>
<html>
<head>
<title>nsIDOMWindowUtils::selectAtPoint test</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
function done() {
testwindow.close();
SimpleTest.finish();
}
var testwindow = window.open("selectAtPoint.html", '_new', 'width=800,height=800');
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</body>
</html>

View file

@ -0,0 +1,26 @@
<?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"?>
<!--
Test for the sizemode attribute
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
sizemode="fullscreen">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
newwindow = window.open("sizemode_attribute.xul", "_blank","chrome,resizable=yes");
function done() {
newwindow.close();
SimpleTest.finish();
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px;"/>
</window>

View file

@ -0,0 +1,44 @@
<?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=741267
-->
<window title="Mozilla Bug 741267"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<iframe id="t"></iframe>
<!-- 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=741267"
target="_blank">Mozilla Bug 741267</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 741267 **/
function doTest() {
// Resolve XMLHttpRequest on the chrome global
new XMLHttpRequest();
var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
var context = { window: $("t").contentWindow };
var thrown = false;
try {
loader.loadSubScript(/.*\//.exec(window.location.href)[0] + "file_subscript_bindings.js", context);
} catch (e) {
thrown = true;
}
ok(!thrown, "'new window.XMLHttpRequest()' in a subscript shouldn't throw");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
]]>
</script>
</window>

View file

@ -0,0 +1,35 @@
<?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=861493
-->
<window title="Mozilla Bug 861493"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<iframe id="t" type="content"></iframe>
<!-- 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=861493"
target="_blank">Mozilla Bug 861493</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 861493 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
ok(Components.utils.isXrayWrapper($("t").contentWindow),
"Should have xray");
var e = new ($("t").contentWindow).Event("test", { bubbles: true });
is(e.bubbles, true, "Dictionary should have worked");
SimpleTest.finish();
})
]]>
</script>
</window>

View file

@ -0,0 +1,37 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="data:text/css,
%23box {
background: blue;
}
%23box:-moz-window-inactive {
background: cyan;
}
" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<box id="box" height="100"/>
<script type="application/javascript"><![CDATA[
var ok = window.opener.wrappedJSObject.ok;
var complete = window.opener.wrappedJSObject.complete;
var openerDoc = window.opener.wrappedJSObject.document;
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
SimpleTest.waitForFocus(function () {
ok(getComputedStyle(document.getElementById("box"), "").backgroundColor, "rgb(0, 0, 255)");
ok(getComputedStyle(openerDoc.getElementById("box"), "").backgroundColor, "rgb(0, 255, 255)");
window.opener.focus();
ok(getComputedStyle(document.getElementById("box"), "").backgroundColor, "rgb(0, 255, 255)");
ok(getComputedStyle(openerDoc.getElementById("box"), "").backgroundColor, "rgb(0, 0, 255)");
complete();
}, window);
]]></script>
</window>

View file

@ -0,0 +1,21 @@
<?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">
<browser type="content"
src="data:text/html,&lt;script&gt;var x = new XMLHttpRequest(); x.onreadystatechange = function() {}&lt;/script&gt;"/>
<script type="application/javascript"><![CDATA[
window.onload = function() {
var z = new XPCNativeWrapper(window.frames[0].wrappedJSObject.x).onreadystatechange;
var t = window.opener.SimpleTest;
t.ok(true, "Hey, we didn't crash");
window.close();
t.finish();
}
]]>
</script>
</window>

View file

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<browser type="content" src="about:blank" id="browser"/>
</window>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,126 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window onload="start()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<textbox id="textbox1"/>
<textbox id="textbox2"/>
<panel id="panel" onpopupshown="runTests(this, 1);"
onpopuphidden="noChildrenTest()">
<textbox id="p1textbox" value="Popup1"/>
</panel>
<panel id="panel2" onpopupshown="runTests(this, 2);" onpopuphidden="document.getElementById('panel').hidePopup()">
<textbox id="p2textbox" value="Popup2"/>
</panel>
<browser id="browser" type="content" src="focus_frameset.html" width="500" height="400"/>
<script type="application/javascript">
<![CDATA[
var fm = Components.classes["@mozilla.org/focus-manager;1"].
getService(Components.interfaces.nsIFocusManager);
function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
function noChildrenTest()
{
// Remove the browser element and test navigation when there are no other documents.
// The focus should move or stay on the first focusable element.
let browser = document.getElementById("browser");
browser.parentNode.removeChild(browser);
let textbox1 = document.getElementById("textbox1");
let textbox2 = document.getElementById("textbox2");
textbox2.focus();
next(window, textbox1.inputField, "Focus forward when no child documents");
next(window, textbox1.inputField, "Focus forward again when no child documents");
textbox2.focus();
previous(window, textbox1.inputField, "Focus backward when no child documents");
previous(window, textbox1.inputField, "Focus backward again when no child documents");
done();
}
function done()
{
var opener = window.opener;
window.close();
opener.wrappedJSObject.SimpleTest.finish();
}
function previous(expectedWindow, expectedElement, desc)
{
synthesizeKey("VK_F6", { shiftKey: true });
is(fm.focusedWindow, expectedWindow, desc);
is(fm.focusedElement, expectedElement, desc + " element");
}
function next(expectedWindow, expectedElement, desc)
{
synthesizeKey("VK_F6", { });
is(fm.focusedWindow, expectedWindow, desc);
is(fm.focusedElement, expectedElement, desc + " element" + "::" + (fm.focusedElement ? fm.focusedElement.parentNode.id : "<none>"));
}
// This test runs through three cases. Document navigation forward and
// backward using the F6 key when no popups are open, with one popup open and
// with two popups open.
function runTests(panel, popupCount)
{
if (!popupCount || popupCount > 2)
popupCount = 0;
fm.clearFocus(window);
var childwin = document.getElementById("browser").contentWindow;
if (popupCount) {
next(window, document.getElementById("p1textbox").inputField, "First into popup 1 with " + popupCount);
if (popupCount == 2) {
next(window, document.getElementById("p2textbox").inputField, "First into popup 2 with " + popupCount);
}
}
next(childwin.frames[0], childwin.frames[0].document.documentElement, "First with " + popupCount);
next(childwin.frames[1], childwin.frames[1].document.documentElement, "Second with " + popupCount);
previous(childwin.frames[0], childwin.frames[0].document.documentElement, "Second back with " + popupCount);
if (popupCount) {
if (popupCount == 2) {
previous(window, document.getElementById("p2textbox").inputField, "First back from popup 2 with " + popupCount);
}
previous(window, document.getElementById("p1textbox").inputField, "First back from popup 1 with " + popupCount);
}
previous(window, document.getElementById("textbox1").inputField, "First back with " + popupCount);
if (panel == document.getElementById("panel"))
document.getElementById("panel2").openPopup(null, "after_start", 100, 20);
else if (panel == document.getElementById("panel2"))
panel.hidePopup();
else
document.getElementById("panel").openPopup(null, "after_start");
}
function start()
{
window.opener.wrappedJSObject.SimpleTest.waitForExplicitFinish();
window.opener.wrappedJSObject.SimpleTest.waitForFocus(
function() { runTests(null, 0); },
document.getElementById("browser").contentWindow);
}
]]></script>
</window>