@@ -123,12 +123,9 @@ describe("Translation", function() {
123
123
assert . equal ( items . length , 1 ) ;
124
124
assert . equal ( items [ 0 ] . itemType , 'journalArticle' ) ;
125
125
var frameURL = getExtensionURL ( 'progressWindow/progressWindow.html' ) ;
126
- var message = await tab . runInFrame ( frameURL , async function ( ) {
127
- // TODO: A more robust way to wait for the text to show up.
128
- let timeout = Zotero . isFirefox ? 1000 : 100 ;
129
- await Zotero . Promise . delay ( timeout ) ;
130
- return document . querySelector ( '.ProgressWindow-progressBox' ) . textContent ;
131
- } ) ;
126
+ var frame = await tab . page . waitForFrame ( frameURL ) ;
127
+ var elem = await frame . waitForSelector ( '.ProgressWindow-progressBox' ) ;
128
+ var message = await elem . evaluate ( node => node . textContent ) ;
132
129
assert . include ( message , items [ 0 ] . title ) ;
133
130
} ) ;
134
131
@@ -152,12 +149,9 @@ describe("Translation", function() {
152
149
assert . equal ( items . length , 1 ) ;
153
150
assert . equal ( items [ 0 ] . itemType , 'journalArticle' ) ;
154
151
var frameURL = getExtensionURL ( 'progressWindow/progressWindow.html' ) ;
155
- var message = await tab . runInFrame ( frameURL , async function ( ) {
156
- // TODO: A more robust way to wait for the text to show up.
157
- let timeout = Zotero . isFirefox ? 1000 : 100 ;
158
- await Zotero . Promise . delay ( timeout ) ;
159
- return document . querySelector ( '.ProgressWindow-progressBox' ) . textContent ;
160
- } ) ;
152
+ var frame = await tab . page . waitForFrame ( frameURL ) ;
153
+ var elem = await frame . waitForSelector ( '.ProgressWindow-progressBox' ) ;
154
+ var message = await elem . evaluate ( node => node . textContent ) ;
161
155
assert . include ( message , items [ 0 ] . title ) ;
162
156
} ) ;
163
157
@@ -170,12 +164,9 @@ describe("Translation", function() {
170
164
} , tab . tabId ) ;
171
165
await delay ( 20 ) ;
172
166
var frameURL = getExtensionURL ( 'progressWindow/progressWindow.html' ) ;
173
- var message = await tab . runInFrame ( frameURL , async function ( ) {
174
- // TODO: A more robust way to wait for the text to show up.
175
- let timeout = Zotero . isFirefox ? 1000 : 100 ;
176
- await Zotero . Promise . delay ( timeout ) ;
177
- return document . querySelector ( '.ProgressWindow-progressBox' ) . textContent ;
178
- } ) ;
167
+ var frame = await tab . page . waitForFrame ( frameURL ) ;
168
+ var elem = await frame . waitForSelector ( '.ProgressWindow-progressBox' ) ;
169
+ var message = await elem . evaluate ( node => node . textContent ) ;
179
170
assert . include ( message , "Scarcity or Abundance? Preserving the Past in a Digital Era" ) ;
180
171
} finally {
181
172
await background ( ( ) => Zotero . Connector . callMethodWithCookies . restore ( ) )
@@ -200,12 +191,9 @@ describe("Translation", function() {
200
191
}
201
192
} , tab . tabId ) ;
202
193
var frameURL = getExtensionURL ( 'progressWindow/progressWindow.html' ) ;
203
- var message = await tab . runInFrame ( frameURL , async function ( ) {
204
- // TODO: A more robust way to wait for the text to show up.
205
- let timeout = Zotero . isFirefox ? 1000 : 100 ;
206
- await Zotero . Promise . delay ( timeout ) ;
207
- return document . querySelector ( '.ProgressWindow-error' ) . textContent ;
208
- } ) ;
194
+ var frame = await tab . page . waitForFrame ( frameURL ) ;
195
+ var elem = await frame . waitForSelector ( '.ProgressWindow-error' ) ;
196
+ var message = await elem . evaluate ( node => node . textContent ) ;
209
197
assert . include ( message , "An error occurred while saving this item." ) ;
210
198
} ) ;
211
199
} ) ;
@@ -235,14 +223,10 @@ describe("Translation", function() {
235
223
Zotero . Connector_Browser . saveWithTranslator ( tab , 0 ) . then ( deferred . resolve ) . catch ( deferred . reject ) ;
236
224
} , tab . tabId ) ;
237
225
// Wait for the modal prompt to appear
238
- await delay ( 500 ) ;
239
226
var frameURL = getExtensionURL ( 'modalPrompt/modalPrompt.html' ) ;
240
- var message = await tab . runInFrame ( frameURL , async function ( ) {
241
- // TODO: A more robust way to wait for the text to show up.
242
- let timeout = Zotero . isFirefox ? 1000 : 100 ;
243
- await Zotero . Promise . delay ( timeout ) ;
244
- return document . getElementById ( 'zotero-modal-prompt' ) . textContent ;
245
- } ) ;
227
+ var frame = await tab . page . waitForFrame ( frameURL ) ;
228
+ var elem = await frame . waitForSelector ( '#zotero-modal-prompt' ) ;
229
+ var message = await elem . evaluate ( node => node . textContent ) ;
246
230
assert . include ( message , 'The Zotero Connector was unable to communicate with the Zotero desktop application.' ) ;
247
231
} finally {
248
232
await background ( function ( ) {
@@ -270,12 +254,9 @@ describe("Translation", function() {
270
254
271
255
try {
272
256
var frameURL = getExtensionURL ( 'progressWindow/progressWindow.html' ) ;
273
- var message = await tab . runInFrame ( frameURL , async function ( ) {
274
- // TODO: A more robust way to wait for the text to show up.
275
- let timeout = Zotero . isFirefox ? 1000 : 100 ;
276
- await Zotero . Promise . delay ( timeout ) ;
277
- return document . querySelector ( '.ProgressWindow-box' ) . textContent ;
278
- } ) ;
257
+ var frame = await tab . page . waitForFrame ( frameURL ) ;
258
+ var elem = await frame . waitForSelector ( '.ProgressWindow-box' ) ;
259
+ var message = await elem . evaluate ( node => node . textContent ) ;
279
260
280
261
assert . include ( message , 'zotero.org' ) ;
281
262
assert . include ( message , 'Scarcity or Abundance? Preserving the Past in a Digital Era' ) ;
0 commit comments