mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
117 lines
4.0 KiB
HTML
117 lines
4.0 KiB
HTML
|
<html>
|
||
|
<head>
|
||
|
<title>Testing Application.js</title>
|
||
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
|
||
|
</head>
|
||
|
<body>
|
||
|
<pre id="test">
|
||
|
<script class="testbody" type="text/javascript">
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
const Ci = Components.interfaces;
|
||
|
const Cc = Components.classes;
|
||
|
|
||
|
test_Browser();
|
||
|
|
||
|
function url(spec) {
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||
|
return ios.newURI(spec, null, null);
|
||
|
}
|
||
|
|
||
|
var gTabOpenCount = 0;
|
||
|
var gTabCloseCount = 0;
|
||
|
var gTabMoveCount = 0;
|
||
|
|
||
|
function test_Browser() {
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
|
||
|
var windows = Application.windows;
|
||
|
ok(windows, "Check access to browser windows");
|
||
|
ok(windows.length, "There should be at least one browser window open");
|
||
|
|
||
|
var activeWin = Application.activeWindow;
|
||
|
activeWin.events.addListener("TabOpen", onTabOpen);
|
||
|
activeWin.events.addListener("TabClose", onTabClose);
|
||
|
activeWin.events.addListener("TabMove", onTabMove);
|
||
|
|
||
|
var pageA = activeWin.open(url("http://localhost:8888/tests/browser/fuel/test/ContentA.html"));
|
||
|
var pageB = activeWin.open(url("http://localhost:8888/tests/browser/fuel/test/ContentB.html"));
|
||
|
pageB.focus();
|
||
|
|
||
|
is(activeWin.tabs.length, 3, "Checking length of 'Browser.tabs' after opening 2 additional tabs");
|
||
|
is(activeWin.activeTab.index, pageB.index, "Checking 'Browser.activeTab' after setting focus");
|
||
|
|
||
|
SimpleTest.waitForExplicitFinish();
|
||
|
setTimeout(afterOpen, 1000);
|
||
|
|
||
|
// need to wait for the url's to be refreshed during the load
|
||
|
function afterOpen() {
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
is(pageA.uri.spec, "http://localhost:8888/tests/browser/fuel/test/ContentA.html", "Checking 'BrowserTab.uri' after opening");
|
||
|
is(pageB.uri.spec, "http://localhost:8888/tests/browser/fuel/test/ContentB.html", "Checking 'BrowserTab.uri' after opening");
|
||
|
|
||
|
// check event
|
||
|
todo_is(gTabOpenCount, 2, "Checking event handler for tab open");
|
||
|
|
||
|
// test document access
|
||
|
var test1 = pageA.document.getElementById("test1");
|
||
|
ok(test1, "Checking existence of element in content DOM");
|
||
|
is(test1.innerHTML, "A", "Checking content of element in content DOM");
|
||
|
|
||
|
// test moving tab
|
||
|
pageA.moveToEnd();
|
||
|
is(pageA.index, 2, "Checking index after moving tab");
|
||
|
|
||
|
// check event
|
||
|
is(gTabMoveCount, 1, "Checking event handler for tab move");
|
||
|
|
||
|
// test loading new content into a tab
|
||
|
// the event will be checked in afterClose
|
||
|
pageA.events.addListener("load", onPageLoad);
|
||
|
pageA.load(pageB.uri);
|
||
|
}
|
||
|
|
||
|
function onPageLoad(event) {
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
is(pageA.uri.spec, "http://localhost:8888/tests/browser/fuel/test/ContentB.html", "Checking 'BrowserTab.uri' after loading new content");
|
||
|
|
||
|
// start testing closing tabs
|
||
|
pageA.close();
|
||
|
pageB.close();
|
||
|
setTimeout(afterClose, 1000);
|
||
|
}
|
||
|
|
||
|
function afterClose() {
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
// check event
|
||
|
is(gTabCloseCount, 2, "Checking event handler for tab close");
|
||
|
|
||
|
is(activeWin.tabs.length, 1, "Checking length of 'Browser.tabs' after closing 2 tabs");
|
||
|
|
||
|
SimpleTest.finish();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function onTabOpen(event) {
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
gTabOpenCount++;
|
||
|
}
|
||
|
|
||
|
function onTabClose(event) {
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
gTabCloseCount++;
|
||
|
}
|
||
|
|
||
|
function onTabMove(event) {
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
gTabMoveCount++;
|
||
|
}
|
||
|
|
||
|
</script>
|
||
|
</pre>
|
||
|
</body>
|
||
|
</html>
|