Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 4 | |
michael@0 | 5 | <window title="Show Caret Test" |
michael@0 | 6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 7 | |
michael@0 | 8 | <script type="application/javascript" |
michael@0 | 9 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 10 | |
michael@0 | 11 | <iframe id="f1" width="100" height="100" onload="frameLoaded()" |
michael@0 | 12 | src="data:text/html,%3Cbody%20style='height:%208000px'%3E%3Cp%3EHello%3C/p%3EGoodbye%3C/body%3E"/> |
michael@0 | 13 | <!-- <body style='height: 8000px'><p>Hello</p><span id='s'>Goodbye<span></body> --> |
michael@0 | 14 | <iframe id="f2" type="content" showcaret="true" width="100" height="100" onload="frameLoaded()" |
michael@0 | 15 | src="data:text/html,%3Cbody%20style%3D%27height%3A%208000px%27%3E%3Cp%3EHello%3C%2Fp%3E%3Cspan%20id%3D%27s%27%3EGoodbye%3Cspan%3E%3C%2Fbody%3E"/> |
michael@0 | 16 | |
michael@0 | 17 | <script> |
michael@0 | 18 | <![CDATA[ |
michael@0 | 19 | |
michael@0 | 20 | var framesLoaded = 0; |
michael@0 | 21 | var otherWindow = null; |
michael@0 | 22 | |
michael@0 | 23 | function frameLoaded() { if (++framesLoaded == 2) SimpleTest.waitForFocus(runTest); } |
michael@0 | 24 | |
michael@0 | 25 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 26 | function runTest() |
michael@0 | 27 | { |
michael@0 | 28 | var sel1 = frames[0].getSelection(); |
michael@0 | 29 | sel1.collapse(frames[0].document.body, 0); |
michael@0 | 30 | |
michael@0 | 31 | var sel2 = frames[1].getSelection(); |
michael@0 | 32 | sel2.collapse(frames[1].document.body, 0); |
michael@0 | 33 | window.frames[0].focus(); |
michael@0 | 34 | document.commandDispatcher.getControllerForCommand("cmd_moveBottom").doCommand("cmd_moveBottom"); |
michael@0 | 35 | |
michael@0 | 36 | var listener = function() { |
michael@0 | 37 | if (!(frames[0].scrollY > 0)) { |
michael@0 | 38 | window.content.removeEventListener("scroll", listener, false); |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | window.frames[0].addEventListener("scroll", listener, false); |
michael@0 | 42 | |
michael@0 | 43 | var sel1 = frames[0].getSelection(); |
michael@0 | 44 | sel1.collapse(frames[0].document.body, 0); |
michael@0 | 45 | |
michael@0 | 46 | var sel2 = frames[1].getSelection(); |
michael@0 | 47 | sel2.collapse(frames[1].document.body, 0); |
michael@0 | 48 | |
michael@0 | 49 | window.frames[0].focus(); |
michael@0 | 50 | document.commandDispatcher.getControllerForCommand("cmd_moveBottom").doCommand("cmd_moveBottom"); |
michael@0 | 51 | is(sel1.focusNode, frames[0].document.body, "focusNode for non-showcaret"); |
michael@0 | 52 | is(sel1.focusOffset, 0, "focusOffset for non-showcaret"); |
michael@0 | 53 | |
michael@0 | 54 | window.frames[1].focus(); |
michael@0 | 55 | document.commandDispatcher.getControllerForCommand("cmd_moveBottom").doCommand("cmd_moveBottom"); |
michael@0 | 56 | |
michael@0 | 57 | ok(frames[1].scrollY < |
michael@0 | 58 | frames[1].document.getElementById('s').getBoundingClientRect().top, |
michael@0 | 59 | "scrollY for showcaret"); |
michael@0 | 60 | isnot(sel2.focusNode, frames[1].document.body, "focusNode for showcaret"); |
michael@0 | 61 | ok(sel2.anchorOffset > 0, "focusOffset for showcaret"); |
michael@0 | 62 | |
michael@0 | 63 | otherWindow = window.open("window_showcaret.xul", "_blank", "chrome,width=400,height=200"); |
michael@0 | 64 | otherWindow.addEventListener("focus", otherWindowFocused, false); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | function otherWindowFocused() |
michael@0 | 68 | { |
michael@0 | 69 | otherWindow.removeEventListener("focus", otherWindowFocused, false); |
michael@0 | 70 | |
michael@0 | 71 | // enable caret browsing temporarily to test caret movement |
michael@0 | 72 | var prefs = Components.classes["@mozilla.org/preferences-service;1"]. |
michael@0 | 73 | getService(Components.interfaces.nsIPrefBranch); |
michael@0 | 74 | prefs.setBoolPref("accessibility.browsewithcaret", true); |
michael@0 | 75 | |
michael@0 | 76 | var hbox = otherWindow.document.documentElement.firstChild; |
michael@0 | 77 | hbox.focus(); |
michael@0 | 78 | is(otherWindow.document.activeElement, hbox, "hbox in other window is focused"); |
michael@0 | 79 | |
michael@0 | 80 | document.commandDispatcher.getControllerForCommand("cmd_lineNext").doCommand("cmd_lineNext"); |
michael@0 | 81 | is(otherWindow.document.activeElement, hbox, "hbox still focused in other window after down movement"); |
michael@0 | 82 | |
michael@0 | 83 | prefs.setBoolPref("accessibility.browsewithcaret", false); |
michael@0 | 84 | |
michael@0 | 85 | otherWindow.close(); |
michael@0 | 86 | SimpleTest.finish(); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | ]]> |
michael@0 | 90 | </script> |
michael@0 | 91 | |
michael@0 | 92 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 93 | <p id="display"> |
michael@0 | 94 | </p> |
michael@0 | 95 | <div id="content" style="display: none"> |
michael@0 | 96 | </div> |
michael@0 | 97 | <pre id="test"> |
michael@0 | 98 | </pre> |
michael@0 | 99 | </body> |
michael@0 | 100 | |
michael@0 | 101 | </window> |