puppeteer-ruby 0.0.11 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +0 -12
  3. data/.github/workflows/docs.yml +45 -0
  4. data/.github/workflows/reviewdog.yml +15 -0
  5. data/README.md +54 -1
  6. data/lib/puppeteer.rb +39 -13
  7. data/lib/puppeteer/browser.rb +22 -25
  8. data/lib/puppeteer/cdp_session.rb +3 -19
  9. data/lib/puppeteer/concurrent_ruby_utils.rb +12 -2
  10. data/lib/puppeteer/connection.rb +3 -15
  11. data/lib/puppeteer/define_async_method.rb +23 -0
  12. data/lib/puppeteer/dom_world.rb +51 -65
  13. data/lib/puppeteer/element_handle.rb +15 -44
  14. data/lib/puppeteer/emulation_manager.rb +2 -6
  15. data/lib/puppeteer/event_callbackable.rb +11 -0
  16. data/lib/puppeteer/execution_context.rb +1 -6
  17. data/lib/puppeteer/frame.rb +34 -39
  18. data/lib/puppeteer/frame_manager.rb +7 -25
  19. data/lib/puppeteer/js_handle.rb +3 -12
  20. data/lib/puppeteer/keyboard.rb +6 -27
  21. data/lib/puppeteer/launcher.rb +6 -6
  22. data/lib/puppeteer/launcher/chrome.rb +10 -8
  23. data/lib/puppeteer/mouse.rb +5 -25
  24. data/lib/puppeteer/network_manager.rb +163 -5
  25. data/lib/puppeteer/page.rb +230 -177
  26. data/lib/puppeteer/page/pdf_options.rb +166 -0
  27. data/lib/puppeteer/remote_object.rb +2 -5
  28. data/lib/puppeteer/request.rb +336 -0
  29. data/lib/puppeteer/response.rb +113 -0
  30. data/lib/puppeteer/target.rb +1 -1
  31. data/lib/puppeteer/touch_screen.rb +2 -7
  32. data/lib/puppeteer/version.rb +1 -1
  33. data/lib/puppeteer/wait_task.rb +2 -4
  34. data/lib/puppeteer/web_socket_transport.rb +8 -8
  35. data/puppeteer-ruby.gemspec +1 -1
  36. data/puppeteer-ruby.png +0 -0
  37. metadata +11 -105
  38. data/Dockerfile +0 -6
  39. data/docker-compose.yml +0 -15
  40. data/docs/Puppeteer.html +0 -2020
  41. data/docs/Puppeteer/AsyncAwaitBehavior.html +0 -105
  42. data/docs/Puppeteer/Browser.html +0 -2258
  43. data/docs/Puppeteer/BrowserContext.html +0 -809
  44. data/docs/Puppeteer/BrowserFetcher.html +0 -214
  45. data/docs/Puppeteer/BrowserRunner.html +0 -914
  46. data/docs/Puppeteer/BrowserRunner/BrowserProcess.html +0 -477
  47. data/docs/Puppeteer/CDPSession.html +0 -813
  48. data/docs/Puppeteer/CDPSession/Error.html +0 -124
  49. data/docs/Puppeteer/ConcurrentRubyUtils.html +0 -430
  50. data/docs/Puppeteer/Connection.html +0 -964
  51. data/docs/Puppeteer/Connection/MessageCallback.html +0 -434
  52. data/docs/Puppeteer/Connection/ProtocolError.html +0 -216
  53. data/docs/Puppeteer/Connection/RequestDebugPrinter.html +0 -217
  54. data/docs/Puppeteer/Connection/ResponseDebugPrinter.html +0 -244
  55. data/docs/Puppeteer/ConsoleMessage.html +0 -565
  56. data/docs/Puppeteer/ConsoleMessage/Location.html +0 -433
  57. data/docs/Puppeteer/DOMWorld.html +0 -2219
  58. data/docs/Puppeteer/DOMWorld/DetachedError.html +0 -124
  59. data/docs/Puppeteer/DOMWorld/DocumentEvaluationError.html +0 -124
  60. data/docs/Puppeteer/DebugPrint.html +0 -233
  61. data/docs/Puppeteer/Device.html +0 -470
  62. data/docs/Puppeteer/Devices.html +0 -139
  63. data/docs/Puppeteer/ElementHandle.html +0 -2542
  64. data/docs/Puppeteer/ElementHandle/BoundingBox.html +0 -507
  65. data/docs/Puppeteer/ElementHandle/BoxModel.html +0 -404
  66. data/docs/Puppeteer/ElementHandle/ElementNotFoundError.html +0 -206
  67. data/docs/Puppeteer/ElementHandle/ElementNotVisibleError.html +0 -206
  68. data/docs/Puppeteer/ElementHandle/Point.html +0 -492
  69. data/docs/Puppeteer/ElementHandle/ScrollIntoViewError.html +0 -124
  70. data/docs/Puppeteer/EmulationManager.html +0 -454
  71. data/docs/Puppeteer/EventCallbackable.html +0 -433
  72. data/docs/Puppeteer/EventCallbackable/EventListeners.html +0 -435
  73. data/docs/Puppeteer/ExecutionContext.html +0 -998
  74. data/docs/Puppeteer/ExecutionContext/EvaluationError.html +0 -124
  75. data/docs/Puppeteer/ExecutionContext/JavaScriptExpression.html +0 -357
  76. data/docs/Puppeteer/ExecutionContext/JavaScriptFunction.html +0 -389
  77. data/docs/Puppeteer/FileChooser.html +0 -455
  78. data/docs/Puppeteer/Frame.html +0 -3813
  79. data/docs/Puppeteer/FrameManager.html +0 -2410
  80. data/docs/Puppeteer/FrameManager/NavigationError.html +0 -124
  81. data/docs/Puppeteer/IfPresent.html +0 -222
  82. data/docs/Puppeteer/JSHandle.html +0 -1352
  83. data/docs/Puppeteer/Keyboard.html +0 -1557
  84. data/docs/Puppeteer/Keyboard/KeyDefinition.html +0 -831
  85. data/docs/Puppeteer/Keyboard/KeyDescription.html +0 -603
  86. data/docs/Puppeteer/Launcher.html +0 -237
  87. data/docs/Puppeteer/Launcher/Base.html +0 -385
  88. data/docs/Puppeteer/Launcher/Base/ExecutablePathNotFound.html +0 -124
  89. data/docs/Puppeteer/Launcher/BrowserOptions.html +0 -441
  90. data/docs/Puppeteer/Launcher/Chrome.html +0 -669
  91. data/docs/Puppeteer/Launcher/Chrome/DefaultArgs.html +0 -382
  92. data/docs/Puppeteer/Launcher/ChromeArgOptions.html +0 -531
  93. data/docs/Puppeteer/Launcher/LaunchOptions.html +0 -893
  94. data/docs/Puppeteer/LifecycleWatcher.html +0 -834
  95. data/docs/Puppeteer/LifecycleWatcher/ExpectedLifecycle.html +0 -363
  96. data/docs/Puppeteer/LifecycleWatcher/FrameDetachedError.html +0 -206
  97. data/docs/Puppeteer/LifecycleWatcher/TerminatedError.html +0 -124
  98. data/docs/Puppeteer/Mouse.html +0 -1095
  99. data/docs/Puppeteer/Mouse/Button.html +0 -136
  100. data/docs/Puppeteer/NetworkManager.html +0 -901
  101. data/docs/Puppeteer/NetworkManager/Credentials.html +0 -385
  102. data/docs/Puppeteer/Page.html +0 -5970
  103. data/docs/Puppeteer/Page/FileChooserTimeoutError.html +0 -206
  104. data/docs/Puppeteer/Page/ScreenshotOptions.html +0 -845
  105. data/docs/Puppeteer/Page/ScriptTag.html +0 -555
  106. data/docs/Puppeteer/Page/StyleTag.html +0 -448
  107. data/docs/Puppeteer/Page/TargetCrashedError.html +0 -124
  108. data/docs/Puppeteer/RemoteObject.html +0 -1087
  109. data/docs/Puppeteer/Target.html +0 -1336
  110. data/docs/Puppeteer/Target/InitializeFailure.html +0 -124
  111. data/docs/Puppeteer/Target/TargetInfo.html +0 -729
  112. data/docs/Puppeteer/TimeoutError.html +0 -135
  113. data/docs/Puppeteer/TimeoutSettings.html +0 -496
  114. data/docs/Puppeteer/TouchScreen.html +0 -464
  115. data/docs/Puppeteer/Viewport.html +0 -837
  116. data/docs/Puppeteer/WaitTask.html +0 -637
  117. data/docs/Puppeteer/WaitTask/TerminatedError.html +0 -124
  118. data/docs/Puppeteer/WaitTask/TimeoutError.html +0 -206
  119. data/docs/Puppeteer/WebSocket.html +0 -673
  120. data/docs/Puppeteer/WebSocket/DriverImpl.html +0 -412
  121. data/docs/Puppeteer/WebSocket/TransportError.html +0 -124
  122. data/docs/Puppeteer/WebSocketTransport.html +0 -600
  123. data/docs/Puppeteer/WebSocktTransportError.html +0 -124
  124. data/docs/_index.html +0 -816
  125. data/docs/class_list.html +0 -51
  126. data/docs/css/common.css +0 -1
  127. data/docs/css/full_list.css +0 -58
  128. data/docs/css/style.css +0 -496
  129. data/docs/file.README.html +0 -123
  130. data/docs/file_list.html +0 -56
  131. data/docs/frames.html +0 -17
  132. data/docs/index.html +0 -123
  133. data/docs/js/app.js +0 -314
  134. data/docs/js/full_list.js +0 -216
  135. data/docs/js/jquery.js +0 -4
  136. data/docs/method_list.html +0 -4091
  137. data/docs/top-level-namespace.html +0 -126
  138. data/lib/puppeteer/async_await_behavior.rb +0 -38
@@ -1,637 +0,0 @@
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 Sat Jun 20 17:15:07 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>