Bug 1415787 - Add two extra elements in the SVG element to avoid losing focus. r?daoshengmu draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 21 Dec 2017 10:49:05 +0900
changeset 713842 541b1b6af8a8c05966b1b9c1bfde945129aa1bf2
parent 713743 62dd5404cf55e29412d5fff8fe9105076b1ca437
child 713843 a9daf91959dc83fed535f4473ec23d9ab50d5f0b
push id93775
push userhikezoe@mozilla.com
push dateThu, 21 Dec 2017 01:49:27 +0000
reviewersdaoshengmu
bugs1415787
milestone59.0a1
Bug 1415787 - Add two extra elements in the SVG element to avoid losing focus. r?daoshengmu On MacOSX, more precisely if full keyboard access is not enabled on MacOSX, we skip focusing link elements in SVG with tab key, so if there is no more elements to be focused in the SVG, the focus will be moved outside the SVG. To prevent this situation, there needs more focusable elements in the SVG. MozReview-Commit-ID: HGGMjA0Asfw
dom/svg/test/test_tabindex.html
--- a/dom/svg/test/test_tabindex.html
+++ b/dom/svg/test/test_tabindex.html
@@ -19,16 +19,18 @@
     This is SVG text
   </text>
   <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>
+  <rect id="r6" x="0" y="70" width="100" height="100" fill="yellow" tabindex="6"/>
+  <rect id="r7" x="0" y="70" width="100" height="100" fill="yellow" tabindex="7"/>
 </svg>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 SimpleTest.waitForExplicitFinish();
 
 function main()
 {
   var f = document.getElementById('f');
@@ -70,27 +72,25 @@ function main()
     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");
 
     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");
+      is(document.activeElement.tabIndex, 6, "The active element tabindex is 6");
     } 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");
+      is(document.activeElement.tabIndex, 7, "The active element tabindex is 7");
     } else {
       is(document.activeElement.tabIndex, 5, "The active element tabindex is 5");
     }
   } catch(e) {
     ok(false, "Got unexpected exception" + e);
   }
 
   SimpleTest.finish();