puppeteer-ruby 0.0.4 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +30 -0
  3. data/.rubocop.yml +4 -5
  4. data/README.md +3 -2
  5. data/docs/Puppeteer.html +2020 -0
  6. data/docs/Puppeteer/AsyncAwaitBehavior.html +105 -0
  7. data/docs/Puppeteer/Browser.html +2148 -0
  8. data/docs/Puppeteer/BrowserContext.html +809 -0
  9. data/docs/Puppeteer/BrowserFetcher.html +214 -0
  10. data/docs/Puppeteer/BrowserRunner.html +914 -0
  11. data/docs/Puppeteer/BrowserRunner/BrowserProcess.html +477 -0
  12. data/docs/Puppeteer/CDPSession.html +813 -0
  13. data/docs/Puppeteer/CDPSession/Error.html +124 -0
  14. data/docs/Puppeteer/ConcurrentRubyUtils.html +430 -0
  15. data/docs/Puppeteer/Connection.html +960 -0
  16. data/docs/Puppeteer/Connection/MessageCallback.html +434 -0
  17. data/docs/Puppeteer/Connection/ProtocolError.html +216 -0
  18. data/docs/Puppeteer/Connection/RequestDebugPrinter.html +217 -0
  19. data/docs/Puppeteer/Connection/ResponseDebugPrinter.html +244 -0
  20. data/docs/Puppeteer/ConsoleMessage.html +565 -0
  21. data/docs/Puppeteer/ConsoleMessage/Location.html +433 -0
  22. data/docs/Puppeteer/DOMWorld.html +2219 -0
  23. data/docs/Puppeteer/DOMWorld/DetachedError.html +124 -0
  24. data/docs/Puppeteer/DOMWorld/DocumentEvaluationError.html +124 -0
  25. data/docs/Puppeteer/DebugPrint.html +233 -0
  26. data/docs/Puppeteer/Device.html +470 -0
  27. data/docs/Puppeteer/Devices.html +139 -0
  28. data/docs/Puppeteer/ElementHandle.html +2542 -0
  29. data/docs/Puppeteer/ElementHandle/ElementNotFoundError.html +206 -0
  30. data/docs/Puppeteer/ElementHandle/ElementNotVisibleError.html +206 -0
  31. data/docs/Puppeteer/ElementHandle/Point.html +492 -0
  32. data/docs/Puppeteer/ElementHandle/ScrollIntoViewError.html +124 -0
  33. data/docs/Puppeteer/EmulationManager.html +454 -0
  34. data/docs/Puppeteer/EventCallbackable.html +433 -0
  35. data/docs/Puppeteer/EventCallbackable/EventListeners.html +435 -0
  36. data/docs/Puppeteer/ExecutionContext.html +998 -0
  37. data/docs/Puppeteer/ExecutionContext/EvaluationError.html +124 -0
  38. data/docs/Puppeteer/ExecutionContext/JavaScriptExpression.html +357 -0
  39. data/docs/Puppeteer/ExecutionContext/JavaScriptFunction.html +389 -0
  40. data/docs/Puppeteer/FileChooser.html +455 -0
  41. data/docs/Puppeteer/Frame.html +3677 -0
  42. data/docs/Puppeteer/FrameManager.html +2410 -0
  43. data/docs/Puppeteer/FrameManager/NavigationError.html +124 -0
  44. data/docs/Puppeteer/IfPresent.html +222 -0
  45. data/docs/Puppeteer/JSHandle.html +1352 -0
  46. data/docs/Puppeteer/Keyboard.html +1557 -0
  47. data/docs/Puppeteer/Keyboard/KeyDefinition.html +831 -0
  48. data/docs/Puppeteer/Keyboard/KeyDescription.html +603 -0
  49. data/docs/Puppeteer/Launcher.html +237 -0
  50. data/docs/Puppeteer/Launcher/Base.html +385 -0
  51. data/docs/Puppeteer/Launcher/Base/ExecutablePathNotFound.html +124 -0
  52. data/docs/Puppeteer/Launcher/BrowserOptions.html +441 -0
  53. data/docs/Puppeteer/Launcher/Chrome.html +669 -0
  54. data/docs/Puppeteer/Launcher/Chrome/DefaultArgs.html +382 -0
  55. data/docs/Puppeteer/Launcher/ChromeArgOptions.html +531 -0
  56. data/docs/Puppeteer/Launcher/LaunchOptions.html +893 -0
  57. data/docs/Puppeteer/LifecycleWatcher.html +834 -0
  58. data/docs/Puppeteer/LifecycleWatcher/ExpectedLifecycle.html +363 -0
  59. data/docs/Puppeteer/LifecycleWatcher/FrameDetachedError.html +206 -0
  60. data/docs/Puppeteer/LifecycleWatcher/TerminatedError.html +124 -0
  61. data/docs/Puppeteer/Mouse.html +1105 -0
  62. data/docs/Puppeteer/Mouse/Button.html +136 -0
  63. data/docs/Puppeteer/NetworkManager.html +901 -0
  64. data/docs/Puppeteer/NetworkManager/Credentials.html +385 -0
  65. data/docs/Puppeteer/Page.html +5970 -0
  66. data/docs/Puppeteer/Page/FileChooserTimeoutError.html +206 -0
  67. data/docs/Puppeteer/Page/ScreenshotOptions.html +845 -0
  68. data/docs/Puppeteer/Page/ScriptTag.html +555 -0
  69. data/docs/Puppeteer/Page/StyleTag.html +448 -0
  70. data/docs/Puppeteer/Page/TargetCrashedError.html +124 -0
  71. data/docs/Puppeteer/RemoteObject.html +1087 -0
  72. data/docs/Puppeteer/Target.html +1336 -0
  73. data/docs/Puppeteer/Target/InitializeFailure.html +124 -0
  74. data/docs/Puppeteer/Target/TargetInfo.html +729 -0
  75. data/docs/Puppeteer/TimeoutError.html +135 -0
  76. data/docs/Puppeteer/TimeoutSettings.html +496 -0
  77. data/docs/Puppeteer/TouchScreen.html +464 -0
  78. data/docs/Puppeteer/Viewport.html +837 -0
  79. data/docs/Puppeteer/WaitTask.html +637 -0
  80. data/docs/Puppeteer/WaitTask/TerminatedError.html +124 -0
  81. data/docs/Puppeteer/WaitTask/TimeoutError.html +206 -0
  82. data/docs/Puppeteer/WebSocket.html +673 -0
  83. data/docs/Puppeteer/WebSocket/DriverImpl.html +412 -0
  84. data/docs/Puppeteer/WebSocketTransport.html +600 -0
  85. data/docs/Puppeteer/WebSocktTransportError.html +124 -0
  86. data/docs/_index.html +823 -0
  87. data/docs/class_list.html +51 -0
  88. data/docs/css/common.css +1 -0
  89. data/docs/css/full_list.css +58 -0
  90. data/docs/css/style.css +496 -0
  91. data/docs/file.README.html +123 -0
  92. data/docs/file_list.html +56 -0
  93. data/docs/frames.html +17 -0
  94. data/docs/index.html +123 -0
  95. data/docs/js/app.js +314 -0
  96. data/docs/js/full_list.js +216 -0
  97. data/docs/js/jquery.js +4 -0
  98. data/docs/method_list.html +4075 -0
  99. data/docs/top-level-namespace.html +126 -0
  100. data/lib/puppeteer.rb +16 -8
  101. data/lib/puppeteer/async_await_behavior.rb +6 -0
  102. data/lib/puppeteer/browser.rb +25 -6
  103. data/lib/puppeteer/browser_runner.rb +1 -1
  104. data/lib/puppeteer/cdp_session.rb +33 -11
  105. data/lib/puppeteer/connection.rb +1 -1
  106. data/lib/puppeteer/dom_world.rb +121 -104
  107. data/lib/puppeteer/element_handle.rb +186 -224
  108. data/lib/puppeteer/element_handle/bounding_box.rb +12 -0
  109. data/lib/puppeteer/element_handle/box_model.rb +19 -0
  110. data/lib/puppeteer/element_handle/point.rb +26 -0
  111. data/lib/puppeteer/errors.rb +1 -3
  112. data/lib/puppeteer/execution_context.rb +36 -17
  113. data/lib/puppeteer/file_chooser.rb +29 -0
  114. data/lib/puppeteer/frame.rb +17 -11
  115. data/lib/puppeteer/frame_manager.rb +1 -3
  116. data/lib/puppeteer/js_handle.rb +3 -2
  117. data/lib/puppeteer/launcher.rb +0 -1
  118. data/lib/puppeteer/launcher/chrome.rb +48 -2
  119. data/lib/puppeteer/lifecycle_watcher.rb +3 -3
  120. data/lib/puppeteer/page.rb +121 -68
  121. data/lib/puppeteer/remote_object.rb +15 -1
  122. data/lib/puppeteer/target.rb +24 -24
  123. data/lib/puppeteer/version.rb +1 -1
  124. data/lib/puppeteer/viewport.rb +18 -0
  125. data/lib/puppeteer/wait_task.rb +183 -1
  126. data/lib/puppeteer/web_socket.rb +3 -1
  127. data/lib/puppeteer/web_socket_transport.rb +1 -1
  128. data/puppeteer-ruby.gemspec +4 -1
  129. metadata +145 -4
