2016-05-24 09:31:09 +03:00
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<head>
|
|
|
|
<title>Test for SVG tabIndex - Bug 778654</title>
|
|
|
|
<link rel="stylesheet" type="text/css"
|
|
|
|
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
|
|
|
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" overflow="visible">
|
|
|
|
<foreignObject id="f" x="0" y="0" width="200" height="60" tabindex="0">
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<p>Here is a paragraph that requires word wrap</p>
|
|
|
|
</body>
|
|
|
|
</foreignObject>
|
2016-09-01 11:53:18 +03:00
|
|
|
<rect id="r" x="0" y="70" width="100" height="100" fill="yellow" tabindex="1"/>
|
2016-05-24 09:31:09 +03:00
|
|
|
<text id="t" x="0" y="200" tabindex="2">
|
2016-09-28 05:21:50 +03:00
|
|
|
This is SVG text
|
2016-05-24 09:31:09 +03:00
|
|
|
</text>
|
2016-09-28 05:21:50 +03:00
|
|
|
<a xlink:href="#" id="l1" tabindex="3">
|
|
|
|
<circle cx="10" cy="230" r="10"/>
|
|
|
|
</a>
|
|
|
|
<a id="l2" tabindex="4">
|
|
|
|
<circle cx="10" cy="260" r="10"/>
|
|
|
|
</a>
|
2016-05-24 09:31:09 +03:00
|
|
|
</svg>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
function main()
|
|
|
|
{
|
|
|
|
var f = document.getElementById('f');
|
|
|
|
var r = document.getElementById('r');
|
|
|
|
var t = document.getElementById('t');
|
2016-09-28 05:21:50 +03:00
|
|
|
var l1 = document.getElementById('l1');
|
|
|
|
var l2 = document.getElementById('l2');
|
|
|
|
const isMac = ("nsILocalFileMac" in SpecialPowers.Ci);
|
2016-05-24 09:31:09 +03:00
|
|
|
|
|
|
|
try {
|
|
|
|
// Step 1: Checking by assigning tabIndex
|
|
|
|
is(f.tabIndex, 0, "foreignObject initial tabIndex");
|
|
|
|
f.tabIndex = 1;
|
|
|
|
is(f.tabIndex, 1, "foreignObject tabIndex is set to 1");
|
|
|
|
|
|
|
|
is(r.tabIndex, 1, "rect initial tabIndex");
|
|
|
|
r.tabIndex = 2;
|
|
|
|
is(r.tabIndex, 2, "rect tabIndex is set to 2");
|
|
|
|
|
|
|
|
is(t.tabIndex, 2, "text initial tabIndex");
|
|
|
|
t.tabIndex = 3;
|
|
|
|
is(t.tabIndex, 3, "text is set to 3");
|
|
|
|
|
2016-09-28 05:21:50 +03:00
|
|
|
is(l1.tabIndex, 3, "link initial tabIndex");
|
|
|
|
l1.tabIndex = 4;
|
|
|
|
is(l1.tabIndex, 4, "link is set to 4");
|
|
|
|
|
|
|
|
is(l2.tabIndex, 4, "non-link initial tabIndex");
|
|
|
|
l2.tabIndex = 5;
|
|
|
|
is(l2.tabIndex, 5, "non-link is set to 4");
|
|
|
|
|
2016-05-24 09:31:09 +03:00
|
|
|
// Step 2: Checking by triggering TAB event
|
|
|
|
is(document.activeElement.tabIndex, -1, "In the beginning, the active element tabindex is -1");
|
|
|
|
|
|
|
|
synthesizeKey("VK_TAB", {});
|
|
|
|
is(document.activeElement.tabIndex, 1, "The active element tabindex is 1");
|
|
|
|
|
|
|
|
synthesizeKey("VK_TAB", {});
|
|
|
|
is(document.activeElement.tabIndex, 2, "The active element tabindex is 2");
|
|
|
|
|
|
|
|
synthesizeKey("VK_TAB", {});
|
|
|
|
is(document.activeElement.tabIndex, 3, "The active element tabindex is 3");
|
2016-09-28 05:21:50 +03:00
|
|
|
|
|
|
|
synthesizeKey("VK_TAB", {});
|
|
|
|
// On Mac, SVG link elements should not be focused.
|
|
|
|
if (isMac) {
|
|
|
|
is(document.activeElement.tabIndex, 3, "The active element tabindex is 3");
|
|
|
|
} else {
|
|
|
|
is(document.activeElement.tabIndex, 4, "The active element tabindex is 4");
|
|
|
|
}
|
|
|
|
|
|
|
|
synthesizeKey("VK_TAB", {});
|
|
|
|
// On Mac, SVG link elements should not be focused.
|
|
|
|
if (isMac) {
|
|
|
|
// This test has to be run with other tests, otherwise,
|
|
|
|
// document.activeElement.tabIndex will be -1 on Mac.
|
|
|
|
is(document.activeElement.tabIndex, 3, "The active element tabindex is 3");
|
|
|
|
} else {
|
|
|
|
is(document.activeElement.tabIndex, 5, "The active element tabindex is 5");
|
|
|
|
}
|
2016-05-24 09:31:09 +03:00
|
|
|
} catch(e) {
|
|
|
|
ok(false, "Got unexpected exception" + e);
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
2017-01-17 13:50:25 +03:00
|
|
|
window.addEventListener("load", main);
|
2016-05-24 09:31:09 +03:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|