mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 999645 Cancel implementing KeyboardEvent.initKeyboardEvent() because it completely breaks feature detection in web apps r=smaug
This commit is contained in:
parent
237eb0b915
commit
4d85cc932c
@ -276,28 +276,6 @@ KeyboardEvent::InitKeyEvent(const nsAString& aType,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardEvent::InitKeyboardEvent(const nsAString& aType,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
nsIDOMWindow* aView,
|
||||
uint32_t aDetail,
|
||||
const nsAString& aKey,
|
||||
uint32_t aLocation,
|
||||
const nsAString& aModifiersList,
|
||||
bool aRepeat,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
aRv = UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
|
||||
|
||||
WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent();
|
||||
keyEvent->modifiers = UIEvent::ComputeModifierState(aModifiersList);
|
||||
keyEvent->location = aLocation;
|
||||
keyEvent->mIsRepeat = aRepeat;
|
||||
keyEvent->mKeyNameIndex = KEY_NAME_INDEX_USE_STRING;
|
||||
keyEvent->mKeyValue = aKey;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -69,13 +69,6 @@ public:
|
||||
aKeyCode, aCharCode);
|
||||
}
|
||||
|
||||
void InitKeyboardEvent(const nsAString& aType,
|
||||
bool aCanBubble, bool aCancelable,
|
||||
nsIDOMWindow* aView, uint32_t aDetail,
|
||||
const nsAString& aKey, uint32_t aLocation,
|
||||
const nsAString& aModifiersList, bool aRepeat,
|
||||
ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
// True, if the instance is created with Constructor().
|
||||
bool mInitializedByCtor;
|
||||
|
@ -20,126 +20,55 @@ SimpleTest.waitForFocus(runTests, window);
|
||||
function testInitializingUntrustedEvent()
|
||||
{
|
||||
const kTests = [
|
||||
// initKeyEvent
|
||||
{ createEventArg: "KeyboardEvent", useInitKeyboardEvent: false,
|
||||
{ createEventArg: "KeyboardEvent",
|
||||
type: "keydown", bubbles: true, cancelable: true, view: null,
|
||||
ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
|
||||
keyCode: 0x00, charCode: 0x00,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 0
|
||||
keyCode: 0x00, charCode: 0x00 },
|
||||
|
||||
{ createEventArg: "keyboardevent", useInitKeyboardEvent: false,
|
||||
{ createEventArg: "keyboardevent",
|
||||
type: "keyup", bubbles: false, cancelable: true, view: window,
|
||||
ctrlKey: true, altKey: false, shiftKey: false, metaKey: false,
|
||||
keyCode: 0x10, charCode: 0x00,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 1
|
||||
keyCode: 0x10, charCode: 0x00 },
|
||||
|
||||
{ createEventArg: "Keyboardevent", useInitKeyboardEvent: false,
|
||||
{ createEventArg: "Keyboardevent",
|
||||
type: "keypess", bubbles: true, cancelable: false, view: null,
|
||||
ctrlKey: false, altKey: true, shiftKey: false, metaKey: false,
|
||||
keyCode: 0x11, charCode: 0x30,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 2
|
||||
keyCode: 0x11, charCode: 0x30 },
|
||||
|
||||
{ createEventArg: "keyboardEvent", useInitKeyboardEvent: false,
|
||||
{ createEventArg: "keyboardEvent",
|
||||
type: "boo", bubbles: false, cancelable: false, view: window,
|
||||
ctrlKey: false, altKey: false, shiftKey: true, metaKey: false,
|
||||
keyCode: 0x30, charCode: 0x40,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 3
|
||||
keyCode: 0x30, charCode: 0x40 },
|
||||
|
||||
{ createEventArg: "KeyEvents", useInitKeyboardEvent: false,
|
||||
{ createEventArg: "KeyEvents",
|
||||
type: "foo", bubbles: true, cancelable: true, view: null,
|
||||
ctrlKey: false, altKey: false, shiftKey: false, metaKey: true,
|
||||
keyCode: 0x00, charCode: 0x50,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 4
|
||||
keyCode: 0x00, charCode: 0x50 },
|
||||
|
||||
{ createEventArg: "keyevents", useInitKeyboardEvent: false,
|
||||
{ createEventArg: "keyevents",
|
||||
type: "bar", bubbles: false, cancelable: true, view: window,
|
||||
ctrlKey: true, altKey: true, shiftKey: false, metaKey: false,
|
||||
keyCode: 0x00, charCode: 0x60,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 5
|
||||
keyCode: 0x00, charCode: 0x60 },
|
||||
|
||||
{ createEventArg: "Keyevents", useInitKeyboardEvent: false,
|
||||
{ createEventArg: "Keyevents",
|
||||
type: "keydown", bubbles: true, cancelable: false, view: null,
|
||||
ctrlKey: false, altKey: true, shiftKey: false, metaKey: true,
|
||||
keyCode: 0x30, charCode: 0x00,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 6
|
||||
keyCode: 0x30, charCode: 0x00 },
|
||||
|
||||
{ createEventArg: "keyEvents", useInitKeyboardEvent: false,
|
||||
{ createEventArg: "keyEvents",
|
||||
type: "keyup", bubbles: false, cancelable: false, view: window,
|
||||
ctrlKey: true, altKey: false, shiftKey: true, metaKey: false,
|
||||
keyCode: 0x10, charCode: 0x80,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 7
|
||||
keyCode: 0x10, charCode: 0x80 },
|
||||
|
||||
{ createEventArg: "KeyboardEvent", useInitKeyboardEvent: false,
|
||||
{ createEventArg: "KeyboardEvent",
|
||||
type: "keypress", bubbles: false, cancelable: false, view: window,
|
||||
ctrlKey: true, altKey: false, shiftKey: true, metaKey: true,
|
||||
keyCode: 0x10, charCode: 0x80,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 8
|
||||
keyCode: 0x10, charCode: 0x80 },
|
||||
|
||||
{ createEventArg: "KeyboardEvent", useInitKeyboardEvent: false,
|
||||
{ createEventArg: "KeyboardEvent",
|
||||
type: "foo", bubbles: false, cancelable: false, view: window,
|
||||
ctrlKey: true, altKey: true, shiftKey: true, metaKey: true,
|
||||
keyCode: 0x10, charCode: 0x80,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 9
|
||||
|
||||
// initKeyboardEvent
|
||||
{ createEventArg: "KeyboardEvent", useInitKeyboardEvent: true,
|
||||
type: "keydown", bubbles: true, cancelable: true, view: null,
|
||||
ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
|
||||
keyCode: 0x00, charCode: 0x00,
|
||||
detail: 0, key: "", location: 0, modifiersList: "", repeat: false,
|
||||
}, // 10
|
||||
|
||||
{ createEventArg: "keyboardevent", useInitKeyboardEvent: true,
|
||||
type: "keyup", bubbles: false, cancelable: true, view: window,
|
||||
ctrlKey: true, altKey: false, shiftKey: false, metaKey: false,
|
||||
keyCode: 0x00, charCode: 0x00,
|
||||
detail: 2, key: "Unidentified", location: 1, modifiersList: "Control", repeat: false,
|
||||
}, // 11
|
||||
|
||||
{ createEventArg: "Keyboardevent", useInitKeyboardEvent: true,
|
||||
type: "keypess", bubbles: true, cancelable: false, view: null,
|
||||
ctrlKey: false, altKey: true, shiftKey: false, metaKey: false,
|
||||
keyCode: 0x00, charCode: 0x00,
|
||||
detail: 0, key: "FooBar", location: 2, modifiersList: "Alt", repeat: true,
|
||||
}, // 12
|
||||
|
||||
{ createEventArg: "keyboardevent", useInitKeyboardEvent: true,
|
||||
type: "foo", bubbles: true, cancelable: true, view: null,
|
||||
ctrlKey: false, altKey: false, shiftKey: false, metaKey: true,
|
||||
keyCode: 0x00, charCode: 0x00,
|
||||
detail: 0, key: "a", location: 0, modifiersList: "Meta", repeat: false,
|
||||
}, // 13
|
||||
|
||||
{ createEventArg: "Keyevents", useInitKeyboardEvent: true,
|
||||
type: "", bubbles: false, cancelable: false, view: null,
|
||||
ctrlKey: true, altKey: true, shiftKey: true, metaKey: true,
|
||||
keyCode: 0x00, charCode: 0x00,
|
||||
detail: 0, key: "3", location: 0, modifiersList: "Control Alt Meta Shift", repeat: true,
|
||||
}, // 14
|
||||
|
||||
{ createEventArg: "keyevents", useInitKeyboardEvent: true,
|
||||
type: "", bubbles: false, cancelable: false, view: null,
|
||||
ctrlKey: false, altKey: false, shiftKey: true, metaKey: false,
|
||||
keyCode: 0x00, charCode: 0x00,
|
||||
detail: 0, key: "3", location: 6, modifiersList: "Shift", repeat: true,
|
||||
}, // 15
|
||||
|
||||
{ createEventArg: "keyevents", useInitKeyboardEvent: true,
|
||||
type: "", bubbles: false, cancelable: false, view: null,
|
||||
ctrlKey: false, altKey: true, shiftKey: false, metaKey: false,
|
||||
keyCode: 0x00, charCode: 0x00,
|
||||
detail: 0, key: "", location: 4, modifiersList: "Shift, Alt", repeat: false,
|
||||
}, // 16
|
||||
keyCode: 0x10, charCode: 0x80 },
|
||||
];
|
||||
|
||||
const kOtherModifierName = [
|
||||
@ -156,23 +85,17 @@ function testInitializingUntrustedEvent()
|
||||
var description = "testInitializingUntrustedEvent, Index: " + i + ", ";
|
||||
const kTest = kTests[i];
|
||||
var e = document.createEvent(kTest.createEventArg);
|
||||
if (kTest.useInitKeyboardEvent) {
|
||||
// IE has extra argument for |.locale|. Calling with it shouldn't cause error for compatibility with IE.
|
||||
e.initKeyboardEvent(kTest.type, kTest.bubbles, kTest.cancelable, kTest.view, kTest.detail,
|
||||
kTest.key, kTest.location, kTest.modifiersList, kTest.repeat, "locale");
|
||||
} else {
|
||||
e.initKeyEvent(kTest.type, kTest.bubbles, kTest.cancelable, kTest.view,
|
||||
kTest.ctrlKey, kTest.altKey, kTest.shiftKey, kTest.metaKey,
|
||||
kTest.keyCode, kTest.charCode);
|
||||
}
|
||||
e.initKeyEvent(kTest.type, kTest.bubbles, kTest.cancelable, kTest.view,
|
||||
kTest.ctrlKey, kTest.altKey, kTest.shiftKey, kTest.metaKey,
|
||||
kTest.keyCode, kTest.charCode);
|
||||
is(e.toString(), "[object KeyboardEvent]",
|
||||
description + 'class string should be "KeyboardEvent"');
|
||||
|
||||
for (var attr in kTest) {
|
||||
if (attr == "createEventArg" || attr == "useInitKeyboardEvent" || attr == "modifiersList") {
|
||||
if (attr == "createEventArg") {
|
||||
continue;
|
||||
}
|
||||
if (!kTest.useInitKeyboardEvent && attr == "keyCode") {
|
||||
if (attr == "keyCode") {
|
||||
// If this is keydown, keyup of keypress event, keycod must be correct.
|
||||
if (kTest.type == "keydown" || kTest.type == "keyup" || kTest.type == "keypress") {
|
||||
is(e[attr], kTest[attr], description + attr + " returns wrong value");
|
||||
@ -180,7 +103,7 @@ function testInitializingUntrustedEvent()
|
||||
} else {
|
||||
is(e[attr], 0, description + attr + " returns non-zero for invalid event");
|
||||
}
|
||||
} else if (!kTest.useInitKeyboardEvent && attr == "charCode") {
|
||||
} else if (attr == "charCode") {
|
||||
// If this is keydown or keyup event, charCode always 0.
|
||||
if (kTest.type == "keydown" || kTest.type == "keyup") {
|
||||
is(e[attr], 0, description + attr + " returns non-zero for keydown or keyup event");
|
||||
@ -199,6 +122,9 @@ function testInitializingUntrustedEvent()
|
||||
}
|
||||
is(e.isTrusted, false, description + "isTrusted returns wrong value");
|
||||
|
||||
// Currently, there is no way to initialize char and key attribute values.
|
||||
ok(e.key === "", description + "key must return empty string - got " + e.key);
|
||||
|
||||
// getModifierState() tests
|
||||
is(e.getModifierState("Shift"), kTest.shiftKey,
|
||||
description + "getModifierState(\"Shift\") returns wrong value");
|
||||
|
@ -31,17 +31,6 @@ interface KeyboardEvent : UIEvent
|
||||
readonly attribute boolean isComposing;
|
||||
|
||||
readonly attribute DOMString key;
|
||||
|
||||
[Throws]
|
||||
void initKeyboardEvent(DOMString typeArg,
|
||||
boolean bubblesArg,
|
||||
boolean cancelableArg,
|
||||
WindowProxy? viewArg,
|
||||
long detailArg,
|
||||
DOMString keyArg,
|
||||
unsigned long locationArg,
|
||||
DOMString modifiersListArg,
|
||||
boolean repeatArg);
|
||||
};
|
||||
|
||||
dictionary KeyboardEventInit : UIEventInit
|
||||
|
Loading…
Reference in New Issue
Block a user