2020-07-15 01:29:15 +02:00
|
|
|
set_global("$", global.make_zjquery());
|
2018-07-23 00:45:46 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
zrequire("keydown_util");
|
2018-07-23 00:45:46 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
run_test("test_early_returns", () => {
|
|
|
|
const stub = $.create("stub");
|
2018-12-04 19:15:31 +01:00
|
|
|
const opts = {
|
2018-07-23 00:45:46 +02:00
|
|
|
elem: stub,
|
2018-12-04 19:15:31 +01:00
|
|
|
handlers: {
|
|
|
|
left_arrow: () => {
|
2020-07-15 01:29:15 +02:00
|
|
|
throw Error("do not dispatch this with alt key");
|
2018-12-04 19:15:31 +01:00
|
|
|
},
|
|
|
|
},
|
2018-07-23 00:45:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
keydown_util.handle(opts);
|
|
|
|
|
2018-12-04 19:15:31 +01:00
|
|
|
const e1 = {
|
2020-07-20 21:24:26 +02:00
|
|
|
type: "keydown",
|
2018-07-23 00:45:46 +02:00
|
|
|
which: 17, // not in keys
|
|
|
|
};
|
|
|
|
|
2020-07-20 21:24:26 +02:00
|
|
|
stub.trigger(e1);
|
2018-07-23 00:45:46 +02:00
|
|
|
|
2018-12-04 19:15:31 +01:00
|
|
|
const e2 = {
|
2020-07-20 21:24:26 +02:00
|
|
|
type: "keydown",
|
2018-07-23 00:45:46 +02:00
|
|
|
which: 13, // no handler
|
|
|
|
};
|
|
|
|
|
2020-07-20 21:24:26 +02:00
|
|
|
stub.trigger(e2);
|
2018-12-04 19:15:31 +01:00
|
|
|
|
|
|
|
const e3 = {
|
2020-07-20 21:24:26 +02:00
|
|
|
type: "keydown",
|
2018-12-04 19:15:31 +01:00
|
|
|
which: 37,
|
|
|
|
altKey: true, // let browser handle
|
|
|
|
};
|
|
|
|
|
2020-07-20 21:24:26 +02:00
|
|
|
stub.trigger(e3);
|
2018-07-23 00:45:46 +02:00
|
|
|
});
|