-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
testloader.js
1151 lines (892 loc) · 39.2 KB
/
testloader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// testloader.js
// Namhyeon Go <abuse@catswords.net>
// https://github.com/gnh1201/welsonjs
// load libraries
var FILE = require("lib/file");
// implement the tests
var test_implements = {
// https://gist.github.com/CityRay/c56e4fa874af9370cc1a367bd43095b0
"es5_polyfills": function() {
var parseIntIgnoresLeadingZeros = (function () {
return parseInt('010', 10) === 10;
}());
console.log("parseIntIgnoresLeadingZeros: " + String(parseIntIgnoresLeadingZeros) + " (Default on the built-in engine: true)");
var DateISOString = (function () {
return !!(Date && Date.prototype && Date.prototype.toISOString);
}());
console.log("DateISOString: " + String(DateISOString) + " (Default on the built-in engine: false)");
var result = !!(parseIntIgnoresLeadingZeros && DateISOString);
console.log(result ?
"ECMAScript 5 수준의 런타임입니다. 필수 테스트를 모두 통과하였습니다." :
"ECMAScript 5 수준의 런타임이 아닙니다. 필수 테스트 중 하나를 실패하였습니다.");
},
// https://learn.microsoft.com/en-us/previous-versions/windows/desktop/regprov/stdregprov
"registry_find_provider": function() {
var REG = require("lib/registry");
console.log("레지스트리 제공자(StdRegProv) 클래스에 접근을 시도합니다.");
var provider = REG.getProvider();
console.log(typeof provider !== "undefined" ?
"레지스트리 제공자 클래스에 성공적으로 연결되었습니다." :
"레지스트리 제공자 클래스에 연결하는데 문제가 있습니다.");
},
"registry_write": function() {
var REG = require("lib/registry");
var appName = "welsonjs";
console.log("레지스트리에 쓰기를 시도합니다.");
REG.write(REG.HKCU, appName + "\\WelsonJSTest", "", "here are in", REG.STRING);
console.log("레지스트리에 쓰기를 완료하였습니다.");
},
"registry_read": function() {
var REG = require("lib/registry");
var appName = "welsonjs";
console.log("레지스트리 읽기를 시도합니다.");
var response = REG.read(REG.HKCU, appName + "\\WelsonJSTest", "", REG.STRING);
console.log("읽음: " + response);
console.log(response === "here are in" ?
"레지스트리를 정상적으로 읽었습니다." :
"레지스트리를 읽는데 문제가 있습니다.");
},
"wmi_create_object": function() {
var WMI = require("lib/wmi");
console.log(typeof WMI.create().interface !== "undefined" ?
"WMI 객체를 정상적으로 생성하였습니다." :
"WMI 객체를 생성하는데 문제가 있습니다.");
},
"wmi_execute_query": function() {
var WMI = require("lib/wmi");
var queryString = "SELECT Caption FROM Win32_OperatingSystem";
console.log("실행할 쿼리: " + queryString);
var result = WMI.execQuery(queryString).fetch().get("Caption").trim();
console.log("현재 윈도우즈 배포판 종류: " + result);
},
"wmi_result_query": function() {
var WMI = require("lib/wmi");
var queryString = "SELECT Caption FROM Win32_OperatingSystem";
console.log("실행할 쿼리: " + queryString);
var result = WMI.execQuery(queryString).fetch().get("Caption").trim();
console.log("현재 윈도우즈 배포판 종류: " + result);
},
"shell_create_object": function() {
var SHELL = require("lib/shell");
console.log(typeof SHELL.create().interface !== "undefined" ?
"윈도우즈 쉘(Shell) 객체를 정상적으로 생성하였습니다." :
"윈도우즈 쉘(Shell) 객체를 생성하는데 문제가 있습니다.");
},
"shell_build_command_line": function() {
var SHELL = require("lib/shell");
console.log("쉘 명령의 무결성을 훼손시킬 수 있는 경우(따옴표, 쌍따옴표, 띄어쓰기 등을 포함한 경우)를 테스트합니다.");
// 모든 경우를 하나의 배열에 포함
var test_args = [
"ppap.exe",
"\"pen\"",
"'apple'",
"apple pen",
"pineapple pen"
];
// 입력과 출력 확인
console.log("입력 인자: " + test_args.join(" / "));
console.log("출력 문자열: " + SHELL.build(test_args));
console.log("정상적으로 명령행이 만들어졌는지 확인하세요.");
},
"shell_set_charset": function() {
var SHELL = require("lib/shell");
var ShellInstance = SHELL.create();
console.log("현재 기준 문자셋: " + ShellInstance.charset);
console.log("기준 문자셋을 유니코드(UTF-8)로 변경합니다.");
ShellInstance.setCharset(SHELL.CdoCharset.CdoUTF_8);
console.log("현재 기준 문자셋: " + ShellInstance.charset);
},
"shell_working_directory": function() {
var SHELL = require("lib/shell");
var ShellInstance = SHELL.create();
console.log("현재 작업 폴더: " + ShellInstance.workingDirectory);
console.log("작업 폴더를 변경합니다.");
ShellInstance.setWorkingDirectory(ShellInstance.workingDirectory + "\\data");
console.log("현재 작업 폴더: " + ShellInstance.workingDirectory);
},
"shell_create_process": function() {
var SHELL = require("lib/shell");
var shell = SHELL.create();
var process = shell.createProcess("calc.exe");
sleep(1500);
var processId = process.ProcessId;
console.log("프로세스 ID:", processId);
sleep(1500);
shell.release();
console.log("계산기가 정상적으로 실행되었는지 확인하세요.");
},
"shell_execute": function() {
var SHELL = require("lib/shell");
var response = SHELL.exec("echo done");
console.log(response == "done" ?
"쉘(Shell) 출력이 정상적으로 작동합니다." :
"쉘(Shell) 출력에 문제가 있습니다.");
},
"shell_run": function() {
var SHELL = require("lib/shell");
SHELL.run("calc");
console.log("잠시 후 계산기 프로그램이 열리는지 확인하여 주세요.");
},
"shell_run_as": function() {
var SHELL = require("lib/shell");
console.log("관리자 권한 요청을 확인하세요.");
SHELL.runAs("calc");
console.log("잠시 후 계산기 프로그램이 열리는지 확인하여 주세요.");
},
"shell_find_my_documents": function() {
var SHELL = require("lib/shell");
console.log("내 문서 폴더 위치: " + SHELL.getPathOfMyDocuments());
},
"shell_release": function() {
var SHELL = require("lib/shell");
var ShellInstance = SHELL.create();
ShellInstance.release();
console.log(ShellInstance.interface != null ?
"정상적으로 해제되지 않았습니다." :
"정상적으로 해제되었습니다.");
},
"powershell_set_command": function() {
var PS = require("lib/powershell");
var PSInstance = PS.create();
PSInstance.load("Write-Output \"hello world\"");
console.log("설정된 명령어: " + PSInstance.target);
},
"powershell_set_file": function() {
var PS = require("lib/powershell");
var PSInstance = PS.create();
PSInstance.loadFile("app\\assets\\ps1\\helloworld");
console.log("설정된 파일: " + PSInstance.target);
},
"powershell_set_uri": function() {
var PS = require("lib/powershell");
var PSInstance = PS.create();
PSInstance.loadURI("data:text/plain;base64,V3JpdGUtT3V0cHV0ICJoZWxsbyB3b3JsZCI=");
console.log("설정된 URI: " + PSInstance.target);
},
"powershell_execute": function() {
var PS = require("lib/powershell");
var response = PS.execScript("app\\assets\\ps1\\helloworld");
console.log("실행 결과 값: " + response);
},
"powershell_run_as": function() {
var PS = require("lib/powershell");
var response = PS.runAs("app\\assets\\ps1\\helloworld");
console.log("실행 결과 값: " + response);
},
"system_resolve_env": function() {
var SYS = require("lib/system");
console.log("기본 프로그램 설치 폴더: " + SYS.getEnvString("PROGRAMFILES"));
console.log("기본 프로그램 설치 폴더가 정상적인 위치를 가르키고 있는지 확인하세요.");
},
"system_check_as": function() {
var SYS = require("lib/system");
console.log(SYS.isElevated() ?
"이 런타임은 관리자 모드에서 실행되고 있지 않습니다." :
"이 런타임은 관리자 모드에서 실행되고 있습니다.");
},
"system_get_os_version": function() {
var SYS = require("lib/system");
console.log("현재 사용중인 운영체제: " + SYS.getOS());
},
"system_get_architecture": function() {
var SYS = require("lib/system");
console.log("현재 사용중인 아키텍처: " + SYS.getArch());
},
"system_get_uuid": function() {
var SYS = require("lib/system");
console.log("디바이스 고유 번호: " + SYS.getUUID());
},
"system_get_working_directory": function() {
var SYS = require("lib/system");
console.log("현재 작업 폴더: " + SYS.getCurrentWorkingDirectory());
},
"system_get_script_directory": function() {
var SYS = require("lib/system");
console.log("현재 스크립트 폴더: " + SYS.getCurrentScriptDirectory());
},
"system_get_network_interfaces": function() {
var SYS = require("lib/system");
var netInterfaces = SYS.getNetworkInterfaces();
netInterfaces.forEach(function(x) {
console.log(x.Caption);
});
},
"system_get_process_list": function() {
var SYS = require("lib/system");
var processList = SYS.getProcessList();
processList.forEach(function(x) {
console.log(x.Caption, x.ProcessId);
});
},
"system_get_process_list_by_name": function() {
var SYS = require("lib/system");
var processList = SYS.getProcessListByName("explorer.exe");
processList.forEach(function(x) {
console.log(x.Caption, x.ProcessId);
});
},
"system_register_uri": function() {
console.log("웹 브라우저를 열고 주소창에 아래 주소를 입력하세요.");
console.log("welsonjs:///?application=mscalc");
},
"system_pipe_ipc": function() {
var SHELL = require("lib/shell");
for (var i = 0; i < 3; i++) {
SHELL.show(["cscript", "app.js", "examples/ipctest"]);
}
},
"vhid_find_window": function() {
console.log("동일한 기능이 포함된 chromium_send_click 또는 chromium_send_keys 테스트를 수행하십시오");
},
"vhid_send_click": function() {
console.log("동일한 기능이 포함된 chromium_send_click 테스트를 수행하십시오");
},
"vhid_send_keys": function() {
console.log("동일한 기능이 포함된 chromium_send_keys 테스트를 수행하십시오");
},
"vhid_send_key_enter": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://en.key-test.ru/", null, "welsonjs_test", 9222, true);
console.log("참고: vhid_send_key_enter 테스트의 엔터 키 기능은 웹 브라우저가 키코드를 처리하도록 작성되었습니다.");
console.log("5초 후 명령을 수행합니다.");
sleep(5000);
wbInstance.focus();
wbInstance.sendEnterKey();
sleep(1000);
},
"vhid_send_key_functions": function() {
var Toolkit = require("lib/toolkit");
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true);
console.log("웹 브라우저를 열고 F1 키를 눌러 도움말 페이지를 열겠습니다.");
console.log("5초 후 명령을 수행합니다.");
sleep(5000);
wbInstance.focus();
Toolkit.sendFnKey(wbInstance.pageId.substring(0, 6), 1); // F1 키 누름
},
"vhid_alert": function() {
var Toolkit = require("lib/toolkit");
Toolkit.alert("잘 보이면 테스트에 성공한 것입니다.");
},
"vhid_confirm": function() {
var Toolkit = require("lib/toolkit");
var answer = Toolkit.confirm("예 또는 아니오를 눌러주세요");
console.log(String(answer));
},
"vhid_prompt": function() {
var Toolkit = require("lib/toolkit");
var answer = Toolkit.prompt("Enter your input:");
console.log(String(answer));
},
"network_http_get": function() {
var HTTP = require("lib/http");
console.log("HTTP GET 요청으로 내 외부 IP를 확인합니다.");
var response = HTTP.get("https://api.ipify.org/", {}, {});
console.log("내 외부 IP: " + response);
},
"network_http_post": function() {
var HTTP = require("lib/http");
var response = HTTP.get("https://httpbin.org/post", {}, {});
console.log("응답: " + response);
},
"network_http_extended": function() {
var HTTP = require("lib/http");
var response1 = HTTP.put("https://httpbin.org/put", {}, {});
console.log("응답: " + response1);
var response2 = HTTP.patch("https://httpbin.org/patch", {}, {});
console.log("응답: " + response2);
},
"network_attach_debugger": function() {
var HTTP = require("lib/http");
HTTP.create("CURL")
.attachDebugger("FIDDLER")
.get("https://api.ipify.org/");
},
"network_detect_charset": function() {
var HTTP = require("lib/http");
var response = HTTP.get("https://example.org/", {}, {});
var charset = HTTP.create("CURL").detectCharset(response);
console.log("감지된 문자셋: " + charset);
},
"network_detect_http_ssl": function() {
var HTTP = require("lib/http");
var response = HTTP.create("CURL").get("https://example.org/");
var charset = HTTP.create("CURL").detectCharset(response);
},
"network_send_icmp": function() {
var SYS = require("lib/system");
console.log("1.1.1.1로 PING(ICMP) 전송");
console.log("응답 시간: " + SYS.ping("1.1.1.1") + "ms");
},
"network_bitsadmin_test": function() {
var HTTP = require("lib/http");
var bits = HTTP.create("BITS");
var response = bits.open("GET", "https://httpbin.org/get").send().responseText;
console.log(response);
},
"extramath_dtm": function() {
var ExtraMath = require("lib/extramath");
var a = "this is an apple";
var b = "this is red apple";
var dtm = new ExtraMath.DTM();
dtm.add(a);
dtm.add(b);
var mat = dtm.toArray();
console.log("Original sentance");
console.log(a);
console.log(b);
console.log("Create a DTM(Document-Term Matrix)");
console.log(mat[0].join(' '));
console.log(mat[1].join(' '));
},
"extramath_cosine_similarity": function() {
var ExtraMath = require("lib/extramath");
var a = "this is an apple";
var b = "this is red apple";
var dtm = new ExtraMath.DTM();
dtm.add(a);
dtm.add(b);
var mat = dtm.toArray();
console.log("Original sentance");
console.log(a);
console.log(b);
console.log("Create a DTM(Document-Term Matrix)");
console.log(mat[0].join(' '));
console.log(mat[1].join(' '));
console.log("Measure Cosine Similarity");
console.log('' + ExtraMath.arrayCos(mat[0], mat[1]));
console.log('' + ExtraMath.measureSimilarity(a, b));
},
"base64_encode": function() {
var BASE64 = require("lib/base64");
var original_text = "hello world";
var encoded_text = BASE64.encode(original_text);
console.log("원문: " + original_text);
console.log("인코딩된 문자: " + encoded_text);
console.log(encoded_text == "aGVsbG8gd29ybGQ=" ?
"인코딩된 문자가 기대값과 일치합니다." :
"인코딩된 문자가 기대값과 불일치합니다.");
},
"base64_decode": function() {
var BASE64 = require("lib/base64");
var encoded_text = "aGVsbG8gd29ybGQ=";
var original_text = BASE64.decode(encoded_text);
console.log("인코딩된 문자: " + encoded_text);
console.log("원문: " + original_text);
console.log(original_text == "hello world" ?
"디코드된 문자가 기대값과 일치합니다." :
"디코드된 문자가 기대값과 불일치합니다.");
},
"chromium_run": function() {
var Chrome = require("lib/chrome");
Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true);
},
"chromium_create_profile": function() {
var Chrome = require("lib/chrome");
console.log("welsonjs_test 프로파일을 생성합니다. (웹 브라우저를 실행하여 생성합니다.)");
Chrome.startDebug("https://example.org", null, "welsonjs_test", 9222, true);
},
"chromium_run_incognito": function() {
var Chrome = require("lib/chrome");
Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true);
},
"chromium_navigate": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true);
console.log("5초 후 구글로 이동합니다.");
sleep(5000);
wbInstance.setPageId(null);
wbInstance.navigate("https://google.com");
},
"chromium_get_active_pages": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true);
console.log("5초 후 페이지 목록을 불러옵니다.");
sleep(5000);
var pageList = wbInstance.getPageList();
pageList.forEach(function(x) {
console.log(x.title);
});
},
"chromium_find_page_by_id": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true);
console.log("5초 후 페이지 ID를 불러옵니다.");
sleep(5000);
var pageId = wbInstance.getPageList()[0].id;
console.log("페이지 ID: " + pageId);
console.log("페이지 ID로 페이지 찾기");
var page = wbInstance.getPageById(pageId);
console.log("페이지 제목: " + page.title);
},
"chromium_find_pages_by_title": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true);
console.log("5초 후 페이지 타이틀을 불러옵니다.");
sleep(5000);
var pageTitle = wbInstance.getPageList()[0].title;
console.log("페이지 타이틀: " + pageTitle);
console.log("페이지 타이틀로 페이지 찾기");
var pages = wbInstance.getPagesByTitle(pageTitle); // 타이틀로 찾는 경우 복수형으로 반환됨
console.log("페이지 ID: " + pages[0].id);
},
"chromium_move_focused": function() {
var Chrome = require("lib/chrome");
var wbInstances = [];
wbInstances.push(Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true));
sleep(2000);
wbInstances.push(Chrome.startDebugInPrivate("https://naver.com", null, "welsonjs_test_2", 9223, true));
sleep(2000);
wbInstances.push(Chrome.startDebugInPrivate("https://daum.net", null, "welsonjs_test_3", 9224, true));
sleep(2000);
var wbInstance = wbInstances[1];
wbInstance.setPageId(null);
wbInstance.focus();
},
"chromium_adjust_window_size": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true);
console.log("5초 후 명령을 수행합니다.");
sleep(5000);
wbInstance.focus();
wbInstance.autoAdjustByWindow(10, 10, 1024, 1280, 720, 768);
},
"chromium_get_element_position": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true);
console.log("5초 후 명령을 수행합니다.");
sleep(5000);
console.log(JSON.stringify(wbInstance.getElementPosition("p")));
},
"chromium_get_mapreduced_element_position": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://example.org", null, "welsonjs_test", 9222, true);
console.log("5초 후 명령을 수행합니다.");
sleep(5000);
console.log("More information... 버튼의 위치를 탐색");
console.log(JSON.stringify(wbInstance.getNestedElementPosition("p", ":self", "More information...")));
},
"chromium_set_value_to_textbox": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://html5doctor.com/demos/forms/forms-example.html", null, "welsonjs_test", 9222, true);
console.log("5초 후 명령을 수행합니다.");
sleep(5000);
wbInstance.setValue("#given-name", "길동");
wbInstance.setValue("#family-name", "홍");
},
"chromium_send_click": function() {
var RAND = require("lib/rand");
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://html5doctor.com/demos/forms/forms-example.html", null, "welsonjs_test", 9222, true);
console.log("5초 후 명령을 수행합니다.");
sleep(5000);
wbInstance.focus();
wbInstance.traceMouseClick();
while (true) {
wbInstance.vMouseClick(RAND.getInt(20, 200), RAND.getInt(20, 200));
sleep(2000);
}
},
"chromium_send_keys": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://html5doctor.com/demos/forms/forms-example.html", null, "welsonjs_test", 9222, true);
console.log("5초 후 명령을 수행합니다.");
sleep(5000);
wbInstance.focus();
wbInstance.traceMouseClick();
console.log("이메일 필드 위치 찾기");
var emailInputPosition = wbInstance.getElementPosition("#email");
wbInstance.vMouseClick(emailInputPosition.x + 2, emailInputPosition.y + 2);
sleep(1000);
console.log("가상 키 보내기");
wbInstance.vSendKeys("hong@example.org");
},
"chromium_auto_scroll_until_end": function() {
var Chrome = require("lib/chrome");
var wbInstance = Chrome.startDebugInPrivate("https://en.wikipedia.org/wiki/Lorem_ipsum", null, "welsonjs_test", 9222, true);
console.log("5초 후 명령을 수행합니다.");
sleep(5000);
wbInstance.focus();
wbInstance.traceMouseClick();
console.log("스크롤이 끝날 때까지 계속 스크롤을 조정합니다.");
while(!wbInstance.isPageScrollEnded()) {
wbInstance.scrollBy(0, 150);
sleep(2000);
}
},
"grpc_run_server": function() {
var SHELL = require("lib/shell");
SHELL.show(["cscript", "app.js", "grpcloader"]);
},
"grpc_receive_command": function() {
var SHELL = require("lib/shell");
SHELL.show(["grpcloader_test.bat"]);
},
"gui_check": function() {
console.log("GUI 환경에서 실행하여 주십시오");
},
// profile: data/test-misc-20231107.json
"gtkserver_test": function() {
var GTK = require("lib/gtk");
function main() {
GTK.init(function() {
var win, table, button, entry, text, radiogroup, radio1, radio2;
// create new window
win = new GTK.Window({
title: "WelsonJS GTK GUI Demo Application",
width: 450,
height: 400
});
// create new table
table = new GTK.Table({
rows: 50,
columns: 50
});
win.setContainer(table);
// create new button
button = new GTK.Button({
text: "Exit"
});
button.addEventListener("click", function() {
GTK.exit();
});
table.attach(button, 41, 49, 45, 49);
// create new entry
entry = new GTK.Entry();
table.attach(entry, 1, 40, 45, 49);
entry.addEventListener("enter", function(event) {
console.info(event.target.getText());
});
// create new textbox
text = new GTK.TextBox();
table.attach(text, 1, 49, 8, 44);
// create new radiogroup
radiogroup = new GTK.RadioGroup();
// create new radio (Radio 1)
radio1 = new GTK.RadioBox({
text: "Yes",
group: radiogroup
});
table.attach(radio1, 1, 10, 1, 4);
// create new radio (Radio 2)
radio2 = new GTK.RadioBox({
text: "No",
group: radiogroup
});
table.attach(radio2, 1, 10, 4, 7);
// showing window
win.show();
// focusing entry
entry.focus();
});
GTK.wait();
}
},
// profile: data/test-misc.json
"toolkit_msedge_test": function() {
var Chrome = require("lib/chrome");
var Toolkit = require("lib/toolkit");
var wbInstance = Chrome.create().setVendor("msedge").open("https://google.com");
sleep(5000);
//console.log(wbInstance.getHTML("body"));
wbInstance.focus();
wbInstance.traceMouseClick();
Toolkit.sendClick("Google", 30, 30, 1);
},
// profile: data/test-misc.json
"squel_sqlmap_test": function() {
console.log(squel.select({ separator: "\n" })
.from("students")
.field("name")
.field("MIN(test_score)")
.field("MAX(test_score)")
.field("GROUP_CONCAT(DISTINCT test_score ORDER BY test_score DESC SEPARATOR ' ')")
.group("name")
.toString());
},
// profile: data/test-msoffice.json
"open_excel_file": function() {
var Office = require("lib/msoffice");
var excel = new Office.Excel(); // Create a Excel instance
excel.open("data\\example.xlsx"); // Open a Excel window
},
"open_excel_new": function() {
var Office = require("lib/msoffice");
var excel = new Office.Excel(); // Create a Excel instance
excel.open(); // Open a Excel window
},
"open_excel_with_chatgpt": function() {
// Load libraries
var Office = require("lib/msoffice");
var ChatGPT = require("lib/chatgpt");
// Create an Excel instance
var excel = new Office.Excel();
// List of questions
var questions = [
"Which one does Mom like, and which one does Dad like?",
"If 100 billion won is deposited into my bank account without my knowledge, what would I do?",
"If my friend passed out from drinking, and Arnold Schwarzenegger suggests having a drink together alone, is it okay to ditch my friend and go with him?",
"If there's a snake in our tent during the company camping trip, should I wake up the manager, or should I escape on my own without waking him up?"
];
// Open the Excel window
excel.open();
// Answer to questions
var i = 1;
questions.forEach(function(x) {
var answer = ChatGPT.chat(x);
console.log("Answer:", answer);
excel.getCellByPosition(i, 1).setValue(answer);
i++;
});
// Close the Excel window
//excel.close();
},
"open_powerpoint_file": function() {
var Office = require("lib/msoffice");
var powerpoint = new Office.PowerPoint(); // Create a PowerPoint instance
powerpoint.open("data\\example.pptx"); // Open a PowerPoint window
},
"open_powerpoint_new": function() {
var Office = require("lib/msoffice");
var powerpoint = new Office.PowerPoint(); // Create a PowerPoint instance
powerpoint.open(); // Open a PowerPoint window
},
"open_word_file": function() {
var Office = require("lib/msoffice"); // Load libraries
var word = new Office.Word(); // Create an Word instance
word.open("data\\example.docx"); // Open the Word window
},
"sharedmemory": function() {
var Toolkit = require("lib/toolkit");
var mem = new Toolkit.NamedSharedMemory("welsonjs_test");
console.log("Writing a text the to shared memory...");
mem.writeText("nice meet you");
console.log("Reading a text from the shared memory...");
console.log(mem.readText() + ", too");
console.log("Cleaning the shared memory...");
mem.clear()
console.log(mem.readText());
mem.close()
console.log("Closing the shared memory...");
console.log("Done");
},
"sharedmemory_write": function() {
var Toolkit = require("lib/toolkit");
var mem = new Toolkit.NamedSharedMemory("welsonjs_test");
console.log("Writing a text to the shared memory...");
mem.writeText("nice meet you");
console.log("Done");
},
"sharedmemory_read": function() {
var Toolkit = require("lib/toolkit");
var mem = new Toolkit.NamedSharedMemory("welsonjs_test");
console.log("Reading a text from the shared memory...");
console.log(mem.readText() + ", too");
console.log("Cleaning the shared memory...");
mem.clear()
console.log(mem.readText());
mem.close()
console.log("Closing the shared memory...");
console.log("Done");
},
"sharedmemory_listener": function() {
var Toolkit = require("lib/toolkit");
var targets = (function() {
var s = Toolkit.prompt("Input the shared memory names (Comma seperated)");
return s.split(',');
})();
if (!targets) {
console.log("Aborted.");
} else {
// Open the shared memory
var memories = targets.map(function(x) {
return [x, new Toolkit.NamedSharedMemory(x)];
});
// Open the second process will be communicate
Toolkit.openProcess();
// Listen the shared memory
console.log("Listening the shared memory:", targets.join(', '));
while (true) {
console.log(new Date().toISOString());
memories.forEach(function(x) {
var name = x[0];
var mem = x[1];
console.log(name + ": ", mem.readText());
});
sleep(100);
}
}
},
"string_split": function() {
var a = "monkey:red:apple:delicious:banana:long:train:fast:airplane:high:everest:sharp:seringue:painful";
var b = a.split(':').join(':');
var c = "a=1=b=2=c=3";
var d = c.split('=').join('=');
if (a == b && c == d) {
console.log("PASS");
} else {
console.log("FAILED");
console.log(a);
console.log(b);
console.log(c);
console.log(d);
}
},
"linqjs": function() {
var a = Enumerable.range(1, 10)
.where(function(i) { return i % 3 == 0; })
.select(function(i) { return i * 10; })
;
console.log(a.toArray().join(','));
var array = "monkey:red:apple:delicious:banana:long:train:fast:airplane:high:everest:sharp:seringue:painful".split(':');
var b = Enumerable.from(array).select(function(val, i) {
return {
value: val,
index: i
}
});
console.log(JSON.stringify(b.toArray()));
},
// https://stackoverflow.com/questions/33417367/example-of-how-to-use-peg-js
"pegjs": function() {
var syntax = FILE.readFile("app/assets/pegjs/test.pegjs", FILE.CdoCharset.CdoUTF_8);
var parser = PEG.generate(syntax);
console.log(JSON.stringify(parser.parse("test123")));
},
"domparser_test": function() {
console.log(typeof DOMParser);
},
// https://github.com/gnh1201/caterpillar
"catproxy_test": function() {
var client = require('lib/catproxy');
function main(args) {
var worker = client.create("http://locahost:5555");
worker.set_method("relay_mysql_query");
worker.set_env("mysql_username", "adminer");
worker.set_env("mysql_password", "changeme");
worker.set_env("mysql_database", "dummydb");