Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | <!DOCTYPE html> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=428248 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>nsIHyper>TextAccessible chrome tests</title> |
michael@0 | 8 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 9 | |
michael@0 | 10 | <script type="application/javascript" |
michael@0 | 11 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 12 | <script type="application/javascript" |
michael@0 | 13 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 14 | |
michael@0 | 15 | <script type="application/javascript" |
michael@0 | 16 | src="../common.js"></script> |
michael@0 | 17 | <script type="application/javascript" |
michael@0 | 18 | src="../events.js"></script> |
michael@0 | 19 | |
michael@0 | 20 | <script type="application/javascript"> |
michael@0 | 21 | var gParagraphAcc; |
michael@0 | 22 | |
michael@0 | 23 | function testLinkIndexAtOffset(aID, aOffset, aIndex) |
michael@0 | 24 | { |
michael@0 | 25 | var htAcc = getAccessible(aID, [nsIAccessibleHyperText]); |
michael@0 | 26 | is(htAcc.getLinkIndexAtOffset(aOffset), aIndex, |
michael@0 | 27 | "Wrong link index at offset " + aOffset + " for ID " + aID + "!"); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | function testThis(aID, aCharIndex, aExpectedLinkIndex, aName) |
michael@0 | 31 | { |
michael@0 | 32 | testLinkIndexAtOffset(gParagraphAcc, aCharIndex, aExpectedLinkIndex); |
michael@0 | 33 | |
michael@0 | 34 | var linkAcc = gParagraphAcc.getLinkAt(aExpectedLinkIndex); |
michael@0 | 35 | ok(linkAcc, "No accessible for link " + aID + "!"); |
michael@0 | 36 | |
michael@0 | 37 | var linkIndex = gParagraphAcc.getLinkIndex(linkAcc); |
michael@0 | 38 | is(linkIndex, aExpectedLinkIndex, "Wrong link index for " + aID + "!"); |
michael@0 | 39 | |
michael@0 | 40 | // Just test the link's name to make sure we get the right one. |
michael@0 | 41 | is(linkAcc.getAnchor(0).name, aName, "Wrong name for " + aID + "!"); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | //gA11yEventDumpToConsole = true; |
michael@0 | 45 | function doPreTest() |
michael@0 | 46 | { |
michael@0 | 47 | waitForImageMap("imgmap", doTest); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function doTest() |
michael@0 | 51 | { |
michael@0 | 52 | // Test link count |
michael@0 | 53 | gParagraphAcc = getAccessible("testParagraph", [nsIAccessibleHyperText]); |
michael@0 | 54 | is(gParagraphAcc.linkCount, 7, "Wrong link count for paragraph!"); |
michael@0 | 55 | |
michael@0 | 56 | // normal hyperlink |
michael@0 | 57 | testThis("NormalHyperlink", 14, 0, "Mozilla Foundation"); |
michael@0 | 58 | |
michael@0 | 59 | // ARIA hyperlink |
michael@0 | 60 | testThis("AriaHyperlink", 27, 1, "Mozilla Foundation Home"); |
michael@0 | 61 | |
michael@0 | 62 | // ARIA hyperlink with status invalid |
michael@0 | 63 | testThis("InvalidAriaHyperlink", 63, 2, "Invalid link"); |
michael@0 | 64 | |
michael@0 | 65 | // image map, but not its link children. They are not part of hypertext. |
michael@0 | 66 | testThis("imgmap", 76, 3, "b"); |
michael@0 | 67 | |
michael@0 | 68 | // empty hyperlink |
michael@0 | 69 | testThis("emptyLink", 90, 4, null); |
michael@0 | 70 | |
michael@0 | 71 | // normal hyperlink with embedded span |
michael@0 | 72 | testThis("LinkWithSpan", 116, 5, "Heise Online"); |
michael@0 | 73 | |
michael@0 | 74 | // Named anchor |
michael@0 | 75 | testThis("namedAnchor", 193, 6, "This should never be of state_linked"); |
michael@0 | 76 | |
michael@0 | 77 | // Paragraph with link |
michael@0 | 78 | var p2 = getAccessible("p2", [nsIAccessibleHyperText]); |
michael@0 | 79 | var link = p2.getLinkAt(0); |
michael@0 | 80 | is(link, p2.getChildAt(0), "Wrong link for p2"); |
michael@0 | 81 | is(p2.linkCount, 1, "Wrong link count for p2"); |
michael@0 | 82 | |
michael@0 | 83 | // getLinkIndexAtOffset, causes the offsets to be cached; |
michael@0 | 84 | testLinkIndexAtOffset("p4", 0, 0); // 1st 'mozilla' link |
michael@0 | 85 | testLinkIndexAtOffset("p4", 1, 1); // 2nd 'mozilla' link |
michael@0 | 86 | testLinkIndexAtOffset("p4", 2, -1); // ' ' of ' te' text node |
michael@0 | 87 | testLinkIndexAtOffset("p4", 3, -1); // 't' of ' te' text node |
michael@0 | 88 | testLinkIndexAtOffset("p4", 5, -1); // 'x' of 'xt ' text node |
michael@0 | 89 | testLinkIndexAtOffset("p4", 7, -1); // ' ' of 'xt ' text node |
michael@0 | 90 | testLinkIndexAtOffset("p4", 8, 2); // 3d 'mozilla' link |
michael@0 | 91 | testLinkIndexAtOffset("p4", 9, 2); // the end, latest link |
michael@0 | 92 | |
michael@0 | 93 | // the second pass to make sure link indexes are calculated propertly from |
michael@0 | 94 | // cached offsets. |
michael@0 | 95 | testLinkIndexAtOffset("p4", 0, 0); // 1st 'mozilla' link |
michael@0 | 96 | testLinkIndexAtOffset("p4", 1, 1); // 2nd 'mozilla' link |
michael@0 | 97 | testLinkIndexAtOffset("p4", 2, -1); // ' ' of ' te' text node |
michael@0 | 98 | testLinkIndexAtOffset("p4", 3, -1); // 't' of ' te' text node |
michael@0 | 99 | testLinkIndexAtOffset("p4", 5, -1); // 'x' of 'xt ' text node |
michael@0 | 100 | testLinkIndexAtOffset("p4", 7, -1); // ' ' of 'xt ' text node |
michael@0 | 101 | testLinkIndexAtOffset("p4", 8, 2); // 3d 'mozilla' link |
michael@0 | 102 | testLinkIndexAtOffset("p4", 9, 2); // the end, latest link |
michael@0 | 103 | |
michael@0 | 104 | SimpleTest.finish(); |
michael@0 | 105 | } |
michael@0 | 106 | |
michael@0 | 107 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 108 | addA11yLoadEvent(doPreTest); |
michael@0 | 109 | </script> |
michael@0 | 110 | |
michael@0 | 111 | </head> |
michael@0 | 112 | <body> |
michael@0 | 113 | |
michael@0 | 114 | <a target="_blank" |
michael@0 | 115 | title="Create tests for NSIAccessibleHyperlink interface" |
michael@0 | 116 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=418368"> |
michael@0 | 117 | Mozilla Bug 418368 |
michael@0 | 118 | </a><br> |
michael@0 | 119 | <p id="display"></p> |
michael@0 | 120 | <div id="content" style="display: none"></div> |
michael@0 | 121 | <pre id="test"> |
michael@0 | 122 | </pre> |
michael@0 | 123 | <p id="testParagraph"><br |
michael@0 | 124 | >Simple link:<br |
michael@0 | 125 | ><a id="NormalHyperlink" href="http://www.mozilla.org">Mozilla Foundation</a><br |
michael@0 | 126 | >ARIA link:<br |
michael@0 | 127 | ><span id="AriaHyperlink" role="link" |
michael@0 | 128 | onclick="window.open('http://www.mozilla.org/');" |
michael@0 | 129 | tabindex="0">Mozilla Foundation Home</span><br |
michael@0 | 130 | >Invalid, non-focusable hyperlink:<br |
michael@0 | 131 | ><span id="InvalidAriaHyperlink" role="link" aria-invalid="true" |
michael@0 | 132 | onclick="window.open('http:/www.mozilla.org/');">Invalid link</span><br |
michael@0 | 133 | >Image map:<br |
michael@0 | 134 | ><map name="atoz_map"><area href="http://www.bbc.co.uk/radio4/atoz/index.shtml#b" |
michael@0 | 135 | coords="17,0,30,14" |
michael@0 | 136 | alt="b" |
michael@0 | 137 | shape="rect"></area |
michael@0 | 138 | ><area href="http://www.bbc.co.uk/radio4/atoz/index.shtml#a" |
michael@0 | 139 | coords="0,0,13,14" |
michael@0 | 140 | alt="a" |
michael@0 | 141 | shape="rect"></area></map |
michael@0 | 142 | ><img width="447" id="imgmap" |
michael@0 | 143 | height="15" |
michael@0 | 144 | usemap="#atoz_map" |
michael@0 | 145 | src="../letters.gif"></img><br |
michael@0 | 146 | >Empty link:<br |
michael@0 | 147 | ><a id="emptyLink" href=""><img src=""></img></a><br |
michael@0 | 148 | >Link with embedded span<br |
michael@0 | 149 | ><a id="LinkWithSpan" href="http://www.heise.de/"><span lang="de">Heise Online</span></a><br |
michael@0 | 150 | >Named anchor, must not have "linked" state for it to be exposed correctly:<br |
michael@0 | 151 | ><a id="namedAnchor" name="named_anchor">This should never be of state_linked</a> |
michael@0 | 152 | </p> |
michael@0 | 153 | <p id="p2"><a href="http://mozilla.org">mozilla.org</a></p> |
michael@0 | 154 | <p id="p4"><a href="www">mozilla</a><a href="www">mozilla</a><span> te</span><span>xt </span><a href="www">mozilla</a></p> |
michael@0 | 155 | </body> |
michael@0 | 156 | </html> |