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="Menu Checkbox and Radio Tests" |
michael@0 | 6 | onload="runTest()" |
michael@0 | 7 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 8 | |
michael@0 | 9 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | |
michael@0 | 12 | <hbox> |
michael@0 | 13 | <button id="menu" type="menu" label="View"> |
michael@0 | 14 | <menupopup id="popup" onpopupshown="popupShown()" onpopuphidden="popupHidden()"> |
michael@0 | 15 | <menuitem id="toolbar" label="Show Toolbar" type="checkbox"/> |
michael@0 | 16 | <menuitem id="statusbar" label="Show Status Bar" type="checkbox" checked="true"/> |
michael@0 | 17 | <menuitem id="bookmarks" label="Show Bookmarks" type="checkbox" autocheck="false"/> |
michael@0 | 18 | <menuitem id="history" label="Show History" type="checkbox" autocheck="false" checked="true"/> |
michael@0 | 19 | <menuseparator/> |
michael@0 | 20 | <menuitem id="byname" label="By Name" type="radio" name="sort"/> |
michael@0 | 21 | <menuitem id="bydate" label="By Date" type="radio" name="sort" checked="true"/> |
michael@0 | 22 | <menuseparator/> |
michael@0 | 23 | <menuitem id="ascending" label="Ascending" type="radio" name="order" checked="true"/> |
michael@0 | 24 | <menuitem id="descending" label="Descending" type="radio" name="order" autocheck="false"/> |
michael@0 | 25 | <menuitem id="bysubject" label="By Subject" type="radio" name="sort"/> |
michael@0 | 26 | </menupopup> |
michael@0 | 27 | </button> |
michael@0 | 28 | |
michael@0 | 29 | </hbox> |
michael@0 | 30 | |
michael@0 | 31 | <!-- |
michael@0 | 32 | This test checks that checkbox and radio menu items work properly |
michael@0 | 33 | --> |
michael@0 | 34 | <script class="testbody" type="application/javascript"> |
michael@0 | 35 | <![CDATA[ |
michael@0 | 36 | |
michael@0 | 37 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 38 | var gTestIndex = 0; |
michael@0 | 39 | |
michael@0 | 40 | // tests to perform |
michael@0 | 41 | var tests = [ |
michael@0 | 42 | { |
michael@0 | 43 | testname: "select unchecked checkbox", |
michael@0 | 44 | item: "toolbar", |
michael@0 | 45 | checked: ["toolbar", "statusbar", "history", "bydate", "ascending"] |
michael@0 | 46 | }, |
michael@0 | 47 | { |
michael@0 | 48 | testname: "select checked checkbox", |
michael@0 | 49 | item: "statusbar", |
michael@0 | 50 | checked: ["toolbar", "history", "bydate", "ascending"] |
michael@0 | 51 | }, |
michael@0 | 52 | { |
michael@0 | 53 | testname: "select unchecked autocheck checkbox", |
michael@0 | 54 | item: "bookmarks", |
michael@0 | 55 | checked: ["toolbar", "history", "bydate", "ascending"] |
michael@0 | 56 | }, |
michael@0 | 57 | { |
michael@0 | 58 | testname: "select checked autocheck checkbox", |
michael@0 | 59 | item: "history", |
michael@0 | 60 | checked: ["toolbar", "history", "bydate", "ascending"] |
michael@0 | 61 | }, |
michael@0 | 62 | { |
michael@0 | 63 | testname: "select unchecked radio", |
michael@0 | 64 | item: "byname", |
michael@0 | 65 | checked: ["toolbar", "history", "byname", "ascending"] |
michael@0 | 66 | }, |
michael@0 | 67 | { |
michael@0 | 68 | testname: "select checked radio", |
michael@0 | 69 | item: "byname", |
michael@0 | 70 | checked: ["toolbar", "history", "byname", "ascending"] |
michael@0 | 71 | }, |
michael@0 | 72 | { |
michael@0 | 73 | testname: "select out of order checked radio", |
michael@0 | 74 | item: "bysubject", |
michael@0 | 75 | checked: ["toolbar", "history", "bysubject", "ascending"] |
michael@0 | 76 | }, |
michael@0 | 77 | { |
michael@0 | 78 | testname: "select first radio again", |
michael@0 | 79 | item: "byname", |
michael@0 | 80 | checked: ["toolbar", "history", "byname", "ascending"] |
michael@0 | 81 | }, |
michael@0 | 82 | { |
michael@0 | 83 | testname: "select autocheck radio", |
michael@0 | 84 | item: "descending", |
michael@0 | 85 | checked: ["toolbar", "history", "byname", "ascending"] |
michael@0 | 86 | } |
michael@0 | 87 | ]; |
michael@0 | 88 | |
michael@0 | 89 | function runTest() |
michael@0 | 90 | { |
michael@0 | 91 | checkMenus(["statusbar", "history", "bydate", "ascending"], "initial"); |
michael@0 | 92 | document.getElementById("menu").open = true; |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | function checkMenus(checkedItems, testname) |
michael@0 | 96 | { |
michael@0 | 97 | var isok = true; |
michael@0 | 98 | var children = document.getElementById("popup").childNodes; |
michael@0 | 99 | for (var c = 0; c < children.length; c++) { |
michael@0 | 100 | var child = children[c]; |
michael@0 | 101 | if ((checkedItems.indexOf(child.id) != -1 && child.getAttribute("checked") != "true") || |
michael@0 | 102 | (checkedItems.indexOf(child.id) == -1 && child.hasAttribute("checked"))) { |
michael@0 | 103 | isok = false; |
michael@0 | 104 | break; |
michael@0 | 105 | } |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | ok(isok, testname); |
michael@0 | 109 | } |
michael@0 | 110 | |
michael@0 | 111 | function popupShown() |
michael@0 | 112 | { |
michael@0 | 113 | var test = tests[gTestIndex]; |
michael@0 | 114 | synthesizeMouse(document.getElementById(test.item), 4, 4, { }); |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | function popupHidden() |
michael@0 | 118 | { |
michael@0 | 119 | if (gTestIndex < tests.length) { |
michael@0 | 120 | var test = tests[gTestIndex]; |
michael@0 | 121 | checkMenus(test.checked, test.testname); |
michael@0 | 122 | gTestIndex++; |
michael@0 | 123 | if (gTestIndex < tests.length) { |
michael@0 | 124 | document.getElementById("menu").open = true; |
michael@0 | 125 | } |
michael@0 | 126 | else { |
michael@0 | 127 | // manually setting the checkbox should also update the radio state |
michael@0 | 128 | document.getElementById("bydate").setAttribute("checked", "true"); |
michael@0 | 129 | checkMenus(["toolbar", "history", "bydate", "ascending"], "set checked attribute on radio"); |
michael@0 | 130 | SimpleTest.finish(); |
michael@0 | 131 | } |
michael@0 | 132 | } |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | ]]> |
michael@0 | 136 | </script> |
michael@0 | 137 | |
michael@0 | 138 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 139 | <p id="display"> |
michael@0 | 140 | </p> |
michael@0 | 141 | <div id="content" style="display: none"> |
michael@0 | 142 | </div> |
michael@0 | 143 | <pre id="test"> |
michael@0 | 144 | </pre> |
michael@0 | 145 | </body> |
michael@0 | 146 | |
michael@0 | 147 | </window> |