nadesiko3 3.3.45 → 3.3.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +143 -132
- package/batch/browsers.template.md +3 -3
- package/batch/build_browsers.nako3 +72 -72
- package/batch/build_command.nako3 +44 -44
- package/batch/build_nako_version.nako3 +42 -42
- package/batch/calc_hash.nako3 +29 -29
- package/batch/cmd_txt2json.nako3 +74 -74
- package/batch/command.txt +270 -338
- package/batch/command_nakopad.txt +9 -69
- package/batch/download-extlib.nako3 +43 -43
- package/batch/gen_command_nakopad.nako3 +57 -57
- package/batch/jsplugin2text.nako3 +285 -285
- package/batch/pickup_command.nako3 +110 -110
- package/batch/pickup_reserved_words.nako3 +11 -11
- package/batch/publish_version.nako3 +46 -46
- package/batch/show_agents.js +14 -14
- package/batch/turtle2js.nako3 +21 -21
- package/bin/cnako3 +10 -10
- package/core/.editorconfig +6 -0
- package/core/.eslintrc.cjs +33 -0
- package/core/.github/dependabot.yml +7 -0
- package/core/.github/workflows/nodejs.yml +37 -0
- package/core/.github/workflows/super-linter.yml +61 -0
- package/core/.github/workflows/textlint.yml +199 -0
- package/core/LICENSE +21 -0
- package/core/README.md +66 -0
- package/core/batch/build_nako_version.nako3 +42 -0
- package/core/command/snako.mjs +105 -0
- package/core/command/snako.mts +116 -0
- package/core/index.mjs +21 -0
- package/core/index.mts +21 -0
- package/core/package.json +47 -0
- package/core/sample/hello.nako3 +7 -0
- package/core/sample/hoge.mjs +4 -0
- package/core/sample/hoge.mts +6 -0
- package/core/src/nako3.mjs +858 -0
- package/core/src/nako3.mts +967 -0
- package/core/src/nako_colors.mjs +78 -0
- package/core/src/nako_colors.mts +86 -0
- package/core/src/nako_core_version.mjs +8 -0
- package/core/src/nako_core_version.mts +19 -0
- package/core/src/nako_csv.mjs +185 -0
- package/core/src/nako_csv.mts +188 -0
- package/core/src/nako_errors.mjs +173 -0
- package/core/src/nako_errors.mts +197 -0
- package/core/src/nako_from_dncl.mjs +255 -0
- package/core/src/nako_from_dncl.mts +250 -0
- package/core/src/nako_gen.mjs +1648 -0
- package/core/src/nako_gen.mts +1719 -0
- package/core/src/nako_gen_async.mjs +1659 -0
- package/core/src/nako_gen_async.mts +1732 -0
- package/core/src/nako_global.mjs +107 -0
- package/core/src/nako_global.mts +138 -0
- package/core/src/nako_indent.mjs +445 -0
- package/core/src/nako_indent.mts +492 -0
- package/core/src/nako_josi_list.mjs +38 -0
- package/core/src/nako_josi_list.mts +45 -0
- package/core/src/nako_lex_rules.mjs +253 -0
- package/core/src/nako_lex_rules.mts +260 -0
- package/core/src/nako_lexer.mjs +609 -0
- package/core/src/nako_lexer.mts +612 -0
- package/core/src/nako_logger.mjs +199 -0
- package/core/src/nako_logger.mts +232 -0
- package/core/src/nako_parser3.mjs +2439 -0
- package/core/src/nako_parser3.mts +2195 -0
- package/core/src/nako_parser_base.mjs +370 -0
- package/core/src/nako_parser_base.mts +370 -0
- package/core/src/nako_parser_const.mjs +37 -0
- package/core/src/nako_parser_const.mts +37 -0
- package/core/src/nako_prepare.mjs +304 -0
- package/core/src/nako_prepare.mts +315 -0
- package/core/src/nako_reserved_words.mjs +38 -0
- package/core/src/nako_reserved_words.mts +38 -0
- package/core/src/nako_source_mapping.mjs +207 -0
- package/core/src/nako_source_mapping.mts +262 -0
- package/core/src/nako_test.mjs +37 -0
- package/core/src/nako_types.mjs +25 -0
- package/core/src/nako_types.mts +151 -0
- package/core/src/plugin_csv.mjs +49 -0
- package/core/src/plugin_csv.mts +50 -0
- package/core/src/plugin_math.mjs +328 -0
- package/core/src/plugin_math.mts +326 -0
- package/core/src/plugin_promise.mjs +91 -0
- package/core/src/plugin_promise.mts +91 -0
- package/core/src/plugin_system.mjs +2832 -0
- package/core/src/plugin_system.mts +2690 -0
- package/core/src/plugin_test.mjs +34 -0
- package/core/src/plugin_test.mts +34 -0
- package/core/test/array_test.mjs +34 -0
- package/core/test/basic_test.mjs +344 -0
- package/core/test/calc_test.mjs +140 -0
- package/core/test/core_module_test.mjs +23 -0
- package/core/test/debug_test.mjs +16 -0
- package/core/test/dncl_test.mjs +94 -0
- package/core/test/error_message_test.mjs +210 -0
- package/core/test/error_test.mjs +16 -0
- package/core/test/flow_test.mjs +373 -0
- package/core/test/func_call.mjs +160 -0
- package/core/test/func_test.mjs +149 -0
- package/core/test/indent_test.mjs +364 -0
- package/core/test/lex_test.mjs +168 -0
- package/core/test/literal_test.mjs +73 -0
- package/core/test/nako_lexer_test.mjs +35 -0
- package/core/test/nako_logger_test.mjs +76 -0
- package/core/test/nako_logger_test.mts +78 -0
- package/core/test/plugin_csv_test.mjs +38 -0
- package/core/test/plugin_promise_test.mjs +18 -0
- package/core/test/plugin_system_test.mjs +630 -0
- package/core/test/prepare_test.mjs +96 -0
- package/core/test/re_test.mjs +22 -0
- package/core/test/side_effects_test.mjs +92 -0
- package/core/test/variable_scope_test.mjs +149 -0
- package/core/tsconfig.json +101 -0
- package/demo/ace_editor.html +89 -89
- package/demo/ace_editor_tabs.html +161 -161
- package/demo/basic.html +71 -71
- package/demo/browsers.html +9 -10
- package/demo/css/basic.css +3 -3
- package/demo/css/common.css +157 -157
- package/demo/css/editor.css +8 -8
- package/demo/css/flow.css +3 -3
- package/demo/css/index.css +3 -3
- package/demo/flow.html +98 -98
- package/demo/graph.html +53 -53
- package/demo/image/nakopad-icon256.png +0 -0
- package/demo/index.html +133 -133
- package/demo/js/common.js +17 -17
- package/demo/js/turtle3d_test.js +44 -44
- package/demo/js/turtle_test.js +45 -45
- package/demo/nako3/calc.nako3 +4 -4
- package/demo/runscript.html +47 -47
- package/demo/runscript2.html +33 -33
- package/demo/runscript3.html +35 -35
- package/demo/runscript4.html +33 -33
- package/demo/turtle.html +58 -58
- package/demo/turtle2.html +141 -141
- package/demo/turtle3.html +279 -279
- package/demo/turtle3d.html +58 -58
- package/demo/turtle3d2.html +107 -107
- package/demo/version.html +24 -24
- package/doc/SETUP.md +157 -157
- package/doc/about.md +17 -17
- package/doc/browsers.md +26 -26
- package/doc/docgen.md +21 -21
- package/doc/editor.md +44 -44
- package/doc/files.md +39 -39
- package/doc/plugins.md +234 -234
- package/doc/release.md +79 -79
- package/doc/textlint.md +43 -43
- package/doc/win32.md +57 -57
- package/package.json +195 -192
- package/release/_hash.txt +28 -28
- package/release/_script-tags.txt +14 -14
- package/release/command.json +1 -1
- package/release/command.json.js +1 -1
- package/release/command_cnako3.json +1 -1
- package/release/command_list.json +1 -1
- package/release/editor.js +1 -1
- package/release/nako_gen_async.js +1 -1
- package/release/plugin_csv.js +1 -1
- package/release/stats.json +1 -1
- package/release/version.js +1 -1
- package/release/wnako3.js +1 -1
- package/release/wnako3webworker.js +1 -1
- package/src/browsers.txt +11 -12
- package/src/browsers_agents.json +2 -2
- package/src/browsers_agents.mjs +1 -1
- package/src/cnako3.mjs +17 -10
- package/src/cnako3.mts +18 -12
- package/src/cnako3mod.mjs +707 -687
- package/src/cnako3mod.mts +712 -696
- package/src/commander_ja.mjs +164 -164
- package/src/commander_ja.mts +161 -161
- package/src/enako3.mjs +68 -69
- package/src/era.mjs +22 -22
- package/src/image_turtle-elephant.mjs +2 -5
- package/src/image_turtle-panda.mjs +2 -5
- package/src/image_turtle64.mjs +2 -5
- package/src/index.mjs +9 -9
- package/src/index.mts +10 -11
- package/src/nako3editorfix.sfd +106 -106
- package/src/nako_version.mjs +8 -8
- package/src/nako_version.mts +2 -2
- package/src/plugin_browser.mjs +213 -212
- package/src/plugin_browser.mts +206 -205
- package/src/plugin_browser_ajax.mjs +399 -399
- package/src/plugin_browser_audio.mjs +109 -109
- package/src/plugin_browser_canvas.mjs +449 -449
- package/src/plugin_browser_chart.mjs +294 -294
- package/src/plugin_browser_color.mjs +49 -49
- package/src/plugin_browser_crypto.mjs +26 -26
- package/src/plugin_browser_dialog.mjs +53 -53
- package/src/plugin_browser_dom_basic.mjs +336 -336
- package/src/plugin_browser_dom_event.mjs +193 -193
- package/src/plugin_browser_dom_parts.mjs +396 -396
- package/src/plugin_browser_geolocation.mjs +51 -51
- package/src/plugin_browser_hotkey.mjs +25 -25
- package/src/plugin_browser_html.mjs +59 -59
- package/src/plugin_browser_in_worker.mjs +45 -45
- package/src/plugin_browser_location.mjs +21 -21
- package/src/plugin_browser_speech.mjs +111 -111
- package/src/plugin_browser_storage.mjs +121 -121
- package/src/plugin_browser_system.mjs +31 -31
- package/src/plugin_browser_websocket.mjs +73 -73
- package/src/plugin_caniuse.mjs +29 -29
- package/src/plugin_datetime.mjs +394 -394
- package/src/plugin_httpserver.mjs +277 -0
- package/src/plugin_httpserver.mts +286 -0
- package/src/plugin_kansuji.mjs +224 -224
- package/src/plugin_keigo.mjs +55 -55
- package/src/plugin_markup.mjs +32 -32
- package/src/plugin_node.mjs +1047 -1047
- package/src/plugin_node.mts +980 -980
- package/src/plugin_turtle.mjs +647 -647
- package/src/plugin_webworker.mjs +334 -334
- package/src/plugin_weykturtle3d.mjs +1214 -1214
- package/src/plugin_worker.mjs +95 -95
- package/src/repl.nako3 +63 -63
- package/src/wnako3.mjs +12 -12
- package/src/wnako3.mts +11 -11
- package/src/wnako3_editor.css +215 -215
- package/src/wnako3_editor.mjs +1542 -1542
- package/src/wnako3_editor.mts +1657 -1656
- package/src/wnako3mod.mjs +213 -213
- package/src/wnako3mod.mts +214 -214
- package/src/wnako3webworker.mjs +69 -68
- package/test/ace_editor/karma.config.js +94 -94
- package/test/ace_editor/test/.babelrc.json +3 -3
- package/test/ace_editor/test/ace_editor_test.js +178 -178
- package/test/ace_editor/test/html/custom_context.html +139 -139
- package/test/async/async_basic_test.mjs +122 -122
- package/test/browser/karma.config.js +221 -221
- package/test/browser/test/.babelrc.json +3 -3
- package/test/browser/test/compare_util.js +50 -50
- package/test/browser/test/html/div_basic.html +2 -2
- package/test/browser/test/html/event_dom_form.html +4 -4
- package/test/browser/test/html/event_dom_scrolldiv.html +5 -5
- package/test/browser/test/import_plugin_checker.js +24 -24
- package/test/browser/test/plugin_browser_test.js +51 -51
- package/test/browser/test/plugin_browser_test_ajax.js +123 -123
- package/test/browser/test/plugin_browser_test_color.js +18 -18
- package/test/browser/test/plugin_browser_test_dialog.js +72 -72
- package/test/browser/test/plugin_browser_test_dom_event.js +598 -598
- package/test/browser/test/plugin_browser_test_dom_parts.js +125 -125
- package/test/browser/test/plugin_browser_test_system.js +9 -9
- package/test/browser/test/plugin_turtle_test.js +817 -817
- package/test/browser/test/plugin_webworker_test.js +86 -86
- package/test/browser/test/require_test.js +68 -68
- package/test/bundled/karma.config.base.js +117 -117
- package/test/bundled/karma.config.js +86 -86
- package/test/bundled/test/.babelrc.json +3 -3
- package/test/bundled/test/bundled_test.js +69 -69
- package/test/bundled/test/html/custom_context.html +65 -65
- package/test/bundled/test/html/custom_debug.html +66 -66
- package/test/bundled/test4b.cmd +52 -52
- package/test/bundled/test_base/.babelrc.json +3 -3
- package/test/bundled/test_base/_checktool_test.js +25 -25
- package/test/bundled/test_base/basic_ajax_test.js +56 -56
- package/test/bundled/test_base/basic_async_test.js +18 -18
- package/test/bundled/test_base/basic_test.js +153 -153
- package/test/bundled/test_base/calc_test.js +132 -132
- package/test/bundled/test_base/css/browsers_box.css +114 -114
- package/test/bundled/test_base/html/custom_context.html +69 -69
- package/test/bundled/test_base/html/custom_debug.html +71 -71
- package/test/bundled/test_base/js/browsers_box.js +72 -72
- package/test/bundled/test_base/plugin_csv_test.js +37 -37
- package/test/bundled/test_base/plugin_datetime_test.js +115 -115
- package/test/bundled/test_base/plugin_kansuji_test.js +49 -49
- package/test/bundled/test_base/plugin_system_test.js +410 -410
- package/test/bundled/test_base/plugin_webworker_test.js +53 -53
- package/test/bundled/test_base/test_utils.js +191 -191
- package/test/common/plugin_browser_test.mjs +22 -24
- package/test/common/plugin_browser_ut_audio_test.mjs +108 -108
- package/test/common/plugin_browser_ut_color_test.mjs +21 -21
- package/test/common/plugin_browser_ut_dialog_test.mjs +100 -100
- package/test/common/plugin_browser_ut_html_test.mjs +13 -13
- package/test/common/plugin_browser_ut_system_test.mjs +10 -10
- package/test/common/plugin_markup_test.mjs +23 -23
- package/test/jsconfig.json +19 -19
- package/test/karma.config.js +91 -91
- package/test/node/async_test.mjs +96 -82
- package/test/node/commander_ja_test.mjs +89 -89
- package/test/node/error_message_test.mjs +243 -253
- package/test/node/kai_test.nako3 +6 -6
- package/test/node/node_test.mjs +60 -60
- package/test/node/plugin_broken.js.txt +3 -3
- package/test/node/plugin_browser_ut_ajax_test.mjs.todo +357 -357
- package/test/node/plugin_browser_ut_location_test.mjs +42 -42
- package/test/node/plugin_markup_test.mjs +47 -46
- package/test/node/plugin_math_test.mjs +45 -44
- package/test/node/plugin_node_test.mjs +98 -97
- package/test/node/plugin_test.mjs +44 -43
- package/test/node/relative_import_test_1.nako3 +1 -1
- package/test/node/relative_import_test_2.nako3 +2 -2
- package/test/node/require_nako3_test.mjs +67 -66
- package/test/node/requiretest.nako3 +4 -4
- package/test/node/requiretest_indirect.nako3 +1 -1
- package/test/node/requiretest_name.nako3 +5 -5
- package/test/node/runtime_error.nako3 +2 -2
- package/test/node/scope1.nako3 +10 -10
- package/test/node/scope2.nako3 +12 -12
- package/test/node/side_effects_test.mjs +39 -119
- package/test/node/sjis.txt +5 -5
- package/test/node/syntax_error.nako3 +1 -1
- package/test/node/wnako3_editor_test.mjs +384 -384
- package/tools/README.md +12 -7
- package/tools/check_new_version.nako3 +25 -25
- package/tools/nako3edit/html/daisyui/LICENSE +22 -22
- package/tools/nako3edit/html/daisyui/version_2.14.1 +1 -1
- package/tools/nako3edit/html/edit.html +170 -170
- package/tools/nako3edit/html/edit_plugin.js +6 -6
- package/tools/nako3edit/html/files.html +125 -125
- package/tools/nako3edit/html/nako3edit.css +65 -65
- package/tools/nako3edit/index.mjs +248 -244
- package/tools/nako3server/index.html +10 -0
- package/tools/nako3server/index.mjs +116 -116
- package/tools/nako3server/index.nako3 +34 -0
- package/release/nako_gen_async.js.LICENSE.txt +0 -35
- package/release/plugin_caniuse.js.LICENSE.txt +0 -11
- package/release/plugin_csv.js.LICENSE.txt +0 -15
- package/release/plugin_datetime.js.LICENSE.txt +0 -15
- package/release/plugin_kansuji.js.LICENSE.txt +0 -3
- package/release/plugin_markup.js.LICENSE.txt +0 -11
- package/release/plugin_turtle.js.LICENSE.txt +0 -15
- package/release/plugin_webworker.js.LICENSE.txt +0 -3
- package/release/plugin_weykturtle3d.js.LICENSE.txt +0 -3
- package/release/wnako3webworker.js.LICENSE.txt +0 -131
- package/tools/nako3edit/a.sqlite3 +0 -0
|
@@ -1,598 +1,598 @@
|
|
|
1
|
-
/* global __html__ */
|
|
2
|
-
import { CompareUtil, waitTimer, assert } from './compare_util'
|
|
3
|
-
|
|
4
|
-
const htmlPath = 'test/html/'
|
|
5
|
-
|
|
6
|
-
export default (nako) => {
|
|
7
|
-
const cu = new CompareUtil(nako)
|
|
8
|
-
|
|
9
|
-
describe('DOMイベント', () => {
|
|
10
|
-
describe('汎用命令', () => {
|
|
11
|
-
const createMouseEvent = (type, t) => {
|
|
12
|
-
const box = t.target.getBoundingClientRect()
|
|
13
|
-
const x = 30
|
|
14
|
-
const y = 10
|
|
15
|
-
if (MouseEvent && MouseEvent.length > 0) {
|
|
16
|
-
return new MouseEvent(type, {
|
|
17
|
-
view: window,
|
|
18
|
-
bubbles: true,
|
|
19
|
-
cancelable: true,
|
|
20
|
-
button: t.btn || 0,
|
|
21
|
-
buttons: t.btns || 1,
|
|
22
|
-
clientX: box.left + x,
|
|
23
|
-
clientY: box.top + y,
|
|
24
|
-
screenX: window.screenLeft + box.left + x,
|
|
25
|
-
screenY: window.screenTop + box.top + y,
|
|
26
|
-
pageX: window.scrollX + box.left + x,
|
|
27
|
-
pageY: window.scrollY + box.top + y
|
|
28
|
-
})
|
|
29
|
-
} else {
|
|
30
|
-
const evt = new UIEvent(type, {
|
|
31
|
-
view: window,
|
|
32
|
-
bubbles: true,
|
|
33
|
-
cancelable: true
|
|
34
|
-
})
|
|
35
|
-
evt.button = t.btn || 0,
|
|
36
|
-
evt.buttons = t.btns || 1,
|
|
37
|
-
evt.clientX = box.left + x,
|
|
38
|
-
evt.clientY = box.top + y,
|
|
39
|
-
evt.screenX = window.screenLeft + box.left + x,
|
|
40
|
-
evt.screenY = window.screenTop + box.top + y,
|
|
41
|
-
evt.pageX = window.scrollX + box.left + x,
|
|
42
|
-
evt.pageY = window.scrollY + box.top + y
|
|
43
|
-
return evt
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const check_event_set = (selectmethod) => {
|
|
48
|
-
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
49
|
-
|
|
50
|
-
const code = `
|
|
51
|
-
要素は${selectmethod}
|
|
52
|
-
要素の「onclick」に「ボタンクリック」をDOMイベント設定する。
|
|
53
|
-
●ボタンクリックとは
|
|
54
|
-
「C:設定」を報告する。
|
|
55
|
-
ここまで。
|
|
56
|
-
`
|
|
57
|
-
const cr = window.cr
|
|
58
|
-
cr.reset()
|
|
59
|
-
nako.run(code)
|
|
60
|
-
|
|
61
|
-
const e = document.getElementById('button')
|
|
62
|
-
if (e) {
|
|
63
|
-
const evt = createMouseEvent('click', { target: e })
|
|
64
|
-
e.dispatchEvent(evt)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
68
|
-
assert.strictEqual(cr.getMessageAsJson(), '["C:設定"]')
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const check_event_fire = (selectmethod) => {
|
|
72
|
-
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
73
|
-
|
|
74
|
-
const code = `
|
|
75
|
-
要素は${selectmethod}
|
|
76
|
-
要素の「click」がDOMイベント発火した時には、
|
|
77
|
-
「C:設定」を報告する。
|
|
78
|
-
ここまで。
|
|
79
|
-
`
|
|
80
|
-
const cr = window.cr
|
|
81
|
-
cr.reset()
|
|
82
|
-
nako.run(code)
|
|
83
|
-
|
|
84
|
-
const e = document.getElementById('button')
|
|
85
|
-
if (e) {
|
|
86
|
-
const evt = createMouseEvent('click', { target: e })
|
|
87
|
-
e.dispatchEvent(evt)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
91
|
-
assert.strictEqual(cr.getMessageAsJson(), '["C:設定"]')
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const check_event_add = (selectmethod) => {
|
|
95
|
-
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
96
|
-
|
|
97
|
-
const code = `
|
|
98
|
-
要素は${selectmethod}
|
|
99
|
-
要素の「click」に「ボタンクリック」をDOMイベント追加する。
|
|
100
|
-
●ボタンクリックとは
|
|
101
|
-
「C:追加」を報告する。
|
|
102
|
-
ここまで。
|
|
103
|
-
`
|
|
104
|
-
const cr = window.cr
|
|
105
|
-
cr.reset()
|
|
106
|
-
nako.run(code)
|
|
107
|
-
|
|
108
|
-
const e = document.getElementById('button')
|
|
109
|
-
if (e) {
|
|
110
|
-
const evt = createMouseEvent('click', { target: e })
|
|
111
|
-
e.dispatchEvent(evt)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
115
|
-
assert.strictEqual(cr.getMessageAsJson(), '["C:追加"]')
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const check_event_remove = (selectmethod) => {
|
|
119
|
-
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
120
|
-
|
|
121
|
-
const code = `
|
|
122
|
-
要素は${selectmethod}
|
|
123
|
-
要素の「click」に「ボタンクリック」をDOMイベント追加する。
|
|
124
|
-
要素の「click」から「ボタンクリック」をDOMイベント削除する。
|
|
125
|
-
●ボタンクリックとは
|
|
126
|
-
「C:追加」を報告する。
|
|
127
|
-
ここまで。
|
|
128
|
-
`
|
|
129
|
-
const cr = window.cr
|
|
130
|
-
cr.reset()
|
|
131
|
-
nako.run(code)
|
|
132
|
-
|
|
133
|
-
const e = document.getElementById('button')
|
|
134
|
-
if (e) {
|
|
135
|
-
const evt = createMouseEvent('click', { target: e })
|
|
136
|
-
e.dispatchEvent(evt)
|
|
137
|
-
} else {
|
|
138
|
-
assert.fail('要素が見つからないためイベント発火に失敗しました。')
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
assert.ok(!cr.isCalled, 'イベント呼び出し')
|
|
142
|
-
assert.strictEqual(cr.getMessageAsJson(), '[]')
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
it('イベント設定', () => {
|
|
146
|
-
check_event_set('「#button」')
|
|
147
|
-
})
|
|
148
|
-
it('イベント設定 - dom', () => {
|
|
149
|
-
check_event_set('「button」をDOM要素ID取得')
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
it('イベント発火した時', () => {
|
|
153
|
-
check_event_fire('「#button」')
|
|
154
|
-
})
|
|
155
|
-
it('イベント発火した時 - dom', () => {
|
|
156
|
-
check_event_fire('「button」をDOM要素ID取得')
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
it('イベント追加', () => {
|
|
160
|
-
check_event_add('「#button」')
|
|
161
|
-
})
|
|
162
|
-
it('イベント追加 - dom', () => {
|
|
163
|
-
check_event_add('「button」をDOM要素ID取得')
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
it('イベント削除', () => {
|
|
167
|
-
check_event_remove('「#button」')
|
|
168
|
-
})
|
|
169
|
-
it('イベント削除 - dom', () => {
|
|
170
|
-
check_event_remove('「button」をDOM要素ID取得')
|
|
171
|
-
})
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
describe('読み込み時', () => {
|
|
175
|
-
const check_img_load = async (selectmethod) => {
|
|
176
|
-
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
177
|
-
|
|
178
|
-
const code = `
|
|
179
|
-
IMGは「img」のDOM要素作成
|
|
180
|
-
IMG["id"]は「img」
|
|
181
|
-
親は「form」をDOM要素ID取得
|
|
182
|
-
親にIMGをDOM子要素追加
|
|
183
|
-
要素は${selectmethod}
|
|
184
|
-
要素を読み込んだ時には、
|
|
185
|
-
「L:{IMG["naturalWidth"]},{IMG["naturalHeight"]}」を報告する。
|
|
186
|
-
ここまで。
|
|
187
|
-
IMG["src"]は「/turtle.png」
|
|
188
|
-
`
|
|
189
|
-
const cr = window.cr
|
|
190
|
-
cr.reset()
|
|
191
|
-
nako.run(code)
|
|
192
|
-
|
|
193
|
-
await waitTimer(1.0)
|
|
194
|
-
|
|
195
|
-
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
196
|
-
assert.strictEqual(cr.getMessageAsJson(), '["L:64,64"]')
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
it('読み込み時', async () => {
|
|
200
|
-
await check_img_load('「#img」')
|
|
201
|
-
})
|
|
202
|
-
it('読み込み時 - dom', async () => {
|
|
203
|
-
await check_img_load('「img」をDOM要素ID取得')
|
|
204
|
-
})
|
|
205
|
-
it('読み込み時 - image', async () => {
|
|
206
|
-
const code = `
|
|
207
|
-
要素は「new Image()」をJS実行
|
|
208
|
-
要素を読み込んだ時には、
|
|
209
|
-
「I:{要素["naturalWidth"]},{要素["naturalHeight"]}」を報告する。
|
|
210
|
-
ここまで。
|
|
211
|
-
要素["src"]は「/turtle.png」
|
|
212
|
-
`
|
|
213
|
-
const cr = window.cr
|
|
214
|
-
cr.reset()
|
|
215
|
-
nako.run(code)
|
|
216
|
-
|
|
217
|
-
await waitTimer(1.0)
|
|
218
|
-
|
|
219
|
-
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
220
|
-
assert.strictEqual(cr.getMessageAsJson(), '["I:64,64"]')
|
|
221
|
-
})
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
describe('フォーム', () => {
|
|
225
|
-
const createSubmitEvent = (t) => {
|
|
226
|
-
if (SubmitEvent && SubmitEvent.length > 0) {
|
|
227
|
-
return new SubmitEvent('submit', {
|
|
228
|
-
bubbles: true,
|
|
229
|
-
cancelable: true,
|
|
230
|
-
submitter: t.submitter
|
|
231
|
-
})
|
|
232
|
-
} else {
|
|
233
|
-
const evt = new Event('submit', {
|
|
234
|
-
bubbles: true,
|
|
235
|
-
cancelable: true
|
|
236
|
-
})
|
|
237
|
-
evt.submitter = t.submitter
|
|
238
|
-
return evt
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const check_form_submit = (selectmethod) => {
|
|
243
|
-
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
244
|
-
|
|
245
|
-
const code = `
|
|
246
|
-
要素は${selectmethod}
|
|
247
|
-
要素をフォーム送信した時には、
|
|
248
|
-
WINDOW["event"]をDOMイベント処理停止する。
|
|
249
|
-
「SUBMITED」を報告する。
|
|
250
|
-
ここまで。
|
|
251
|
-
`
|
|
252
|
-
const cr = window.cr
|
|
253
|
-
cr.reset()
|
|
254
|
-
nako.run(code)
|
|
255
|
-
|
|
256
|
-
const e = document.getElementById('form')
|
|
257
|
-
if (e) {
|
|
258
|
-
e.addEventListener('submit', (event) => {
|
|
259
|
-
event.preventDefault()
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
const btn = document.getElementById('submit')
|
|
263
|
-
let evt = createSubmitEvent({ submitter: btn })
|
|
264
|
-
e.dispatchEvent(evt)
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
268
|
-
assert.strictEqual(cr.getMessageAsJson(), '["SUBMITED"]')
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
it('フォーム送信', () => {
|
|
272
|
-
check_form_submit('「#form」')
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
it('フォーム送信 - dom', () => {
|
|
276
|
-
check_form_submit('「form」をDOM要素ID取得')
|
|
277
|
-
})
|
|
278
|
-
})
|
|
279
|
-
|
|
280
|
-
describe('キーボード', () => {
|
|
281
|
-
const createKeyboardEvent = (type, t) => {
|
|
282
|
-
const box = t.target.getBoundingClientRect()
|
|
283
|
-
const { x, y } = t
|
|
284
|
-
if (KeyboardEvent && KeyboardEvent.length > 0) {
|
|
285
|
-
return new KeyboardEvent(type, {
|
|
286
|
-
view: window,
|
|
287
|
-
bubbles: true,
|
|
288
|
-
cancelable: true,
|
|
289
|
-
key: t.key || 0,
|
|
290
|
-
code: t.code || 0
|
|
291
|
-
})
|
|
292
|
-
} else {
|
|
293
|
-
const evt = new UIEvent(type, {
|
|
294
|
-
view: window,
|
|
295
|
-
bubbles: true,
|
|
296
|
-
cancelable: true
|
|
297
|
-
})
|
|
298
|
-
evt.key = t.key || '',
|
|
299
|
-
evt.code = t.code || ''
|
|
300
|
-
return evt
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const check_event_key = (selectmethod) => {
|
|
305
|
-
document.body.innerHTML = __html__[htmlPath+'event_dom_scrolldiv.html']
|
|
306
|
-
window.scrollX = 50
|
|
307
|
-
window.scrollY = 50
|
|
308
|
-
|
|
309
|
-
const code = `
|
|
310
|
-
要素は${selectmethod}
|
|
311
|
-
要素をキー押した時には、
|
|
312
|
-
「D:{押キー}」を報告する。
|
|
313
|
-
ここまで。
|
|
314
|
-
要素をキー離した時には、
|
|
315
|
-
「U:{押キー}」を報告する。
|
|
316
|
-
ここまで。
|
|
317
|
-
要素をキータイピングした時には、
|
|
318
|
-
「P:{押キー}」を報告する。
|
|
319
|
-
ここまで。
|
|
320
|
-
`
|
|
321
|
-
const cr = window.cr
|
|
322
|
-
cr.reset()
|
|
323
|
-
nako.run(code)
|
|
324
|
-
|
|
325
|
-
const e = document.getElementById('tgt')
|
|
326
|
-
if (e) {
|
|
327
|
-
const targetOffsets = [
|
|
328
|
-
{ target: e, key: 'A', code: 'D' },
|
|
329
|
-
{ target: e, key: 'C', code: 'E' },
|
|
330
|
-
{ target: e, key: 'Q', code: 'W' }
|
|
331
|
-
]
|
|
332
|
-
|
|
333
|
-
let evt = createKeyboardEvent('keydown', targetOffsets[0])
|
|
334
|
-
e.dispatchEvent(evt)
|
|
335
|
-
|
|
336
|
-
evt = createKeyboardEvent('keyup', targetOffsets[1])
|
|
337
|
-
e.dispatchEvent(evt)
|
|
338
|
-
|
|
339
|
-
evt = createKeyboardEvent('keypress', targetOffsets[2])
|
|
340
|
-
e.dispatchEvent(evt)
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
344
|
-
assert.strictEqual(cr.getMessageAsJson(), '["D:A","U:C","P:Q"]')
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
it('キーボード押・話・押下', () => {
|
|
348
|
-
check_event_key('「#tgt」')
|
|
349
|
-
})
|
|
350
|
-
it('キーボード押・話・押下 - dom', () => {
|
|
351
|
-
check_event_key('「tgt」をDOM要素ID取得')
|
|
352
|
-
})
|
|
353
|
-
})
|
|
354
|
-
|
|
355
|
-
describe('マウス', () => {
|
|
356
|
-
const createMouseEvent = (type, t) => {
|
|
357
|
-
const box = t.target.getBoundingClientRect()
|
|
358
|
-
const { x, y } = t
|
|
359
|
-
if (MouseEvent && MouseEvent.length > 0) {
|
|
360
|
-
return new MouseEvent(type, {
|
|
361
|
-
view: window,
|
|
362
|
-
bubbles: true,
|
|
363
|
-
cancelable: true,
|
|
364
|
-
button: t.btn || 0,
|
|
365
|
-
buttons: t.btns || 0,
|
|
366
|
-
clientX: box.left + x,
|
|
367
|
-
clientY: box.top + y,
|
|
368
|
-
screenX: window.screenLeft + box.left + x,
|
|
369
|
-
screenY: window.screenTop + box.top + y,
|
|
370
|
-
pageX: window.scrollX + box.left + x,
|
|
371
|
-
pageY: window.scrollY + box.top + y
|
|
372
|
-
})
|
|
373
|
-
} else {
|
|
374
|
-
const evt = new UIEvent(type, {
|
|
375
|
-
view: window,
|
|
376
|
-
bubbles: true,
|
|
377
|
-
cancelable: true
|
|
378
|
-
})
|
|
379
|
-
evt.button = t.btn || 0,
|
|
380
|
-
evt.buttons = t.btns || 0,
|
|
381
|
-
evt.clientX = box.left + x,
|
|
382
|
-
evt.clientY = box.top + y,
|
|
383
|
-
evt.screenX = window.screenLeft + box.left + x,
|
|
384
|
-
evt.screenY = window.screenTop + box.top + y,
|
|
385
|
-
evt.pageX = window.scrollX + box.left + x,
|
|
386
|
-
evt.pageY = window.scrollY + box.top + y
|
|
387
|
-
return evt
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
const check_event_mouse = (selectmethod) => {
|
|
392
|
-
document.body.innerHTML = __html__[htmlPath+'event_dom_scrolldiv.html']
|
|
393
|
-
window.scrollX = 50
|
|
394
|
-
window.scrollY = 50
|
|
395
|
-
|
|
396
|
-
const code = `
|
|
397
|
-
要素は${selectmethod}
|
|
398
|
-
要素をクリックした時には、
|
|
399
|
-
「C:」を報告する。
|
|
400
|
-
ここまで。
|
|
401
|
-
要素をマウス押した時には、
|
|
402
|
-
「D:{マウスX},{マウスY}」を報告する。
|
|
403
|
-
ここまで。
|
|
404
|
-
要素をマウス移動した時には、
|
|
405
|
-
「M:{マウスX},{マウスY}」を報告する。
|
|
406
|
-
ここまで。
|
|
407
|
-
要素をマウス離した時には、
|
|
408
|
-
「U:{マウスX},{マウスY}」を報告する。
|
|
409
|
-
ここまで。
|
|
410
|
-
`
|
|
411
|
-
const cr = window.cr
|
|
412
|
-
cr.reset()
|
|
413
|
-
nako.run(code)
|
|
414
|
-
|
|
415
|
-
const e = document.getElementById('tgt')
|
|
416
|
-
if (e) {
|
|
417
|
-
const targetOffsets = [
|
|
418
|
-
{ target: e, x: 0, y: 0, btn: 0, btns: 1 },
|
|
419
|
-
{ target: e, x: 30, y: 35, btn: 1, btns: 3 },
|
|
420
|
-
{ target: e, x: 30, y: 40, btn: 0, btns: 3 },
|
|
421
|
-
{ target: e, x: 20, y: 35, btn: 1, btns: 2 }
|
|
422
|
-
]
|
|
423
|
-
|
|
424
|
-
let evt = createMouseEvent('click', targetOffsets[0])
|
|
425
|
-
e.dispatchEvent(evt)
|
|
426
|
-
|
|
427
|
-
evt = createMouseEvent('mousedown', targetOffsets[1])
|
|
428
|
-
e.dispatchEvent(evt)
|
|
429
|
-
|
|
430
|
-
evt = createMouseEvent('mousemove', targetOffsets[2])
|
|
431
|
-
e.dispatchEvent(evt)
|
|
432
|
-
|
|
433
|
-
evt = createMouseEvent('mouseup', targetOffsets[3])
|
|
434
|
-
e.dispatchEvent(evt)
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
438
|
-
assert.strictEqual(cr.getMessageAsJson(), '["C:","D:30,35","M:30,40","U:20,35"]')
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
it('マウス押・離・クリック', () => {
|
|
442
|
-
check_event_mouse('「#tgt」')
|
|
443
|
-
})
|
|
444
|
-
it('マウス押・離・クリック - dom', () => {
|
|
445
|
-
check_event_mouse('「tgt」をDOM要素ID取得')
|
|
446
|
-
})
|
|
447
|
-
})
|
|
448
|
-
|
|
449
|
-
describe('タッチ', () => {
|
|
450
|
-
const createTouches = (infos) => {
|
|
451
|
-
const touches = []
|
|
452
|
-
const createTouchFactory = () => {
|
|
453
|
-
if (Touch && TouchEvent && Touch.length > 0 && TouchEvent.length > 0) {
|
|
454
|
-
return (params) => {
|
|
455
|
-
return new Touch(params)
|
|
456
|
-
}
|
|
457
|
-
} else {
|
|
458
|
-
return (params) => {
|
|
459
|
-
return params
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
const createTouch = createTouchFactory()
|
|
464
|
-
|
|
465
|
-
infos.forEach(t => {
|
|
466
|
-
const box = t.target.getBoundingClientRect()
|
|
467
|
-
const { x, y } = t
|
|
468
|
-
const params = {
|
|
469
|
-
identifier: t.id,
|
|
470
|
-
target: t.target,
|
|
471
|
-
clientX: box.left + x,
|
|
472
|
-
clientY: box.top + y,
|
|
473
|
-
screenX: window.screenLeft + box.left + x,
|
|
474
|
-
screenY: window.screenTop + box.top + y,
|
|
475
|
-
pageX: window.scrollX + box.left + x,
|
|
476
|
-
pageY: window.scrollY + box.top + y,
|
|
477
|
-
radiusX: t.r || 1.0,
|
|
478
|
-
radiusY: t.r || 1.0
|
|
479
|
-
}
|
|
480
|
-
touches.push(createTouch(params))
|
|
481
|
-
})
|
|
482
|
-
return touches
|
|
483
|
-
}
|
|
484
|
-
const createTouchEvent = (type, touches) => {
|
|
485
|
-
if (Touch && TouchEvent && Touch.length > 0 && TouchEvent.length > 0) {
|
|
486
|
-
return new TouchEvent(type, {
|
|
487
|
-
view: window,
|
|
488
|
-
bubbles: true,
|
|
489
|
-
cancelable: true,
|
|
490
|
-
changedTouches: touches.changed,
|
|
491
|
-
targetTouches: touches.target,
|
|
492
|
-
touches: touches.all
|
|
493
|
-
})
|
|
494
|
-
} else {
|
|
495
|
-
const evt = new UIEvent(type, {
|
|
496
|
-
view: window,
|
|
497
|
-
bubbles: true,
|
|
498
|
-
cancelable: true
|
|
499
|
-
})
|
|
500
|
-
evt.changedTouches = touches.changed
|
|
501
|
-
evt.targetTouches = touches.target
|
|
502
|
-
evt.touches = touches.all
|
|
503
|
-
return evt
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
const check_event_touch = (selectmethod) => {
|
|
507
|
-
document.body.innerHTML = __html__[htmlPath+'event_dom_scrolldiv.html']
|
|
508
|
-
window.scrollX = 50
|
|
509
|
-
window.scrollY = 50
|
|
510
|
-
|
|
511
|
-
const code = `
|
|
512
|
-
要素は${selectmethod}
|
|
513
|
-
要素をタッチ開始した時には、
|
|
514
|
-
「S:{タッチX},{タッチY}」を報告する。
|
|
515
|
-
タッチ配列を反復する。
|
|
516
|
-
これはそれ
|
|
517
|
-
「{これ[0]},{これ[1]}」を報告する。
|
|
518
|
-
ここまで。
|
|
519
|
-
ここまで。
|
|
520
|
-
要素をタッチ終了した時には、
|
|
521
|
-
「E:{タッチX},{タッチY}」を報告する。
|
|
522
|
-
タッチ配列を反復する。
|
|
523
|
-
これはそれ
|
|
524
|
-
「{これ[0]},{これ[1]}」を報告する。
|
|
525
|
-
ここまで。
|
|
526
|
-
ここまで。
|
|
527
|
-
要素をタッチした時には、
|
|
528
|
-
「M:{タッチX},{タッチY}」を報告する。
|
|
529
|
-
タッチ配列を反復する。
|
|
530
|
-
これはそれ
|
|
531
|
-
「{これ[0]},{これ[1]}」を報告する。
|
|
532
|
-
ここまで。
|
|
533
|
-
ここまで。
|
|
534
|
-
要素をタッチキャンセルした時には、
|
|
535
|
-
「C:{タッチX},{タッチY}」を報告する。
|
|
536
|
-
タッチ配列を反復する。
|
|
537
|
-
これはそれ
|
|
538
|
-
「{これ[0]},{これ[1]}」を報告する。
|
|
539
|
-
ここまで。
|
|
540
|
-
ここまで。
|
|
541
|
-
`
|
|
542
|
-
const cr = window.cr
|
|
543
|
-
cr.reset()
|
|
544
|
-
nako.run(code)
|
|
545
|
-
|
|
546
|
-
const e = document.getElementById('tgt')
|
|
547
|
-
if (e) {
|
|
548
|
-
const targetOffsets = [
|
|
549
|
-
{ target: e, id: 42, x: 20, y: 30, r: 5 },
|
|
550
|
-
{ target: e, id: 43, x: 30, y: 35, r: 2 },
|
|
551
|
-
{ target: e, id: 42, x: 25, y: 35, r: 3 },
|
|
552
|
-
{ target: e, id: 42, x: 20, y: 35, r: 1 },
|
|
553
|
-
{ target: e, id: 43, x: 30, y: 35, r: 5 }
|
|
554
|
-
]
|
|
555
|
-
const touchesList = createTouches(targetOffsets)
|
|
556
|
-
|
|
557
|
-
let evt = createTouchEvent('touchstart', {
|
|
558
|
-
changed: [ touchesList[0], touchesList[1] ],
|
|
559
|
-
target: [ touchesList[0], touchesList[1] ],
|
|
560
|
-
all: [ touchesList[0], touchesList[1] ]
|
|
561
|
-
})
|
|
562
|
-
e.dispatchEvent(evt)
|
|
563
|
-
|
|
564
|
-
evt = createTouchEvent('touchmove', {
|
|
565
|
-
changed: [ touchesList[2] ],
|
|
566
|
-
target: [ touchesList[2], touchesList[1] ],
|
|
567
|
-
all: [ touchesList[2], touchesList[1] ]
|
|
568
|
-
})
|
|
569
|
-
e.dispatchEvent(evt)
|
|
570
|
-
|
|
571
|
-
evt = createTouchEvent('touchcancel', {
|
|
572
|
-
changed: [ touchesList[3] ],
|
|
573
|
-
target: [ touchesList[1] ],
|
|
574
|
-
all: [ touchesList[1] ]
|
|
575
|
-
})
|
|
576
|
-
e.dispatchEvent(evt)
|
|
577
|
-
|
|
578
|
-
evt = createTouchEvent('touchend', {
|
|
579
|
-
changed: [ touchesList[4] ],
|
|
580
|
-
target: [],
|
|
581
|
-
all: []
|
|
582
|
-
})
|
|
583
|
-
e.dispatchEvent(evt)
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
587
|
-
assert.strictEqual(cr.getMessageAsJson(), '["S:20,30","20,30","30,35","M:25,35","25,35","C:20,35","20,35","E:30,35","30,35"]')
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
it('タッチ開始・終了・移動・キャンセル', () => {
|
|
591
|
-
check_event_touch('「#tgt」')
|
|
592
|
-
})
|
|
593
|
-
it('タッチ開始・終了・移動・キャンセル - dom', () => {
|
|
594
|
-
check_event_touch('「tgt」をDOM要素ID取得')
|
|
595
|
-
})
|
|
596
|
-
})
|
|
597
|
-
})
|
|
598
|
-
}
|
|
1
|
+
/* global __html__ */
|
|
2
|
+
import { CompareUtil, waitTimer, assert } from './compare_util'
|
|
3
|
+
|
|
4
|
+
const htmlPath = 'test/html/'
|
|
5
|
+
|
|
6
|
+
export default (nako) => {
|
|
7
|
+
const cu = new CompareUtil(nako)
|
|
8
|
+
|
|
9
|
+
describe('DOMイベント', () => {
|
|
10
|
+
describe('汎用命令', () => {
|
|
11
|
+
const createMouseEvent = (type, t) => {
|
|
12
|
+
const box = t.target.getBoundingClientRect()
|
|
13
|
+
const x = 30
|
|
14
|
+
const y = 10
|
|
15
|
+
if (MouseEvent && MouseEvent.length > 0) {
|
|
16
|
+
return new MouseEvent(type, {
|
|
17
|
+
view: window,
|
|
18
|
+
bubbles: true,
|
|
19
|
+
cancelable: true,
|
|
20
|
+
button: t.btn || 0,
|
|
21
|
+
buttons: t.btns || 1,
|
|
22
|
+
clientX: box.left + x,
|
|
23
|
+
clientY: box.top + y,
|
|
24
|
+
screenX: window.screenLeft + box.left + x,
|
|
25
|
+
screenY: window.screenTop + box.top + y,
|
|
26
|
+
pageX: window.scrollX + box.left + x,
|
|
27
|
+
pageY: window.scrollY + box.top + y
|
|
28
|
+
})
|
|
29
|
+
} else {
|
|
30
|
+
const evt = new UIEvent(type, {
|
|
31
|
+
view: window,
|
|
32
|
+
bubbles: true,
|
|
33
|
+
cancelable: true
|
|
34
|
+
})
|
|
35
|
+
evt.button = t.btn || 0,
|
|
36
|
+
evt.buttons = t.btns || 1,
|
|
37
|
+
evt.clientX = box.left + x,
|
|
38
|
+
evt.clientY = box.top + y,
|
|
39
|
+
evt.screenX = window.screenLeft + box.left + x,
|
|
40
|
+
evt.screenY = window.screenTop + box.top + y,
|
|
41
|
+
evt.pageX = window.scrollX + box.left + x,
|
|
42
|
+
evt.pageY = window.scrollY + box.top + y
|
|
43
|
+
return evt
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const check_event_set = (selectmethod) => {
|
|
48
|
+
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
49
|
+
|
|
50
|
+
const code = `
|
|
51
|
+
要素は${selectmethod}
|
|
52
|
+
要素の「onclick」に「ボタンクリック」をDOMイベント設定する。
|
|
53
|
+
●ボタンクリックとは
|
|
54
|
+
「C:設定」を報告する。
|
|
55
|
+
ここまで。
|
|
56
|
+
`
|
|
57
|
+
const cr = window.cr
|
|
58
|
+
cr.reset()
|
|
59
|
+
nako.run(code)
|
|
60
|
+
|
|
61
|
+
const e = document.getElementById('button')
|
|
62
|
+
if (e) {
|
|
63
|
+
const evt = createMouseEvent('click', { target: e })
|
|
64
|
+
e.dispatchEvent(evt)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
68
|
+
assert.strictEqual(cr.getMessageAsJson(), '["C:設定"]')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const check_event_fire = (selectmethod) => {
|
|
72
|
+
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
73
|
+
|
|
74
|
+
const code = `
|
|
75
|
+
要素は${selectmethod}
|
|
76
|
+
要素の「click」がDOMイベント発火した時には、
|
|
77
|
+
「C:設定」を報告する。
|
|
78
|
+
ここまで。
|
|
79
|
+
`
|
|
80
|
+
const cr = window.cr
|
|
81
|
+
cr.reset()
|
|
82
|
+
nako.run(code)
|
|
83
|
+
|
|
84
|
+
const e = document.getElementById('button')
|
|
85
|
+
if (e) {
|
|
86
|
+
const evt = createMouseEvent('click', { target: e })
|
|
87
|
+
e.dispatchEvent(evt)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
91
|
+
assert.strictEqual(cr.getMessageAsJson(), '["C:設定"]')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const check_event_add = (selectmethod) => {
|
|
95
|
+
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
96
|
+
|
|
97
|
+
const code = `
|
|
98
|
+
要素は${selectmethod}
|
|
99
|
+
要素の「click」に「ボタンクリック」をDOMイベント追加する。
|
|
100
|
+
●ボタンクリックとは
|
|
101
|
+
「C:追加」を報告する。
|
|
102
|
+
ここまで。
|
|
103
|
+
`
|
|
104
|
+
const cr = window.cr
|
|
105
|
+
cr.reset()
|
|
106
|
+
nako.run(code)
|
|
107
|
+
|
|
108
|
+
const e = document.getElementById('button')
|
|
109
|
+
if (e) {
|
|
110
|
+
const evt = createMouseEvent('click', { target: e })
|
|
111
|
+
e.dispatchEvent(evt)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
115
|
+
assert.strictEqual(cr.getMessageAsJson(), '["C:追加"]')
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const check_event_remove = (selectmethod) => {
|
|
119
|
+
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
120
|
+
|
|
121
|
+
const code = `
|
|
122
|
+
要素は${selectmethod}
|
|
123
|
+
要素の「click」に「ボタンクリック」をDOMイベント追加する。
|
|
124
|
+
要素の「click」から「ボタンクリック」をDOMイベント削除する。
|
|
125
|
+
●ボタンクリックとは
|
|
126
|
+
「C:追加」を報告する。
|
|
127
|
+
ここまで。
|
|
128
|
+
`
|
|
129
|
+
const cr = window.cr
|
|
130
|
+
cr.reset()
|
|
131
|
+
nako.run(code)
|
|
132
|
+
|
|
133
|
+
const e = document.getElementById('button')
|
|
134
|
+
if (e) {
|
|
135
|
+
const evt = createMouseEvent('click', { target: e })
|
|
136
|
+
e.dispatchEvent(evt)
|
|
137
|
+
} else {
|
|
138
|
+
assert.fail('要素が見つからないためイベント発火に失敗しました。')
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
assert.ok(!cr.isCalled, 'イベント呼び出し')
|
|
142
|
+
assert.strictEqual(cr.getMessageAsJson(), '[]')
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
it('イベント設定', () => {
|
|
146
|
+
check_event_set('「#button」')
|
|
147
|
+
})
|
|
148
|
+
it('イベント設定 - dom', () => {
|
|
149
|
+
check_event_set('「button」をDOM要素ID取得')
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it('イベント発火した時', () => {
|
|
153
|
+
check_event_fire('「#button」')
|
|
154
|
+
})
|
|
155
|
+
it('イベント発火した時 - dom', () => {
|
|
156
|
+
check_event_fire('「button」をDOM要素ID取得')
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
it('イベント追加', () => {
|
|
160
|
+
check_event_add('「#button」')
|
|
161
|
+
})
|
|
162
|
+
it('イベント追加 - dom', () => {
|
|
163
|
+
check_event_add('「button」をDOM要素ID取得')
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('イベント削除', () => {
|
|
167
|
+
check_event_remove('「#button」')
|
|
168
|
+
})
|
|
169
|
+
it('イベント削除 - dom', () => {
|
|
170
|
+
check_event_remove('「button」をDOM要素ID取得')
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
describe('読み込み時', () => {
|
|
175
|
+
const check_img_load = async (selectmethod) => {
|
|
176
|
+
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
177
|
+
|
|
178
|
+
const code = `
|
|
179
|
+
IMGは「img」のDOM要素作成
|
|
180
|
+
IMG["id"]は「img」
|
|
181
|
+
親は「form」をDOM要素ID取得
|
|
182
|
+
親にIMGをDOM子要素追加
|
|
183
|
+
要素は${selectmethod}
|
|
184
|
+
要素を読み込んだ時には、
|
|
185
|
+
「L:{IMG["naturalWidth"]},{IMG["naturalHeight"]}」を報告する。
|
|
186
|
+
ここまで。
|
|
187
|
+
IMG["src"]は「/turtle.png」
|
|
188
|
+
`
|
|
189
|
+
const cr = window.cr
|
|
190
|
+
cr.reset()
|
|
191
|
+
nako.run(code)
|
|
192
|
+
|
|
193
|
+
await waitTimer(1.0)
|
|
194
|
+
|
|
195
|
+
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
196
|
+
assert.strictEqual(cr.getMessageAsJson(), '["L:64,64"]')
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
it('読み込み時', async () => {
|
|
200
|
+
await check_img_load('「#img」')
|
|
201
|
+
})
|
|
202
|
+
it('読み込み時 - dom', async () => {
|
|
203
|
+
await check_img_load('「img」をDOM要素ID取得')
|
|
204
|
+
})
|
|
205
|
+
it('読み込み時 - image', async () => {
|
|
206
|
+
const code = `
|
|
207
|
+
要素は「new Image()」をJS実行
|
|
208
|
+
要素を読み込んだ時には、
|
|
209
|
+
「I:{要素["naturalWidth"]},{要素["naturalHeight"]}」を報告する。
|
|
210
|
+
ここまで。
|
|
211
|
+
要素["src"]は「/turtle.png」
|
|
212
|
+
`
|
|
213
|
+
const cr = window.cr
|
|
214
|
+
cr.reset()
|
|
215
|
+
nako.run(code)
|
|
216
|
+
|
|
217
|
+
await waitTimer(1.0)
|
|
218
|
+
|
|
219
|
+
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
220
|
+
assert.strictEqual(cr.getMessageAsJson(), '["I:64,64"]')
|
|
221
|
+
})
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
describe('フォーム', () => {
|
|
225
|
+
const createSubmitEvent = (t) => {
|
|
226
|
+
if (SubmitEvent && SubmitEvent.length > 0) {
|
|
227
|
+
return new SubmitEvent('submit', {
|
|
228
|
+
bubbles: true,
|
|
229
|
+
cancelable: true,
|
|
230
|
+
submitter: t.submitter
|
|
231
|
+
})
|
|
232
|
+
} else {
|
|
233
|
+
const evt = new Event('submit', {
|
|
234
|
+
bubbles: true,
|
|
235
|
+
cancelable: true
|
|
236
|
+
})
|
|
237
|
+
evt.submitter = t.submitter
|
|
238
|
+
return evt
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const check_form_submit = (selectmethod) => {
|
|
243
|
+
document.body.innerHTML = __html__[htmlPath+'event_dom_form.html']
|
|
244
|
+
|
|
245
|
+
const code = `
|
|
246
|
+
要素は${selectmethod}
|
|
247
|
+
要素をフォーム送信した時には、
|
|
248
|
+
WINDOW["event"]をDOMイベント処理停止する。
|
|
249
|
+
「SUBMITED」を報告する。
|
|
250
|
+
ここまで。
|
|
251
|
+
`
|
|
252
|
+
const cr = window.cr
|
|
253
|
+
cr.reset()
|
|
254
|
+
nako.run(code)
|
|
255
|
+
|
|
256
|
+
const e = document.getElementById('form')
|
|
257
|
+
if (e) {
|
|
258
|
+
e.addEventListener('submit', (event) => {
|
|
259
|
+
event.preventDefault()
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
const btn = document.getElementById('submit')
|
|
263
|
+
let evt = createSubmitEvent({ submitter: btn })
|
|
264
|
+
e.dispatchEvent(evt)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
268
|
+
assert.strictEqual(cr.getMessageAsJson(), '["SUBMITED"]')
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
it('フォーム送信', () => {
|
|
272
|
+
check_form_submit('「#form」')
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
it('フォーム送信 - dom', () => {
|
|
276
|
+
check_form_submit('「form」をDOM要素ID取得')
|
|
277
|
+
})
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
describe('キーボード', () => {
|
|
281
|
+
const createKeyboardEvent = (type, t) => {
|
|
282
|
+
const box = t.target.getBoundingClientRect()
|
|
283
|
+
const { x, y } = t
|
|
284
|
+
if (KeyboardEvent && KeyboardEvent.length > 0) {
|
|
285
|
+
return new KeyboardEvent(type, {
|
|
286
|
+
view: window,
|
|
287
|
+
bubbles: true,
|
|
288
|
+
cancelable: true,
|
|
289
|
+
key: t.key || 0,
|
|
290
|
+
code: t.code || 0
|
|
291
|
+
})
|
|
292
|
+
} else {
|
|
293
|
+
const evt = new UIEvent(type, {
|
|
294
|
+
view: window,
|
|
295
|
+
bubbles: true,
|
|
296
|
+
cancelable: true
|
|
297
|
+
})
|
|
298
|
+
evt.key = t.key || '',
|
|
299
|
+
evt.code = t.code || ''
|
|
300
|
+
return evt
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const check_event_key = (selectmethod) => {
|
|
305
|
+
document.body.innerHTML = __html__[htmlPath+'event_dom_scrolldiv.html']
|
|
306
|
+
window.scrollX = 50
|
|
307
|
+
window.scrollY = 50
|
|
308
|
+
|
|
309
|
+
const code = `
|
|
310
|
+
要素は${selectmethod}
|
|
311
|
+
要素をキー押した時には、
|
|
312
|
+
「D:{押キー}」を報告する。
|
|
313
|
+
ここまで。
|
|
314
|
+
要素をキー離した時には、
|
|
315
|
+
「U:{押キー}」を報告する。
|
|
316
|
+
ここまで。
|
|
317
|
+
要素をキータイピングした時には、
|
|
318
|
+
「P:{押キー}」を報告する。
|
|
319
|
+
ここまで。
|
|
320
|
+
`
|
|
321
|
+
const cr = window.cr
|
|
322
|
+
cr.reset()
|
|
323
|
+
nako.run(code)
|
|
324
|
+
|
|
325
|
+
const e = document.getElementById('tgt')
|
|
326
|
+
if (e) {
|
|
327
|
+
const targetOffsets = [
|
|
328
|
+
{ target: e, key: 'A', code: 'D' },
|
|
329
|
+
{ target: e, key: 'C', code: 'E' },
|
|
330
|
+
{ target: e, key: 'Q', code: 'W' }
|
|
331
|
+
]
|
|
332
|
+
|
|
333
|
+
let evt = createKeyboardEvent('keydown', targetOffsets[0])
|
|
334
|
+
e.dispatchEvent(evt)
|
|
335
|
+
|
|
336
|
+
evt = createKeyboardEvent('keyup', targetOffsets[1])
|
|
337
|
+
e.dispatchEvent(evt)
|
|
338
|
+
|
|
339
|
+
evt = createKeyboardEvent('keypress', targetOffsets[2])
|
|
340
|
+
e.dispatchEvent(evt)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
344
|
+
assert.strictEqual(cr.getMessageAsJson(), '["D:A","U:C","P:Q"]')
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
it('キーボード押・話・押下', () => {
|
|
348
|
+
check_event_key('「#tgt」')
|
|
349
|
+
})
|
|
350
|
+
it('キーボード押・話・押下 - dom', () => {
|
|
351
|
+
check_event_key('「tgt」をDOM要素ID取得')
|
|
352
|
+
})
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
describe('マウス', () => {
|
|
356
|
+
const createMouseEvent = (type, t) => {
|
|
357
|
+
const box = t.target.getBoundingClientRect()
|
|
358
|
+
const { x, y } = t
|
|
359
|
+
if (MouseEvent && MouseEvent.length > 0) {
|
|
360
|
+
return new MouseEvent(type, {
|
|
361
|
+
view: window,
|
|
362
|
+
bubbles: true,
|
|
363
|
+
cancelable: true,
|
|
364
|
+
button: t.btn || 0,
|
|
365
|
+
buttons: t.btns || 0,
|
|
366
|
+
clientX: box.left + x,
|
|
367
|
+
clientY: box.top + y,
|
|
368
|
+
screenX: window.screenLeft + box.left + x,
|
|
369
|
+
screenY: window.screenTop + box.top + y,
|
|
370
|
+
pageX: window.scrollX + box.left + x,
|
|
371
|
+
pageY: window.scrollY + box.top + y
|
|
372
|
+
})
|
|
373
|
+
} else {
|
|
374
|
+
const evt = new UIEvent(type, {
|
|
375
|
+
view: window,
|
|
376
|
+
bubbles: true,
|
|
377
|
+
cancelable: true
|
|
378
|
+
})
|
|
379
|
+
evt.button = t.btn || 0,
|
|
380
|
+
evt.buttons = t.btns || 0,
|
|
381
|
+
evt.clientX = box.left + x,
|
|
382
|
+
evt.clientY = box.top + y,
|
|
383
|
+
evt.screenX = window.screenLeft + box.left + x,
|
|
384
|
+
evt.screenY = window.screenTop + box.top + y,
|
|
385
|
+
evt.pageX = window.scrollX + box.left + x,
|
|
386
|
+
evt.pageY = window.scrollY + box.top + y
|
|
387
|
+
return evt
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const check_event_mouse = (selectmethod) => {
|
|
392
|
+
document.body.innerHTML = __html__[htmlPath+'event_dom_scrolldiv.html']
|
|
393
|
+
window.scrollX = 50
|
|
394
|
+
window.scrollY = 50
|
|
395
|
+
|
|
396
|
+
const code = `
|
|
397
|
+
要素は${selectmethod}
|
|
398
|
+
要素をクリックした時には、
|
|
399
|
+
「C:」を報告する。
|
|
400
|
+
ここまで。
|
|
401
|
+
要素をマウス押した時には、
|
|
402
|
+
「D:{マウスX},{マウスY}」を報告する。
|
|
403
|
+
ここまで。
|
|
404
|
+
要素をマウス移動した時には、
|
|
405
|
+
「M:{マウスX},{マウスY}」を報告する。
|
|
406
|
+
ここまで。
|
|
407
|
+
要素をマウス離した時には、
|
|
408
|
+
「U:{マウスX},{マウスY}」を報告する。
|
|
409
|
+
ここまで。
|
|
410
|
+
`
|
|
411
|
+
const cr = window.cr
|
|
412
|
+
cr.reset()
|
|
413
|
+
nako.run(code)
|
|
414
|
+
|
|
415
|
+
const e = document.getElementById('tgt')
|
|
416
|
+
if (e) {
|
|
417
|
+
const targetOffsets = [
|
|
418
|
+
{ target: e, x: 0, y: 0, btn: 0, btns: 1 },
|
|
419
|
+
{ target: e, x: 30, y: 35, btn: 1, btns: 3 },
|
|
420
|
+
{ target: e, x: 30, y: 40, btn: 0, btns: 3 },
|
|
421
|
+
{ target: e, x: 20, y: 35, btn: 1, btns: 2 }
|
|
422
|
+
]
|
|
423
|
+
|
|
424
|
+
let evt = createMouseEvent('click', targetOffsets[0])
|
|
425
|
+
e.dispatchEvent(evt)
|
|
426
|
+
|
|
427
|
+
evt = createMouseEvent('mousedown', targetOffsets[1])
|
|
428
|
+
e.dispatchEvent(evt)
|
|
429
|
+
|
|
430
|
+
evt = createMouseEvent('mousemove', targetOffsets[2])
|
|
431
|
+
e.dispatchEvent(evt)
|
|
432
|
+
|
|
433
|
+
evt = createMouseEvent('mouseup', targetOffsets[3])
|
|
434
|
+
e.dispatchEvent(evt)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
438
|
+
assert.strictEqual(cr.getMessageAsJson(), '["C:","D:30,35","M:30,40","U:20,35"]')
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
it('マウス押・離・クリック', () => {
|
|
442
|
+
check_event_mouse('「#tgt」')
|
|
443
|
+
})
|
|
444
|
+
it('マウス押・離・クリック - dom', () => {
|
|
445
|
+
check_event_mouse('「tgt」をDOM要素ID取得')
|
|
446
|
+
})
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
describe('タッチ', () => {
|
|
450
|
+
const createTouches = (infos) => {
|
|
451
|
+
const touches = []
|
|
452
|
+
const createTouchFactory = () => {
|
|
453
|
+
if (Touch && TouchEvent && Touch.length > 0 && TouchEvent.length > 0) {
|
|
454
|
+
return (params) => {
|
|
455
|
+
return new Touch(params)
|
|
456
|
+
}
|
|
457
|
+
} else {
|
|
458
|
+
return (params) => {
|
|
459
|
+
return params
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const createTouch = createTouchFactory()
|
|
464
|
+
|
|
465
|
+
infos.forEach(t => {
|
|
466
|
+
const box = t.target.getBoundingClientRect()
|
|
467
|
+
const { x, y } = t
|
|
468
|
+
const params = {
|
|
469
|
+
identifier: t.id,
|
|
470
|
+
target: t.target,
|
|
471
|
+
clientX: box.left + x,
|
|
472
|
+
clientY: box.top + y,
|
|
473
|
+
screenX: window.screenLeft + box.left + x,
|
|
474
|
+
screenY: window.screenTop + box.top + y,
|
|
475
|
+
pageX: window.scrollX + box.left + x,
|
|
476
|
+
pageY: window.scrollY + box.top + y,
|
|
477
|
+
radiusX: t.r || 1.0,
|
|
478
|
+
radiusY: t.r || 1.0
|
|
479
|
+
}
|
|
480
|
+
touches.push(createTouch(params))
|
|
481
|
+
})
|
|
482
|
+
return touches
|
|
483
|
+
}
|
|
484
|
+
const createTouchEvent = (type, touches) => {
|
|
485
|
+
if (Touch && TouchEvent && Touch.length > 0 && TouchEvent.length > 0) {
|
|
486
|
+
return new TouchEvent(type, {
|
|
487
|
+
view: window,
|
|
488
|
+
bubbles: true,
|
|
489
|
+
cancelable: true,
|
|
490
|
+
changedTouches: touches.changed,
|
|
491
|
+
targetTouches: touches.target,
|
|
492
|
+
touches: touches.all
|
|
493
|
+
})
|
|
494
|
+
} else {
|
|
495
|
+
const evt = new UIEvent(type, {
|
|
496
|
+
view: window,
|
|
497
|
+
bubbles: true,
|
|
498
|
+
cancelable: true
|
|
499
|
+
})
|
|
500
|
+
evt.changedTouches = touches.changed
|
|
501
|
+
evt.targetTouches = touches.target
|
|
502
|
+
evt.touches = touches.all
|
|
503
|
+
return evt
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
const check_event_touch = (selectmethod) => {
|
|
507
|
+
document.body.innerHTML = __html__[htmlPath+'event_dom_scrolldiv.html']
|
|
508
|
+
window.scrollX = 50
|
|
509
|
+
window.scrollY = 50
|
|
510
|
+
|
|
511
|
+
const code = `
|
|
512
|
+
要素は${selectmethod}
|
|
513
|
+
要素をタッチ開始した時には、
|
|
514
|
+
「S:{タッチX},{タッチY}」を報告する。
|
|
515
|
+
タッチ配列を反復する。
|
|
516
|
+
これはそれ
|
|
517
|
+
「{これ[0]},{これ[1]}」を報告する。
|
|
518
|
+
ここまで。
|
|
519
|
+
ここまで。
|
|
520
|
+
要素をタッチ終了した時には、
|
|
521
|
+
「E:{タッチX},{タッチY}」を報告する。
|
|
522
|
+
タッチ配列を反復する。
|
|
523
|
+
これはそれ
|
|
524
|
+
「{これ[0]},{これ[1]}」を報告する。
|
|
525
|
+
ここまで。
|
|
526
|
+
ここまで。
|
|
527
|
+
要素をタッチした時には、
|
|
528
|
+
「M:{タッチX},{タッチY}」を報告する。
|
|
529
|
+
タッチ配列を反復する。
|
|
530
|
+
これはそれ
|
|
531
|
+
「{これ[0]},{これ[1]}」を報告する。
|
|
532
|
+
ここまで。
|
|
533
|
+
ここまで。
|
|
534
|
+
要素をタッチキャンセルした時には、
|
|
535
|
+
「C:{タッチX},{タッチY}」を報告する。
|
|
536
|
+
タッチ配列を反復する。
|
|
537
|
+
これはそれ
|
|
538
|
+
「{これ[0]},{これ[1]}」を報告する。
|
|
539
|
+
ここまで。
|
|
540
|
+
ここまで。
|
|
541
|
+
`
|
|
542
|
+
const cr = window.cr
|
|
543
|
+
cr.reset()
|
|
544
|
+
nako.run(code)
|
|
545
|
+
|
|
546
|
+
const e = document.getElementById('tgt')
|
|
547
|
+
if (e) {
|
|
548
|
+
const targetOffsets = [
|
|
549
|
+
{ target: e, id: 42, x: 20, y: 30, r: 5 },
|
|
550
|
+
{ target: e, id: 43, x: 30, y: 35, r: 2 },
|
|
551
|
+
{ target: e, id: 42, x: 25, y: 35, r: 3 },
|
|
552
|
+
{ target: e, id: 42, x: 20, y: 35, r: 1 },
|
|
553
|
+
{ target: e, id: 43, x: 30, y: 35, r: 5 }
|
|
554
|
+
]
|
|
555
|
+
const touchesList = createTouches(targetOffsets)
|
|
556
|
+
|
|
557
|
+
let evt = createTouchEvent('touchstart', {
|
|
558
|
+
changed: [ touchesList[0], touchesList[1] ],
|
|
559
|
+
target: [ touchesList[0], touchesList[1] ],
|
|
560
|
+
all: [ touchesList[0], touchesList[1] ]
|
|
561
|
+
})
|
|
562
|
+
e.dispatchEvent(evt)
|
|
563
|
+
|
|
564
|
+
evt = createTouchEvent('touchmove', {
|
|
565
|
+
changed: [ touchesList[2] ],
|
|
566
|
+
target: [ touchesList[2], touchesList[1] ],
|
|
567
|
+
all: [ touchesList[2], touchesList[1] ]
|
|
568
|
+
})
|
|
569
|
+
e.dispatchEvent(evt)
|
|
570
|
+
|
|
571
|
+
evt = createTouchEvent('touchcancel', {
|
|
572
|
+
changed: [ touchesList[3] ],
|
|
573
|
+
target: [ touchesList[1] ],
|
|
574
|
+
all: [ touchesList[1] ]
|
|
575
|
+
})
|
|
576
|
+
e.dispatchEvent(evt)
|
|
577
|
+
|
|
578
|
+
evt = createTouchEvent('touchend', {
|
|
579
|
+
changed: [ touchesList[4] ],
|
|
580
|
+
target: [],
|
|
581
|
+
all: []
|
|
582
|
+
})
|
|
583
|
+
e.dispatchEvent(evt)
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
assert.ok(cr.isCalled, 'イベント呼び出し')
|
|
587
|
+
assert.strictEqual(cr.getMessageAsJson(), '["S:20,30","20,30","30,35","M:25,35","25,35","C:20,35","20,35","E:30,35","30,35"]')
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
it('タッチ開始・終了・移動・キャンセル', () => {
|
|
591
|
+
check_event_touch('「#tgt」')
|
|
592
|
+
})
|
|
593
|
+
it('タッチ開始・終了・移動・キャンセル - dom', () => {
|
|
594
|
+
check_event_touch('「tgt」をDOM要素ID取得')
|
|
595
|
+
})
|
|
596
|
+
})
|
|
597
|
+
})
|
|
598
|
+
}
|