@@ -0,0 +1,637 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Puppeteer::WaitTask
8
+
9
+ &mdash; Documentation by YARD 0.9.24
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Puppeteer::WaitTask";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (W)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Puppeteer.html" title="Puppeteer (class)">Puppeteer</a></span></span>
41
+ &raquo;
42
+ <span class="title">WaitTask</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Puppeteer::WaitTask
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Puppeteer::WaitTask</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/puppeteer/wait_task.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Defined Under Namespace</h2>
103
+ <p class="children">
104
+
105
+
106
+
107
+
108
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="WaitTask/TerminatedError.html" title="Puppeteer::WaitTask::TerminatedError (class)">TerminatedError</a></span>, <span class='object_link'><a href="WaitTask/TimeoutError.html" title="Puppeteer::WaitTask::TimeoutError (class)">TimeoutError</a></span>
109
+
110
+
111
+ </p>
112
+
113
+
114
+ <h2>
115
+ Constant Summary
116
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
117
+ </h2>
118
+
119
+ <dl class="constants">
120
+
121
+ <dt id="WAIT_FOR_PREDICATE_PAGE_FUNCTION-constant" class="">WAIT_FOR_PREDICATE_PAGE_FUNCTION =
122
+
123
+ </dt>
124
+ <dd><pre class="code"><span class='heredoc_beg'>&lt;&lt;~JAVASCRIPT</span>
125
+ <span class='tstring_content'>async function _(predicateBody, polling, timeout, ...args) {
126
+ const predicate = new Function(&#39;...args&#39;, predicateBody);
127
+ let timedOut = false;
128
+ if (timeout)
129
+ setTimeout(() =&gt; (timedOut = true), timeout);
130
+ if (polling === &#39;raf&#39;)
131
+ return await pollRaf();
132
+ if (polling === &#39;mutation&#39;)
133
+ return await pollMutation();
134
+ if (typeof polling === &#39;number&#39;)
135
+ return await pollInterval(polling);
136
+ /**
137
+ * @return {!Promise&lt;*&gt;}
138
+ */
139
+ function pollMutation() {
140
+ const success = predicate(...args);
141
+ if (success)
142
+ return Promise.resolve(success);
143
+ let fulfill;
144
+ const result = new Promise((x) =&gt; (fulfill = x));
145
+ const observer = new MutationObserver(() =&gt; {
146
+ if (timedOut) {
147
+ observer.disconnect();
148
+ fulfill();
149
+ }
150
+ const success = predicate(...args);
151
+ if (success) {
152
+ observer.disconnect();
153
+ fulfill(success);
154
+ }
155
+ });
156
+ observer.observe(document, {
157
+ childList: true,
158
+ subtree: true,
159
+ attributes: true,
160
+ });
161
+ return result;
162
+ }
163
+ function pollRaf() {
164
+ let fulfill;
165
+ const result = new Promise((x) =&gt; (fulfill = x));
166
+ onRaf();
167
+ return result;
168
+ function onRaf() {
169
+ if (timedOut) {
170
+ fulfill();
171
+ return;
172
+ }
173
+ const success = predicate(...args);
174
+ if (success)
175
+ fulfill(success);
176
+ else
177
+ requestAnimationFrame(onRaf);
178
+ }
179
+ }
180
+ function pollInterval(pollInterval) {
181
+ let fulfill;
182
+ const result = new Promise((x) =&gt; (fulfill = x));
183
+ onTimeout();
184
+ return result;
185
+ function onTimeout() {
186
+ if (timedOut) {
187
+ fulfill();
188
+ return;
189
+ }
190
+ const success = predicate(...args);
191
+ if (success)
192
+ fulfill(success);
193
+ else
194
+ setTimeout(onTimeout, pollInterval);
195
+ }
196
+ }
197
+ }
198
+ </span><span class='heredoc_end'>JAVASCRIPT</span></pre></dd>
199
+
200
+ </dl>
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+ <h2>
211
+ Instance Method Summary
212
+ <small><a href="#" class="summary_toggle">collapse</a></small>
213
+ </h2>
214
+
215
+ <ul class="summary">
216
+
217
+ <li class="public ">
218
+ <span class="summary_signature">
219
+
220
+ <a href="#await_promise-instance_method" title="#await_promise (instance method)">#<strong>await_promise</strong> &#x21d2; Puppeteer::JSHandle </a>
221
+
222
+
223
+
224
+ </span>
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+ <span class="summary_desc"><div class='inline'></div></span>
235
+
236
+ </li>
237
+
238
+
239
+ <li class="public ">
240
+ <span class="summary_signature">
241
+
242
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(dom_world:, predicate_body:, title:, polling:, timeout:, args: []) &#x21d2; WaitTask </a>
243
+
244
+
245
+
246
+ </span>
247
+
248
+
249
+ <span class="note title constructor">constructor</span>
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+ <span class="summary_desc"><div class='inline'>
259
+ <p>A new instance of WaitTask.</p>
260
+ </div></span>
261
+
262
+ </li>
263
+
264
+
265
+ <li class="public ">
266
+ <span class="summary_signature">
267
+
268
+ <a href="#rerun-instance_method" title="#rerun (instance method)">#<strong>rerun</strong> &#x21d2; Object </a>
269
+
270
+
271
+
272
+ </span>
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+ <span class="summary_desc"><div class='inline'></div></span>
283
+
284
+ </li>
285
+
286
+
287
+ <li class="public ">
288
+ <span class="summary_signature">
289
+
290
+ <a href="#terminate-instance_method" title="#terminate (instance method)">#<strong>terminate</strong>(error) &#x21d2; Object </a>
291
+
292
+
293
+
294
+ </span>
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+ <span class="summary_desc"><div class='inline'></div></span>
305
+
306
+ </li>
307
+
308
+
309
+ </ul>
310
+
311
+
312
+ <div id="constructor_details" class="method_details_list">
313
+ <h2>Constructor Details</h2>
314
+
315
+ <div class="method_details first">
316
+ <h3 class="signature first" id="initialize-instance_method">
317
+
318
+ #<strong>initialize</strong>(dom_world:, predicate_body:, title:, polling:, timeout:, args: []) &#x21d2; <tt><span class='object_link'><a href="" title="Puppeteer::WaitTask (class)">WaitTask</a></span></tt>
319
+
320
+
321
+
322
+
323
+
324
+ </h3><div class="docstring">
325
+ <div class="discussion">
326
+
327
+ <p>Returns a new instance of WaitTask.</p>
328
+
329
+
330
+ </div>
331
+ </div>
332
+ <div class="tags">
333
+
334
+
335
+ </div><table class="source_code">
336
+ <tr>
337
+ <td>
338
+ <pre class="lines">
339
+
340
+
341
+ 12
342
+ 13
343
+ 14
344
+ 15
345
+ 16
346
+ 17
347
+ 18
348
+ 19
349
+ 20
350
+ 21
351
+ 22
352
+ 23
353
+ 24
354
+ 25
355
+ 26
356
+ 27
357
+ 28
358
+ 29
359
+ 30
360
+ 31
361
+ 32
362
+ 33
363
+ 34
364
+ 35
365
+ 36
366
+ 37
367
+ 38
368
+ 39
369
+ 40
370
+ 41</pre>
371
+ </td>
372
+ <td>
373
+ <pre class="code"><span class="info file"># File 'lib/puppeteer/wait_task.rb', line 12</span>
374
+
375
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>dom_world:</span><span class='comma'>,</span> <span class='label'>predicate_body:</span><span class='comma'>,</span> <span class='label'>title:</span><span class='comma'>,</span> <span class='label'>polling:</span><span class='comma'>,</span> <span class='label'>timeout:</span><span class='comma'>,</span> <span class='label'>args:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
376
+ <span class='kw'>if</span> <span class='id identifier rubyid_polling'>polling</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
377
+ <span class='kw'>if</span> <span class='id identifier rubyid_polling'>polling</span> <span class='op'>!=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>raf</span><span class='tstring_end'>&#39;</span></span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_polling'>polling</span> <span class='op'>!=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>mutation</span><span class='tstring_end'>&#39;</span></span>
378
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unknown polling option: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_polling'>polling</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
379
+ <span class='kw'>end</span>
380
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_polling'>polling</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Numeric</span><span class='rparen'>)</span>
381
+ <span class='kw'>unless</span> <span class='id identifier rubyid_polling'>polling</span><span class='period'>.</span><span class='id identifier rubyid_positive?'>positive?</span>
382
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot poll with non-positive interval: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_polling'>polling</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
383
+ <span class='kw'>end</span>
384
+ <span class='kw'>else</span>
385
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unknown polling options: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_polling'>polling</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
386
+ <span class='kw'>end</span>
387
+
388
+ <span class='ivar'>@dom_world</span> <span class='op'>=</span> <span class='id identifier rubyid_dom_world'>dom_world</span>
389
+ <span class='ivar'>@polling</span> <span class='op'>=</span> <span class='id identifier rubyid_polling'>polling</span>
390
+ <span class='ivar'>@timeout</span> <span class='op'>=</span> <span class='id identifier rubyid_timeout'>timeout</span>
391
+ <span class='ivar'>@predicate_body</span> <span class='op'>=</span> <span class='id identifier rubyid_predicate_body'>predicate_body</span>
392
+ <span class='ivar'>@args</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span>
393
+ <span class='ivar'>@run_count</span> <span class='op'>=</span> <span class='int'>0</span>
394
+ <span class='ivar'>@dom_world</span><span class='period'>.</span><span class='id identifier rubyid__wait_tasks'>_wait_tasks</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
395
+ <span class='ivar'>@promise</span> <span class='op'>=</span> <span class='id identifier rubyid_resolvable_future'><span class='object_link'><a href="ConcurrentRubyUtils.html#resolvable_future-instance_method" title="Puppeteer::ConcurrentRubyUtils#resolvable_future (method)">resolvable_future</a></span></span>
396
+
397
+ <span class='comment'># Since page navigation requires us to re-install the pageScript, we should track
398
+ </span> <span class='comment'># timeout on our end.
399
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_timeout'>timeout</span>
400
+ <span class='id identifier rubyid_timeout_error'>timeout_error</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="WaitTask/TimeoutError.html" title="Puppeteer::WaitTask::TimeoutError (class)">TimeoutError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="WaitTask/TimeoutError.html#initialize-instance_method" title="Puppeteer::WaitTask::TimeoutError#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>title:</span> <span class='id identifier rubyid_title'>title</span><span class='comma'>,</span> <span class='label'>timeout:</span> <span class='id identifier rubyid_timeout'>timeout</span><span class='rparen'>)</span>
401
+ <span class='const'>Concurrent</span><span class='op'>::</span><span class='const'>Promises</span><span class='period'>.</span><span class='id identifier rubyid_schedule'>schedule</span><span class='lparen'>(</span><span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>/</span> <span class='float'>1000.0</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_terminate'>terminate</span><span class='lparen'>(</span><span class='id identifier rubyid_timeout_error'>timeout_error</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='ivar'>@timeout_cleared</span> <span class='rbrace'>}</span>
402
+ <span class='kw'>end</span>
403
+ <span class='id identifier rubyid_async_rerun'>async_rerun</span>
404
+ <span class='kw'>end</span></pre>
405
+ </td>
406
+ </tr>
407
+ </table>
408
+ </div>
409
+
410
+ </div>
411
+
412
+
413
+ <div id="instance_method_details" class="method_details_list">
414
+ <h2>Instance Method Details</h2>
415
+
416
+
417
+ <div class="method_details first">
418
+ <h3 class="signature first" id="await_promise-instance_method">
419
+
420
+ #<strong>await_promise</strong> &#x21d2; <tt><span class='object_link'><a href="JSHandle.html" title="Puppeteer::JSHandle (class)">Puppeteer::JSHandle</a></span></tt>
421
+
422
+
423
+
424
+
425
+
426
+ </h3><div class="docstring">
427
+ <div class="discussion">
428
+
429
+
430
+ </div>
431
+ </div>
432
+ <div class="tags">
433
+
434
+ <p class="tag_title">Returns:</p>
435
+ <ul class="return">
436
+
437
+ <li>
438
+
439
+
440
+ <span class='type'>(<tt><span class='object_link'><a href="JSHandle.html" title="Puppeteer::JSHandle (class)">Puppeteer::JSHandle</a></span></tt>)</span>
441
+
442
+
443
+
444
+ </li>
445
+
446
+ </ul>
447
+
448
+ </div><table class="source_code">
449
+ <tr>
450
+ <td>
451
+ <pre class="lines">
452
+
453
+
454
+ 44
455
+ 45
456
+ 46</pre>
457
+ </td>
458
+ <td>
459
+ <pre class="code"><span class="info file"># File 'lib/puppeteer/wait_task.rb', line 44</span>
460
+
461
+ <span class='kw'>def</span> <span class='id identifier rubyid_await_promise'>await_promise</span>
462
+ <span class='ivar'>@promise</span><span class='period'>.</span><span class='id identifier rubyid_value!'>value!</span>
463
+ <span class='kw'>end</span></pre>
464
+ </td>
465
+ </tr>
466
+ </table>
467
+ </div>
468
+
469
+ <div class="method_details ">
470
+ <h3 class="signature " id="rerun-instance_method">
471
+
472
+ #<strong>rerun</strong> &#x21d2; <tt>Object</tt>
473
+
474
+
475
+
476
+
477
+
478
+ </h3><table class="source_code">
479
+ <tr>
480
+ <td>
481
+ <pre class="lines">
482
+
483
+
484
+ 54
485
+ 55
486
+ 56
487
+ 57
488
+ 58
489
+ 59
490
+ 60
491
+ 61
492
+ 62
493
+ 63
494
+ 64
495
+ 65
496
+ 66
497
+ 67
498
+ 68
499
+ 69
500
+ 70
501
+ 71
502
+ 72
503
+ 73
504
+ 74
505
+ 75
506
+ 76
507
+ 77
508
+ 78
509
+ 79
510
+ 80
511
+ 81
512
+ 82
513
+ 83
514
+ 84
515
+ 85
516
+ 86
517
+ 87
518
+ 88
519
+ 89
520
+ 90
521
+ 91
522
+ 92
523
+ 93
524
+ 94
525
+ 95
526
+ 96
527
+ 97
528
+ 98
529
+ 99
530
+ 100
531
+ 101
532
+ 102</pre>
533
+ </td>
534
+ <td>
535
+ <pre class="code"><span class="info file"># File 'lib/puppeteer/wait_task.rb', line 54</span>
536
+
537
+ <span class='kw'>def</span> <span class='id identifier rubyid_rerun'>rerun</span>
538
+ <span class='id identifier rubyid_run_count'>run_count</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='ivar'>@run_count</span> <span class='op'>+=</span> <span class='int'>1</span><span class='rparen'>)</span>
539
+ <span class='kw'>begin</span>
540
+ <span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='ivar'>@dom_world</span><span class='period'>.</span><span class='id identifier rubyid_execution_context'>execution_context</span><span class='period'>.</span><span class='id identifier rubyid_evaluate_handle'>evaluate_handle</span><span class='lparen'>(</span>
541
+ <span class='const'><span class='object_link'><a href="#WAIT_FOR_PREDICATE_PAGE_FUNCTION-constant" title="Puppeteer::WaitTask::WAIT_FOR_PREDICATE_PAGE_FUNCTION (constant)">WAIT_FOR_PREDICATE_PAGE_FUNCTION</a></span></span><span class='comma'>,</span>
542
+ <span class='ivar'>@predicate_body</span><span class='comma'>,</span>
543
+ <span class='ivar'>@polling</span><span class='comma'>,</span>
544
+ <span class='ivar'>@timeout</span><span class='comma'>,</span>
545
+ <span class='op'>*</span><span class='ivar'>@args</span><span class='comma'>,</span>
546
+ <span class='rparen'>)</span>
547
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_err'>err</span>
548
+ <span class='id identifier rubyid_error'>error</span> <span class='op'>=</span> <span class='id identifier rubyid_err'>err</span>
549
+ <span class='kw'>end</span>
550
+
551
+ <span class='kw'>if</span> <span class='ivar'>@terminated</span> <span class='op'>||</span> <span class='id identifier rubyid_run_count'>run_count</span> <span class='op'>!=</span> <span class='ivar'>@run_count</span>
552
+ <span class='kw'>if</span> <span class='id identifier rubyid_success'>success</span>
553
+ <span class='id identifier rubyid_success'>success</span><span class='period'>.</span><span class='id identifier rubyid_dispose'>dispose</span>
554
+ <span class='kw'>end</span>
555
+ <span class='kw'>return</span>
556
+ <span class='kw'>end</span>
557
+
558
+ <span class='comment'># Ignore timeouts in pageScript - we track timeouts ourselves.
559
+ </span> <span class='comment'># If the frame&#39;s execution context has already changed, `frame.evaluate` will
560
+ </span> <span class='comment'># throw an error - ignore this predicate run altogether.
561
+ </span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_error'>error</span> <span class='op'>&amp;&amp;</span> <span class='lparen'>(</span><span class='ivar'>@dom_world</span><span class='period'>.</span><span class='id identifier rubyid_evaluate'>evaluate</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>s =&gt; !s</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_success'>success</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>true</span><span class='rparen'>)</span>
562
+ <span class='id identifier rubyid_success'>success</span><span class='period'>.</span><span class='id identifier rubyid_dispose'>dispose</span>
563
+ <span class='kw'>return</span>
564
+ <span class='kw'>end</span>
565
+
566
+ <span class='comment'># When the page is navigated, the promise is rejected.
567
+ </span> <span class='comment'># We will try again in the new execution context.
568
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_error'>error</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Execution context was destroyed</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
569
+ <span class='kw'>return</span>
570
+ <span class='kw'>end</span>
571
+
572
+ <span class='comment'># We could have tried to evaluate in a context which was already
573
+ </span> <span class='comment'># destroyed.
574
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_error'>error</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Cannot find context with specified id</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
575
+ <span class='kw'>return</span>
576
+ <span class='kw'>end</span>
577
+
578
+ <span class='kw'>if</span> <span class='id identifier rubyid_error'>error</span>
579
+ <span class='ivar'>@promise</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span><span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span>
580
+ <span class='kw'>else</span>
581
+ <span class='ivar'>@promise</span><span class='period'>.</span><span class='id identifier rubyid_fulfill'>fulfill</span><span class='lparen'>(</span><span class='id identifier rubyid_success'>success</span><span class='rparen'>)</span>
582
+ <span class='kw'>end</span>
583
+
584
+ <span class='id identifier rubyid_cleanup'>cleanup</span>
585
+ <span class='kw'>end</span></pre>
586
+ </td>
587
+ </tr>
588
+ </table>
589
+ </div>
590
+
591
+ <div class="method_details ">
592
+ <h3 class="signature " id="terminate-instance_method">
593
+
594
+ #<strong>terminate</strong>(error) &#x21d2; <tt>Object</tt>
595
+
596
+
597
+
598
+
599
+
600
+ </h3><table class="source_code">
601
+ <tr>
602
+ <td>
603
+ <pre class="lines">
604
+
605
+
606
+ 48
607
+ 49
608
+ 50
609
+ 51
610
+ 52</pre>
611
+ </td>
612
+ <td>
613
+ <pre class="code"><span class="info file"># File 'lib/puppeteer/wait_task.rb', line 48</span>
614
+
615
+ <span class='kw'>def</span> <span class='id identifier rubyid_terminate'>terminate</span><span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span>
616
+ <span class='ivar'>@terminated</span> <span class='op'>=</span> <span class='kw'>true</span>
617
+ <span class='ivar'>@promise</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span><span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span>
618
+ <span class='id identifier rubyid_cleanup'>cleanup</span>
619
+ <span class='kw'>end</span></pre>
620
+ </td>
621
+ </tr>
622
+ </table>
623
+ </div>
624
+
625
+ </div>
626
+
627
+ </div>
628
+
629
+ <div id="footer">
630
+ Generated on Fri Jun 12 12:38:34 2020 by
631
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
632
+ 0.9.24 (ruby-2.6.3).
633
+ </div>
634
+
635
+ </div>
636
+ </body>
637
+ </html>