mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
9f03f90fb7
find /files/mozilla/build/d/_tests/testing/mochitest/tests/ | egrep "\.(xhtml|html|xml|js)$" | grep -v SimpleTest | grep -vi mochikit | grep -v simpleThread | grep -v test_ipc_messagemanager_blob.html | grep -v "indexedDB/test" | xargs grep -l Components | xargs grep -L enablePrivilege | perl -pe 's#.*mochitest/tests/##' | xargs perl -p -i.bakkk -e 's/Components\.interfaces(\s|;|\.|\[)/SpecialPowers\.Ci$1/g, s/SpecialPowers\.wrap\(Components\)\.(.)(lasses|tils|nterfaces|esults)/SpecialPowers.C$1/g, s/(?<![\.a-zA-Z])Components/SpecialPowers\.Components/g, s/window\.Components/window\.SpecialPowers\.Components/g'
150 lines
4.1 KiB
HTML
150 lines
4.1 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=369306
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 369306</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=369306">Mozilla Bug 369306</a>
|
|
<p id="display"></p>
|
|
<div id='content'>
|
|
</div>
|
|
<pre id="test">
|
|
<script type="application/javascript">
|
|
|
|
/** Test for Bug 369306 **/
|
|
|
|
var originatingWindow = self;
|
|
var gOldPrefValue = null;
|
|
|
|
function focusShouldNotChange(aAction, nextTest)
|
|
{
|
|
var w = window.open('about:blank', '', 'foo');
|
|
var fail = false;
|
|
|
|
SimpleTest.waitForFocus(function () {
|
|
function failHandler() { fail = true; }
|
|
|
|
originatingWindow.addEventListener("focus", failHandler, false);
|
|
w.addEventListener("blur", failHandler, false);
|
|
|
|
aAction(w);
|
|
|
|
SimpleTest.executeSoon(function () {
|
|
originatingWindow.removeEventListener("focus", failHandler, false);
|
|
w.removeEventListener("blur", failHandler, false);
|
|
|
|
ok(!fail, "The focus should not have been changed!");
|
|
|
|
// Cleaning and running next test.
|
|
w.close();
|
|
SimpleTest.waitForFocus(nextTest, originatingWindow);
|
|
});
|
|
}, w, true);
|
|
}
|
|
|
|
function focusShouldNotChange2(aURL, nextTest)
|
|
{
|
|
var w = window.open(aURL, '', 'foo');
|
|
var fail = false;
|
|
|
|
SimpleTest.waitForFocus(function () {
|
|
function failHandler() { fail = true; }
|
|
|
|
originatingWindow.addEventListener("focus", failHandler, false);
|
|
w.addEventListener("blur", failHandler, false);
|
|
|
|
/**
|
|
* NOTE: This setTimeout can cause a random green.
|
|
* onload handler + executeSoon doesn't work too so we have to use setTimeout.
|
|
* The check may be call before w script being executed but that would make
|
|
* this check green even if it should be orange.
|
|
*/
|
|
setTimeout(function () {
|
|
originatingWindow.removeEventListener("focus", failHandler, false);
|
|
w.removeEventListener("blur", failHandler, false);
|
|
|
|
ok(!fail, "The focus should not have been changed with URL=" + aURL);
|
|
|
|
// Cleaning and running next test.
|
|
w.close();
|
|
SimpleTest.waitForFocus(nextTest, originatingWindow);
|
|
}, 1000);
|
|
}, w);
|
|
}
|
|
|
|
function test1()
|
|
{
|
|
focusShouldNotChange(function (aW) { aW.blur(); }, test2);
|
|
}
|
|
|
|
function test2()
|
|
{
|
|
focusShouldNotChange(function () { originatingWindow.focus(); }, test3);
|
|
}
|
|
|
|
function test3()
|
|
{
|
|
focusShouldNotChange2("data:text/html,\<script>opener.focus();\<\/script>", test4);
|
|
}
|
|
|
|
function test4()
|
|
{
|
|
focusShouldNotChange2("data:text/html,\<script>blur();\<\/script>", test5);
|
|
}
|
|
|
|
function test5()
|
|
{
|
|
var w = window.open('about:blank', '', 'foo');
|
|
|
|
SimpleTest.waitForFocus(function () {
|
|
SimpleTest.waitForFocus(function () {
|
|
SimpleTest.waitForFocus(function () {
|
|
ok(true, "The last opened window should be able to get focus");
|
|
w.close();
|
|
SimpleTest.executeSoon(finished);
|
|
}, w, true);
|
|
|
|
w.focus();
|
|
}, originatingWindow);
|
|
|
|
SimpleTest.executeSoon(function() {
|
|
// We have to focus back the originating window but we can't do that with
|
|
// .focus() or .blur() anymore.
|
|
var fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"]
|
|
.getService(SpecialPowers.Ci.nsIFocusManager);
|
|
fm.focusedWindow = window;
|
|
});
|
|
}, w, true);
|
|
}
|
|
|
|
function finished()
|
|
{
|
|
SpecialPowers.Cc["@mozilla.org/preferences-service;1"]
|
|
.getService(SpecialPowers.Ci.nsIPrefBranch)
|
|
.setBoolPref("dom.disable_window_flip", gOldPrefValue);
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
// dom.disable_window_flip has to be set to true for this test.
|
|
var prefs = SpecialPowers.Cc["@mozilla.org/preferences-service;1"]
|
|
.getService(SpecialPowers.Ci.nsIPrefBranch);
|
|
gOldPrefValue = prefs.getBoolPref("dom.disable_window_flip");
|
|
prefs.setBoolPref("dom.disable_window_flip", true);
|
|
|
|
// test1 is going to call the next tests.
|
|
SimpleTest.waitForFocus(test1);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|