|
1
|
/*------------------------------------------------------------------------------
|
|
2
|
upload-dialog.p #12082: web upload dialogs must close after upload
|
|
3
|
|
|
4
|
Path: SYSTEM-DIALOG GET-FILE ... AT-WEB-BROWSER [UPLOAD [DIR d]] reaches
|
|
5
|
ThinClient.chooseFile -> GuiWebDriver.chooseFiles -> the JS
|
|
6
|
p2j.screen.chooseFiles (p2j.screen.js), which drives two
|
|
7
|
p2j.ModalDialogs:
|
|
8
|
selectUploadFilesDialog "Security Warning", OK / Cancel
|
|
9
|
actionResultsDialog "Uploading...", file list + result
|
|
10
|
After the upload, onComplete shows "Uploaded N file(s)." and
|
|
11
|
closes both dialogs 5 s later (closeAction).
|
|
12
|
12082a changed p2j.ModalDialog (hide() releases the input block at
|
|
13
|
once, wantVisible, buttons under the content, setCard, z-index).
|
|
14
|
|
|
15
|
Run: web GUI only, https://localhost:7443/gui?prog=upload_12082/upload-dialog.p
|
|
16
|
|
|
17
|
Cases (one button each; run each one twice, the dialog ids are reused):
|
|
18
|
1 "Upload one" GET-FILE AT-WEB-BROWSER UPLOAD DIR <temp>
|
|
19
|
2 "Upload many" as 1, plus MULTIPLE
|
|
20
|
3 "All options" every option of the statement together:
|
|
21
|
USE-FILENAME FILTERS MUST-EXIST TITLE MULTIPLE
|
|
22
|
AT-WEB-BROWSER UPLOAD DIR UPDATE IN WINDOW ACTIVE-WINDOW
|
|
23
|
4 "Select only" AT-WEB-BROWSER without UPLOAD (closes from onChange,
|
|
24
|
no upload, no "Uploading..." dialog) - control case
|
|
25
|
Steps: Click a case button. In "Security Warning" press OK, pick a file
|
|
26
|
in the browser's file chooser. Wait for "Uploaded 1 file." and
|
|
27
|
then 5 more seconds. Click "Ping". Repeat with Cancel instead
|
|
28
|
of OK.
|
|
29
|
Expected: "Security Warning" disappears as soon as the file is picked;
|
|
30
|
"Uploading..." shows the result and is gone 5 s later; no FWD
|
|
31
|
dialog is left on screen; the log shows the GET-FILE result and
|
|
32
|
"Ping" is logged at once. The second run of a case behaves the
|
|
33
|
same as the first.
|
|
34
|
Broken: after the upload a dialog stays on screen (or "Security Warning"
|
|
35
|
becomes visible again) and is not closed by closeAction.
|
|
36
|
------------------------------------------------------------------------------*/
|
|
37
|
|
|
38
|
DEFINE VARIABLE cPath AS CHARACTER NO-UNDO.
|
|
39
|
DEFINE VARIABLE lOk AS LOGICAL NO-UNDO.
|
|
40
|
DEFINE VARIABLE cDir AS CHARACTER NO-UNDO.
|
|
41
|
DEFINE VARIABLE iSeq AS INTEGER NO-UNDO.
|
|
42
|
DEFINE VARIABLE cLog AS CHARACTER NO-UNDO
|
|
43
|
VIEW-AS EDITOR SCROLLBAR-VERTICAL SIZE 96 BY 14.
|
|
44
|
|
|
45
|
DEFINE BUTTON btnOne LABEL "1 Upload one".
|
|
46
|
DEFINE BUTTON btnMany LABEL "2 Upload many".
|
|
47
|
DEFINE BUTTON btnAll LABEL "3 All options".
|
|
48
|
DEFINE BUTTON btnSelect LABEL "4 Select only".
|
|
49
|
DEFINE BUTTON btnPing LABEL "Ping".
|
|
50
|
DEFINE BUTTON btnQuit LABEL "Quit".
|
|
51
|
|
|
52
|
DEFINE FRAME fMain
|
|
53
|
btnOne btnMany btnAll btnSelect btnPing btnQuit SKIP(0.5)
|
|
54
|
cLog NO-LABEL
|
|
55
|
WITH SIDE-LABELS THREE-D SIZE 100 BY 17 TITLE "#12082 upload dialogs".
|
|
56
|
|
|
57
|
PROCEDURE log-step:
|
|
58
|
DEFINE INPUT PARAMETER pText AS CHARACTER NO-UNDO.
|
|
59
|
|
|
60
|
iSeq = iSeq + 1.
|
|
61
|
cLog:INSERT-STRING(STRING(iSeq, "999") + " " + STRING(TIME, "HH:MM:SS") + " "
|
|
62
|
+ pText + CHR(10)) IN FRAME fMain.
|
|
63
|
END PROCEDURE.
|
|
64
|
|
|
65
|
PROCEDURE log-result:
|
|
66
|
DEFINE INPUT PARAMETER pCase AS CHARACTER NO-UNDO.
|
|
67
|
|
|
68
|
RUN log-step (pCase + " returned, selected " + STRING(lOk)
|
|
69
|
+ " [" + (IF cPath = ? THEN "?" ELSE cPath) + "]"
|
|
70
|
+ " - wait 5 s, no dialog may stay, then click Ping").
|
|
71
|
END PROCEDURE.
|
|
72
|
|
|
73
|
ON CHOOSE OF btnOne IN FRAME fMain
|
|
74
|
DO:
|
|
75
|
RUN log-step ("case 1: GET-FILE AT-WEB-BROWSER UPLOAD DIR - OK, pick one file").
|
|
76
|
ASSIGN cPath = "" lOk = NO.
|
|
77
|
SYSTEM-DIALOG GET-FILE cPath
|
|
78
|
TITLE "12082 upload one"
|
|
79
|
AT-WEB-BROWSER
|
|
80
|
UPLOAD DIR cDir
|
|
81
|
UPDATE lOk.
|
|
82
|
RUN log-result ("case 1").
|
|
83
|
END.
|
|
84
|
|
|
85
|
ON CHOOSE OF btnMany IN FRAME fMain
|
|
86
|
DO:
|
|
87
|
RUN log-step ("case 2: GET-FILE MULTIPLE AT-WEB-BROWSER UPLOAD DIR - OK, pick two files").
|
|
88
|
ASSIGN cPath = "" lOk = NO.
|
|
89
|
SYSTEM-DIALOG GET-FILE cPath
|
|
90
|
TITLE "12082 upload many"
|
|
91
|
MULTIPLE
|
|
92
|
AT-WEB-BROWSER
|
|
93
|
UPLOAD DIR cDir
|
|
94
|
UPDATE lOk.
|
|
95
|
RUN log-result ("case 2").
|
|
96
|
END.
|
|
97
|
|
|
98
|
ON CHOOSE OF btnAll IN FRAME fMain
|
|
99
|
DO:
|
|
100
|
RUN log-step ("case 3: all options - OK, pick a file").
|
|
101
|
ASSIGN cPath = "" lOk = NO.
|
|
102
|
SYSTEM-DIALOG GET-FILE cPath
|
|
103
|
USE-FILENAME
|
|
104
|
FILTERS "All files (*.*)" "*.*"
|
|
105
|
MUST-EXIST
|
|
106
|
TITLE "12082 all options"
|
|
107
|
MULTIPLE
|
|
108
|
AT-WEB-BROWSER
|
|
109
|
UPLOAD DIR cDir
|
|
110
|
UPDATE lOk
|
|
111
|
IN WINDOW ACTIVE-WINDOW.
|
|
112
|
RUN log-result ("case 3").
|
|
113
|
END.
|
|
114
|
|
|
115
|
ON CHOOSE OF btnSelect IN FRAME fMain
|
|
116
|
DO:
|
|
117
|
RUN log-step ("case 4: GET-FILE AT-WEB-BROWSER, no UPLOAD - OK, pick a file").
|
|
118
|
ASSIGN cPath = "" lOk = NO.
|
|
119
|
SYSTEM-DIALOG GET-FILE cPath
|
|
120
|
TITLE "12082 select only"
|
|
121
|
AT-WEB-BROWSER
|
|
122
|
UPDATE lOk.
|
|
123
|
RUN log-result ("case 4").
|
|
124
|
END.
|
|
125
|
|
|
126
|
ON CHOOSE OF btnPing IN FRAME fMain
|
|
127
|
DO:
|
|
128
|
RUN log-step ("Ping - the application takes input").
|
|
129
|
END.
|
|
130
|
|
|
131
|
cDir = SESSION:TEMP-DIRECTORY.
|
|
132
|
|
|
133
|
ENABLE ALL WITH FRAME fMain.
|
|
134
|
RUN log-step ("upload dir " + cDir + " - click a case button").
|
|
135
|
|
|
136
|
WAIT-FOR CHOOSE OF btnQuit IN FRAME fMain.
|