blob: e92f80b3b1ec06749c7a226b5dbdca9532953a91 [file] [log] [blame]
<!DOCTYPE HTML><!-- webkit-test-runner [ KeygenElementEnabled=true ] -->
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<div id="container">
<!-- Focusable elements -->
<a id="anchor" href="tabindex-defaults.html">anchor</a>
<iframe id="iframe"></iframe>
<object id="object"></object>
<button id="button">button</button>
<input id="input">
<select id="select"></select>
<textarea id="textarea"></textarea>
<keygen id="keygen"></keygen>
<div id="editableDiv" contenteditable="true"></div>
<details><summary id="activeSummary"></summary></details>
<!-- Unfocusable element -->
<div id="normalDiv"></div>
<output id="output"></output>
<fieldset id="fieldset"></fieldset>
<video id="video"></video>
<video id="videoWithControls" controls></video>
<details><summary></summary><summary id="summary"></summary></details>
<iframe id="iframeForDesignMode"></iframe>
<svg><g id="g" onfocus="alert('fail')"></g></svg>
<math><mrow id="mrow" onfocus="alert('fail')"></mrow></math>
</div>
<script>
description('Default value of tabIndex IDL attribute');
var anchor = document.getElementById('anchor');
var iframe = document.getElementById('iframe');
iframe.contentDocument.open();
iframe.contentDocument.write('<!DOCTYPE><html><frameset cols="50%,50%"><frame></frame></frameset>');
var frame = iframe.contentDocument.querySelector('frame');
var object = document.getElementById('object');
var button = document.getElementById('button');
var input = document.getElementById('input');
var select = document.getElementById('select');
var textarea = document.getElementById('textarea');
var keygen = document.getElementById('keygen');
var editableDiv = document.getElementById('editableDiv');
var normalDiv = document.getElementById('normalDiv');
var output = document.getElementById('output');
var fieldset = document.getElementById('fieldset');
var video = document.getElementById('video');
var videoWithControls = document.getElementById('videoWithControls');
var summary = document.getElementById('summary');
var activeSummary = document.getElementById('activeSummary');
var iframeForDesignMode = document.getElementById('iframeForDesignMode');
iframeForDesignMode.contentDocument.designMode = 'on';
var bodyInDesignMode = iframeForDesignMode.contentDocument.body;
var g = document.getElementById('g');
var mrow = document.getElementById('mrow');
shouldBe('anchor.tabIndex', '0');
shouldBe('iframe.tabIndex', '0');
shouldBe('frame.tabIndex', '0');
shouldBe('object.tabIndex', '0');
shouldBe('button.tabIndex', '0');
shouldBe('input.tabIndex', '0');
shouldBe('select.tabIndex', '0');
shouldBe('textarea.tabIndex', '0');
shouldBe('keygen.tabIndex', '0');
shouldBe('activeSummary.tabIndex', '0');
shouldBe('editableDiv.tabIndex', '-1');
shouldBe('normalDiv.tabIndex', '-1');
shouldBe('output.tabIndex', '-1');
shouldBe('fieldset.tabIndex', '-1');
shouldBe('video.tabIndex', '-1');
shouldBe('videoWithControls.tabIndex', '-1');
shouldBe('summary.tabIndex', '-1');
shouldBe('bodyInDesignMode.tabIndex', '-1');
shouldBe('g.tabIndex', '-1');
shouldBe('mrow.tabIndex', '-1');
shouldBe('anchor.setAttribute("tabindex", "invalid"); anchor.tabIndex', '0');
shouldBe('iframe.setAttribute("tabindex", "invalid"); iframe.tabIndex', '0');
shouldBe('frame.setAttribute("tabindex", "invalid"); frame.tabIndex', '0');
shouldBe('object.setAttribute("tabindex", "invalid"); object.tabIndex', '0');
shouldBe('button.setAttribute("tabindex", "invalid"); button.tabIndex', '0');
shouldBe('input.setAttribute("tabindex", "invalid"); input.tabIndex', '0');
shouldBe('select.setAttribute("tabindex", "invalid"); select.tabIndex', '0');
shouldBe('textarea.setAttribute("tabindex", "invalid"); textarea.tabIndex', '0');
shouldBe('keygen.setAttribute("tabindex", "invalid"); keygen.tabIndex', '0');
shouldBe('activeSummary.setAttribute("tabindex", "invalid"); activeSummary.tabIndex', '0');
shouldBe('editableDiv.setAttribute("tabindex", "invalid"); editableDiv.tabIndex', '-1');
shouldBe('normalDiv.setAttribute("tabindex", "invalid"); normalDiv.tabIndex', '-1');
shouldBe('output.setAttribute("tabindex", "invalid"); output.tabIndex', '-1');
shouldBe('fieldset.setAttribute("tabindex", "invalid"); fieldset.tabIndex', '-1');
shouldBe('video.setAttribute("tabindex", "invalid"); video.tabIndex', '-1');
shouldBe('videoWithControls.setAttribute("tabindex", "invalid"); videoWithControls.tabIndex', '-1');
shouldBe('summary.setAttribute("tabindex", "invalid"); summary.tabIndex', '-1');
shouldBe('bodyInDesignMode.setAttribute("tabindex", "invalid"); bodyInDesignMode.tabIndex', '-1');
shouldBe('g.setAttribute("tabindex", "invalid"); g.tabIndex', '-1');
shouldBe('mrow.setAttribute("tabindex", "invalid"); mrow.tabIndex', '-1');
shouldBe('anchor.setAttribute("tabindex", "9999999999"); anchor.tabIndex', '0');
shouldBe('iframe.setAttribute("tabindex", "9999999999"); iframe.tabIndex', '0');
shouldBe('frame.setAttribute("tabindex", "9999999999"); frame.tabIndex', '0');
shouldBe('object.setAttribute("tabindex", "invalid"); object.tabIndex', '0');
shouldBe('button.setAttribute("tabindex", "9999999999"); button.tabIndex', '0');
shouldBe('input.setAttribute("tabindex", "9999999999"); input.tabIndex', '0');
shouldBe('select.setAttribute("tabindex", "9999999999"); select.tabIndex', '0');
shouldBe('textarea.setAttribute("tabindex", "9999999999"); textarea.tabIndex', '0');
shouldBe('keygen.setAttribute("tabindex", "9999999999"); keygen.tabIndex', '0');
shouldBe('activeSummary.setAttribute("tabindex", "9999999999"); activeSummary.tabIndex', '0');
shouldBe('editableDiv.setAttribute("tabindex", "9999999999"); editableDiv.tabIndex', '-1');
shouldBe('normalDiv.setAttribute("tabindex", "9999999999"); normalDiv.tabIndex', '-1');
shouldBe('output.setAttribute("tabindex", "9999999999"); output.tabIndex', '-1');
shouldBe('fieldset.setAttribute("tabindex", "9999999999"); fieldset.tabIndex', '-1');
shouldBe('video.setAttribute("tabindex", "9999999999"); video.tabIndex', '-1');
shouldBe('videoWithControls.setAttribute("tabindex", "9999999999"); videoWithControls.tabIndex', '-1');
shouldBe('summary.setAttribute("tabindex", "9999999999"); summary.tabIndex', '-1');
shouldBe('bodyInDesignMode.setAttribute("tabindex", "9999999999"); bodyInDesignMode.tabIndex', '-1');
shouldBe('g.setAttribute("tabindex", "9999999999"); g.tabIndex', '-1');
shouldBe('mrow.setAttribute("tabindex", "9999999999"); mrow.tabIndex', '-1');
document.getElementById('container').innerHTML = '';
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>