1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/states/test_visibility.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,175 @@ 1.4 +<html> 1.5 +<head> 1.6 + <title>visibility state testing</title> 1.7 + 1.8 + <link rel="stylesheet" type="text/css" 1.9 + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.10 + 1.11 + <script type="application/javascript" 1.12 + src="chrome://mochikit/content/MochiKit/packed.js"></script> 1.13 + <script type="application/javascript" 1.14 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.15 + 1.16 + <script type="application/javascript" 1.17 + src="../common.js"></script> 1.18 + <script type="application/javascript" 1.19 + src="../role.js"></script> 1.20 + <script type="application/javascript" 1.21 + src="../states.js"></script> 1.22 + <script type="application/javascript" 1.23 + src="../events.js"></script> 1.24 + <script type="application/javascript" 1.25 + src="../browser.js"></script> 1.26 + 1.27 + <script type="application/javascript"> 1.28 + //////////////////////////////////////////////////////////////////////////// 1.29 + // Invokers 1.30 + 1.31 + function loadURIInvoker(aURI, aFunc) 1.32 + { 1.33 + this.invoke = function loadURIInvoker_invoke() 1.34 + { 1.35 + tabBrowser().loadURI(aURI); 1.36 + } 1.37 + 1.38 + this.eventSeq = [ 1.39 + new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, currentTabDocument) 1.40 + ]; 1.41 + 1.42 + this.finalCheck = function loadURIInvoker_finalCheck() 1.43 + { 1.44 + aFunc.call(); 1.45 + } 1.46 + 1.47 + this.getID = function loadURIInvoker_getID() 1.48 + { 1.49 + return "load uri " + aURI; 1.50 + } 1.51 + } 1.52 + 1.53 + function addTabInvoker(aURL, aFunc) 1.54 + { 1.55 + this.eventSeq = [ 1.56 + new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 1) 1.57 + ]; 1.58 + 1.59 + this.invoke = function addTabInvoker_invoke() 1.60 + { 1.61 + tabBrowser().loadOneTab(aURL, null, "", null, false); 1.62 + } 1.63 + 1.64 + this.finalCheck = function addTabInvoker_finalCheck() 1.65 + { 1.66 + aFunc.call(); 1.67 + } 1.68 + 1.69 + this.getID = function addTabInvoker_getID() 1.70 + { 1.71 + return "add tab: " + aURL; 1.72 + } 1.73 + } 1.74 + 1.75 + //////////////////////////////////////////////////////////////////////////// 1.76 + // Tests 1.77 + 1.78 + function testBackgroundTab() 1.79 + { 1.80 + // Accessibles in background tab should have offscreen state and no 1.81 + // invisible state. 1.82 + var tabDoc = tabDocumentAt(0); 1.83 + var input = getAccessible(tabDoc.getElementById("input")); 1.84 + testStates(input, STATE_OFFSCREEN, 0, STATE_INVISIBLE); 1.85 + } 1.86 + 1.87 + function testScrolledOff() 1.88 + { 1.89 + var tabDoc = tabDocumentAt(1); 1.90 + 1.91 + // scrolled off 1.92 + input = getAccessible(tabDoc.getElementById("input_scrolledoff")); 1.93 + testStates(input, STATE_OFFSCREEN, 0, STATE_INVISIBLE); 1.94 + 1.95 + // scrolled off item (twice) 1.96 + var lastLiNode = tabDoc.getElementById("li_last"); 1.97 + var lastLi = getAccessible(lastLiNode); 1.98 + testStates(lastLi, STATE_OFFSCREEN, 0, STATE_INVISIBLE); 1.99 + 1.100 + // scroll into view the item 1.101 + lastLiNode.scrollIntoView(true); 1.102 + testStates(lastLi, 0, 0, STATE_OFFSCREEN | STATE_INVISIBLE); 1.103 + 1.104 + // first item is scrolled off now (testcase for bug 768786) 1.105 + var firstLi = getAccessible(tabDoc.getElementById("li_first")); 1.106 + testStates(firstLi, STATE_OFFSCREEN, 0, STATE_INVISIBLE); 1.107 + } 1.108 + 1.109 + var gInputDocURI = "data:text/html,<html><body>"; 1.110 + gInputDocURI += "<input id='input'></body></html>"; 1.111 + 1.112 + var gDocURI = "data:text/html,<html><body>"; 1.113 + gDocURI += "<div style='border:2px solid blue; width: 500px; height: 600px;'></div>"; 1.114 + gDocURI += "<input id='input_scrolledoff'>"; 1.115 + gDocURI += "<ul style='border:2px solid red; width: 100px; height: 50px; overflow: auto;'>"; 1.116 + gDocURI += " <li id='li_first'>item1</li><li>item2</li><li>item3</li>"; 1.117 + gDocURI += " <li>item4</li><li>item5</li><li id='li_last'>item6</li>"; 1.118 + gDocURI += "</ul>"; 1.119 + gDocURI += "</body></html>"; 1.120 + 1.121 + function doTests() 1.122 + { 1.123 + testStates("div", 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN); 1.124 + testStates("div_off", STATE_OFFSCREEN, 0, STATE_INVISIBLE); 1.125 + testStates("div_transformed", STATE_OFFSCREEN, 0, STATE_INVISIBLE); 1.126 + testStates("div_abschild", 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN); 1.127 + 1.128 + gQueue = new eventQueue(); 1.129 + 1.130 + gQueue.push(new addTabInvoker("about:blank", testBackgroundTab)); 1.131 + gQueue.push(new loadURIInvoker(gDocURI, testScrolledOff)); 1.132 + 1.133 + gQueue.onFinish = function() { closeBrowserWindow(); } 1.134 + gQueue.invoke(); // Will call SimpleTest.finish(); 1.135 + } 1.136 + 1.137 + SimpleTest.waitForExplicitFinish(); 1.138 + openBrowserWindow(doTests, gInputDocURI, { width: 600, height: 600 }); 1.139 + </script> 1.140 + 1.141 +</head> 1.142 + 1.143 +<body> 1.144 + 1.145 + <a target="_blank" 1.146 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=591363" 1.147 + title="(in)visible state is not always correct?"> 1.148 + Mozilla Bug 591363 1.149 + </a> 1.150 + <a target="_blank" 1.151 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=768786" 1.152 + title="Offscreen state is not exposed under certain circumstances"> 1.153 + Mozilla Bug 768786 1.154 + </a> 1.155 + <p id="display"></p> 1.156 + <div id="content" style="display: none"></div> 1.157 + <pre id="test"> 1.158 + </pre> 1.159 + 1.160 + <div id="outer_div"> 1.161 + 1.162 + <!-- trivial cases --> 1.163 + <div id="div">div</div> 1.164 + <div id="div_off" style="position: absolute; left:-999px; top:-999px"> 1.165 + offscreen! 1.166 + </div> 1.167 + <div id="div_transformed" style="transform: translate(-999px, -999px);"> 1.168 + transformed! 1.169 + </div> 1.170 + 1.171 + <!-- edge case: no rect but has out of flow child --> 1.172 + <div id="div_abschild"> 1.173 + <p style="position: absolute; left: 120px; top:120px;">absolute</p> 1.174 + </div> 1.175 + 1.176 + </div> 1.177 +</body> 1.178 +</html>