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 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for DOM MouseEvent</title> |
michael@0 | 5 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <p id="display"></p> |
michael@0 | 10 | <div id="content" style="display: none"> |
michael@0 | 11 | |
michael@0 | 12 | </div> |
michael@0 | 13 | <pre id="test"> |
michael@0 | 14 | <script type="application/javascript"> |
michael@0 | 15 | |
michael@0 | 16 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 17 | SimpleTest.waitForFocus(runTests, window); |
michael@0 | 18 | |
michael@0 | 19 | function testInitializingUntrustedEvent() |
michael@0 | 20 | { |
michael@0 | 21 | const kTests = [ |
michael@0 | 22 | { createEventArg: "MouseEvent", |
michael@0 | 23 | type: "mousedown", bubbles: true, cancelable: true, view: null, detail: 1, |
michael@0 | 24 | screenX: 0, screenY: 0, clientX: 0, clientY: 0, |
michael@0 | 25 | ctrlKey: false, altKey: false, shiftKey: false, metaKey: false, |
michael@0 | 26 | button: 6, relatedTarget: null }, |
michael@0 | 27 | |
michael@0 | 28 | { createEventArg: "mouseevent", |
michael@0 | 29 | type: "mouseup", bubbles: false, cancelable: true, view: window, detail: 2, |
michael@0 | 30 | screenX: 0, screenY: 0, clientX: 0, clientY: 400, |
michael@0 | 31 | ctrlKey: true, altKey: false, shiftKey: false, metaKey: false, |
michael@0 | 32 | button: 1, relatedTarget: document.getElementById("content") }, |
michael@0 | 33 | |
michael@0 | 34 | { createEventArg: "Mouseevent", |
michael@0 | 35 | type: "click", bubbles: true, cancelable: false, view: null, detail: -5, |
michael@0 | 36 | screenX: 0, screenY: 0, clientX: 300, clientY: 0, |
michael@0 | 37 | ctrlKey: false, altKey: true, shiftKey: false, metaKey: false, |
michael@0 | 38 | button: 2, relatedTarget: document.getElementById("test") }, |
michael@0 | 39 | |
michael@0 | 40 | { createEventArg: "mouseEvent", |
michael@0 | 41 | type: "dblclick", bubbles: false, cancelable: false, view: window, detail: -1, |
michael@0 | 42 | screenX: 0, screenY: 200, clientX: 0, clientY: 0, |
michael@0 | 43 | ctrlKey: false, altKey: false, shiftKey: true, metaKey: false, |
michael@0 | 44 | button: 12, relatedTarget: document.getElementById("content") }, |
michael@0 | 45 | |
michael@0 | 46 | { createEventArg: "MouseEvents", |
michael@0 | 47 | type: "mouseenter", bubbles: true, cancelable: true, view: null, detail: 111000, |
michael@0 | 48 | screenX: 100, screenY: 0, clientX: 0, clientY: 0, |
michael@0 | 49 | ctrlKey: false, altKey: false, shiftKey: false, metaKey: true, |
michael@0 | 50 | button: 2, relatedTarget: document.getElementById("test") }, |
michael@0 | 51 | |
michael@0 | 52 | { createEventArg: "mouseevents", |
michael@0 | 53 | type: "mouseleave", bubbles: false, cancelable: true, view: window, detail: 500, |
michael@0 | 54 | screenX: 100, screenY: 500, clientX: 0, clientY: 0, |
michael@0 | 55 | ctrlKey: true, altKey: true, shiftKey: false, metaKey: false, |
michael@0 | 56 | button: 8, relatedTarget: document.getElementById("content") }, |
michael@0 | 57 | |
michael@0 | 58 | { createEventArg: "Mouseevents", |
michael@0 | 59 | type: "mouseover", bubbles: true, cancelable: false, view: null, detail: 3, |
michael@0 | 60 | screenX: 0, screenY: 0, clientX: 200, clientY: 300, |
michael@0 | 61 | ctrlKey: false, altKey: true, shiftKey: false, metaKey: true, |
michael@0 | 62 | button: 7, relatedTarget: document.getElementById("test") }, |
michael@0 | 63 | |
michael@0 | 64 | { createEventArg: "mouseEvents", |
michael@0 | 65 | type: "mouseout", bubbles: false, cancelable: false, view: window, detail: 5, |
michael@0 | 66 | screenX: -100, screenY: 300, clientX: 600, clientY: -500, |
michael@0 | 67 | ctrlKey: true, altKey: false, shiftKey: true, metaKey: false, |
michael@0 | 68 | button: 8, relatedTarget: document.getElementById("content") }, |
michael@0 | 69 | |
michael@0 | 70 | { createEventArg: "MouseEvent", |
michael@0 | 71 | type: "mousemove", bubbles: false, cancelable: false, view: window, detail: 30, |
michael@0 | 72 | screenX: 500, screenY: -100, clientX: -8888, clientY: -5000, |
michael@0 | 73 | ctrlKey: true, altKey: false, shiftKey: true, metaKey: true, |
michael@0 | 74 | button: 8, relatedTarget: document.getElementById("test") }, |
michael@0 | 75 | |
michael@0 | 76 | { createEventArg: "MouseEvent", |
michael@0 | 77 | type: "foo", bubbles: false, cancelable: false, view: window, detail: 100, |
michael@0 | 78 | screenX: 2000, screenY: 6000, clientX: 5000, clientY: 3000, |
michael@0 | 79 | ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, |
michael@0 | 80 | button: 8, relatedTarget: document.getElementById("test") }, |
michael@0 | 81 | ]; |
michael@0 | 82 | |
michael@0 | 83 | const kOtherModifierName = [ |
michael@0 | 84 | "CapsLock", "NumLock", "ScrollLock", "SymbolLock", "Fn", "OS", "AltGraph" |
michael@0 | 85 | ]; |
michael@0 | 86 | |
michael@0 | 87 | const kInvalidModifierName = [ |
michael@0 | 88 | "shift", "control", "alt", "meta", "capslock", "numlock", "scrolllock", |
michael@0 | 89 | "symbollock", "fn", "os", "altgraph", "Invalid", "Shift Control", |
michael@0 | 90 | "Win", "Scroll" |
michael@0 | 91 | ]; |
michael@0 | 92 | |
michael@0 | 93 | for (var i = 0; i < kTests.length; i++) { |
michael@0 | 94 | var description = "testInitializingUntrustedEvent, Index: " + i + ", "; |
michael@0 | 95 | const kTest = kTests[i]; |
michael@0 | 96 | var e = document.createEvent(kTest.createEventArg); |
michael@0 | 97 | e.initMouseEvent(kTest.type, kTest.bubbles, kTest.cancelable, kTest.view, |
michael@0 | 98 | kTest.detail, kTest.screenX, kTest.screenY, kTest.clientX, kTest.clientY, |
michael@0 | 99 | kTest.ctrlKey, kTest.altKey, kTest.shiftKey, kTest.metaKey, |
michael@0 | 100 | kTest.button, kTest.relatedTarget); |
michael@0 | 101 | |
michael@0 | 102 | for (var attr in kTest) { |
michael@0 | 103 | if (attr == "createEventArg") { |
michael@0 | 104 | continue; |
michael@0 | 105 | } |
michael@0 | 106 | is(e[attr], kTest[attr], description + attr + " returns wrong value"); |
michael@0 | 107 | } |
michael@0 | 108 | is(e.isTrusted, false, description + "isTrusted returns wrong value"); |
michael@0 | 109 | is(e.buttons, 0, description + "buttons returns wrong value"); |
michael@0 | 110 | |
michael@0 | 111 | // getModifierState() tests |
michael@0 | 112 | is(e.getModifierState("Shift"), kTest.shiftKey, |
michael@0 | 113 | description + "getModifierState(\"Shift\") returns wrong value"); |
michael@0 | 114 | is(e.getModifierState("Control"), kTest.ctrlKey, |
michael@0 | 115 | description + "getModifierState(\"Control\") returns wrong value"); |
michael@0 | 116 | is(e.getModifierState("Alt"), kTest.altKey, |
michael@0 | 117 | description + "getModifierState(\"Alt\") returns wrong value"); |
michael@0 | 118 | is(e.getModifierState("Meta"), kTest.metaKey, |
michael@0 | 119 | description + "getModifierState(\"Meta\") returns wrong value"); |
michael@0 | 120 | |
michael@0 | 121 | for (var j = 0; j < kOtherModifierName.length; j++) { |
michael@0 | 122 | ok(!e.getModifierState(kOtherModifierName[j]), |
michael@0 | 123 | description + "getModifierState(\"" + kOtherModifierName[j] + "\") returns wrong value"); |
michael@0 | 124 | } |
michael@0 | 125 | for (var k = 0; k < kInvalidModifierName.length; k++) { |
michael@0 | 126 | ok(!e.getModifierState(kInvalidModifierName[k]), |
michael@0 | 127 | description + "getModifierState(\"" + kInvalidModifierName[k] + "\") returns wrong value"); |
michael@0 | 128 | } |
michael@0 | 129 | } |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | function runTests() |
michael@0 | 133 | { |
michael@0 | 134 | testInitializingUntrustedEvent(); |
michael@0 | 135 | SimpleTest.finish(); |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | </script> |
michael@0 | 139 | </pre> |
michael@0 | 140 | </body> |
michael@0 | 141 | </html> |