isomorfeus-puppetmaster 0.2.9 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d910895a97b5cba7d0facd8355997d015fcc46f7dd16d93732d4ac44a381e76f
4
- data.tar.gz: 17697aa1cbf72aea639ce56ab551a06f546fa7d000493ca8b875782b644d3135
3
+ metadata.gz: 422c2bb4f0581a37a50491b60bfb2b0a44b96acd903c8aaf5460d233d70eb8bf
4
+ data.tar.gz: cc52402be32baecea8e5d70071cdc9d94684ab682eec4e36f124b9185130869b
5
5
  SHA512:
6
- metadata.gz: 82c67621c640f4f5bf3c0f86a7a540b5738e1e50fec7ce067ffa1553889023b1374e28694b25b5b58840fecd9d6989ddd133e0d7904608de8157b56a5fcce8c2
7
- data.tar.gz: 3c9f02d7a90f4b552150e29fc17cf9a9692f00b71b03831cd261813fa4a50c42e33926b3ebc48fae62086b0470e0927ef343824b488e481f94dc8e6c0f5d8097
6
+ metadata.gz: 89f9b3910c274388f23623aded55d5ac5e94d620ff77586bd6f597b6cb723540b9c91d586a4f7e95e869b801832a2dee13f9db88706a32578a2e7ce3e5b52bb1
7
+ data.tar.gz: 0e79a45d2fd530702f95180cb5710b9e304244b76bfe8fe0f59ca2e62c71a349d4c8fb0704e9fc3a93f59df5731187f1086660077c7e385ff5986b2796f3d58a
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # isomorfeus-puppetmaster
2
2
 
3
3
  A framework for acceptance tests or simply running tests in a headless browser.
4
- Comes with drivers for chromium headless, firefox and jsdom.
4
+ Comes with drivers for chromium headless and jsdom.
5
5
  Allows for writing javascript tests in pure ruby.
6
6
 
7
7
  ### Community and Support
@@ -19,10 +19,9 @@ In Gemfile:
19
19
 
20
20
  Also requires the following npm modules with recommended versions:
21
21
 
22
- - [puppeteer 1.16.0](https://github.com/GoogleChrome/puppeteer#readme) - for the chromium driver
23
- - [puppeteer-firefox 0.5.0](https://www.npmjs.com/package/puppeteer-firefox) - for the firefox driver
24
- - [jsdom 14.0.0](https://github.com/jsdom/jsdom#readme) - for the jsdom driver
25
- - [canvas 2.4.1](https://github.com/Automattic/node-canvas) - for the jsdom driver (optional)
22
+ - [puppeteer 2.0.0](https://github.com/GoogleChrome/puppeteer#readme) - for the chromium driver
23
+ - [jsdom 15.2.1](https://github.com/jsdom/jsdom#readme) - for the jsdom driver
24
+ - [canvas 2.6.0](https://github.com/Automattic/node-canvas) - for the jsdom driver (optional)
26
25
 
27
26
  Simply install them in your projects root. Puppetmaster also depends on isomorfeus-speednode, which will be installed automatically.
28
27
  Speednode will pickup the node modules then from the projects root node_modules directory.
@@ -33,8 +32,6 @@ Puppetmaster provides these drivers:
33
32
  - chromium - a real browser, headless, fast
34
33
  - chromium_wsl - as above but with options so it can execute within the Windows Linux WSL
35
34
  - chromium_debug - opens a chromium browser window with devtools enabled, useful for debugging tests
36
- - firefox - real firefox, running headless, not so fast
37
- - firefox_debug - opens a firefox browser window with devtools enabled, useful for debugging tests
38
35
  - jsdom - provides a dom implementation in javascript, can execute javascript in the document, super fast, headless, has certain limitations,
39
36
  especially because its not rendering anything (no element bounding box, etc.)
40
37
  - jsdom_canvas - jsdom driver with additional support for 'canvas', requires certain libraries to be installed, see: [canvas at github](https://github.com/Automattic/node-canvas)
@@ -222,7 +222,7 @@ module Isomorfeus
222
222
  def determine_error(message)
223
223
  if message.include?('Error: certificate has expired')
224
224
  Isomorfeus::Puppetmaster::CertificateError.new(message) unless @ignore_https_errors
225
- elsif message.include?('Error: getaddrinfo ENOTFOUND')
225
+ elsif message.include?('Error: getaddrinfo')
226
226
  Isomorfeus::Puppetmaster::DNSError.new(message)
227
227
  elsif message.include?('Unknown key: ')
228
228
  Isomorfeus::Puppetmaster::KeyError.new(message)
@@ -280,7 +280,7 @@ module Isomorfeus
280
280
  LastRes = null;
281
281
  LastExecutionFinished = false;
282
282
 
283
- if (err) { return [null, err.message]; }
283
+ if (err) { return [null, err.toString() + "\\n" + err.stack]; }
284
284
  else { return [res, null]; }
285
285
 
286
286
  } else {
@@ -284,7 +284,7 @@ module Isomorfeus
284
284
  @context.eval <<~JAVASCRIPT
285
285
  AllDomHandles[#{document.handle}].window.eval(
286
286
  "var arguments = #{ "#{args}".gsub('"', '\"') };" +
287
- "#{script.gsub('\\', '\\\\\\').gsub('"', '\"').gsub("\n", "\\n")}"
287
+ "#{script.strip.gsub('\\', '\\\\\\').gsub('"', '\"').gsub("\n", "\\n")}"
288
288
  )
289
289
  JAVASCRIPT
290
290
  rescue ExecJS::ProgramError => e
@@ -295,7 +295,7 @@ module Isomorfeus
295
295
  @context.eval <<~JAVASCRIPT
296
296
  AllDomHandles[#{document.handle}].window.eval(
297
297
  "(function() { var arguments = #{ "#{args}".gsub('"', '\"') };" +
298
- "#{script.gsub('\\', '\\\\\\').gsub('"', '\"').gsub("\n", "\\n")}" +
298
+ "#{script.strip.gsub('\\', '\\\\\\').gsub('"', '\"').gsub("\n", "\\n")}" +
299
299
  "})()"
300
300
  )
301
301
  JAVASCRIPT
@@ -246,12 +246,6 @@ module Isomorfeus
246
246
  @context.eval 'LastExecutionFinished'
247
247
  end
248
248
 
249
- def firefox_require
250
- <<~JAVASCRIPT
251
- const MasterPuppeteer = require('puppeteer-firefox');
252
- JAVASCRIPT
253
- end
254
-
255
249
  def get_result
256
250
  res, err_msg = @context.eval 'GetLastResult()'
257
251
  raise determine_error(err_msg) if err_msg
@@ -282,11 +276,10 @@ module Isomorfeus
282
276
  def puppeteer_launch
283
277
  # todo target_handle, puppeteer save path
284
278
  puppeteer_require = case @browser_type
285
- when :firefox then firefox_require
286
279
  when :chrome then chromium_require
287
280
  when :chromium then chromium_require
288
281
  else
289
- raise "Browser type #{@browser_type} not supported! Browser type must be one of: chrome, firefox."
282
+ raise "Browser type #{@browser_type} not supported!"
290
283
  end
291
284
  <<~JAVASCRIPT
292
285
  #{puppeteer_require}
@@ -314,7 +307,7 @@ module Isomorfeus
314
307
  LastRes = null;
315
308
  LastExecutionFinished = false;
316
309
 
317
- if (err) { return [null, err.message]; }
310
+ if (err) { return [null, err.toString() + "\\n" + err.stack]; }
318
311
  else { return [res, null]; }
319
312
 
320
313
  } else {
@@ -370,13 +363,11 @@ module Isomorfeus
370
363
  CurrentBrowser = #{launch_line}
371
364
  var page = (await CurrentBrowser.pages())[0];
372
365
  page.setDefaultTimeout(#{@puppeteer_timeout});
373
- if (!(BrowserType === 'firefox')) {
374
- var target = page.target();
375
- var cdp_session = await target.createCDPSession();
376
- await cdp_session.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: '#{Isomorfeus::Puppetmaster.download_path}'});
377
- if (#{@url_blacklist}.length > 0) { await cdp_session.send('Network.setBlockedURLs', {urls: #{@url_blacklist}}); }
378
- await cdp_session.detach();
379
- }
366
+ var target = page.target();
367
+ var cdp_session = await target.createCDPSession();
368
+ await cdp_session.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: '#{Isomorfeus::Puppetmaster.download_path}'});
369
+ if (#{@url_blacklist}.length > 0) { await cdp_session.send('Network.setBlockedURLs', {urls: #{@url_blacklist}}); }
370
+ await cdp_session.detach();
380
371
  LastResult = RegisterPage(page);
381
372
  LastExecutionFinished = true;
382
373
  } catch (err) {
@@ -126,11 +126,9 @@ module Isomorfeus
126
126
 
127
127
  def document_clear_url_blacklist(document)
128
128
  await <<~JAVASCRIPT
129
- if (!(BrowserType === 'firefox')) {
130
- var cdp_session = await AllPageHandles[#{document.handle}].target().createCDPSession();
131
- await cdp_session.send('Network.setBlockedURLs', {urls: []});
132
- await cdp_session.detach();
133
- }
129
+ var cdp_session = await AllPageHandles[#{document.handle}].target().createCDPSession();
130
+ await cdp_session.send('Network.setBlockedURLs', {urls: []});
131
+ await cdp_session.detach();
134
132
  JAVASCRIPT
135
133
  end
136
134
 
@@ -152,12 +150,7 @@ module Isomorfeus
152
150
  }, #{@puppeteer_reaction_timeout});
153
151
  });
154
152
  AllPageHandles[#{document.handle}].on('response', response_handler);
155
- var navigation_watcher;
156
- if (BrowserType === 'firefox') {
157
- navigation_watcher = AllPageHandles[#{document.handle}].waitFor(1000);
158
- } else {
159
- navigation_watcher = AllPageHandles[#{document.handle}].waitForNavigation();
160
- }
153
+ var navigation_watcher = AllPageHandles[#{document.handle}].waitForNavigation();
161
154
  await AllPageHandles[#{document.handle}].evaluate(function(){
162
155
  var options = {button: 0, bubbles: true, cancelable: true};
163
156
  var node = window;
@@ -290,12 +283,7 @@ module Isomorfeus
290
283
  }, #{@puppeteer_reaction_timeout});
291
284
  });
292
285
  AllPageHandlers[#{document.handle}].on('response', response_handler);
293
- var navigation_watcher;
294
- if (BrowserType === 'firefox') {
295
- navigation_watcher = AllPageHandles[#{document.handle}].waitFor(1000);
296
- } else {
297
- navigation_watcher = AllPageHandles[#{document.handle}].waitForNavigation();
298
- }
286
+ var navigation_watcher = AllPageHandles[#{document.handle}].waitForNavigation();
299
287
  await AllPageHandles[#{document.handle}].evaluate(function(){
300
288
  var options = {button: 0, bubbles: true, cancelable: true};
301
289
  var node = window;
@@ -323,7 +311,7 @@ module Isomorfeus
323
311
  def document_evaluate_script(document, script, *args)
324
312
  await <<~JAVASCRIPT
325
313
  LastResult = await AllPageHandles[#{document.handle}].evaluate((arguments) => {
326
- return #{script}
314
+ return #{script.strip}
327
315
  }, #{args});
328
316
  JAVASCRIPT
329
317
  end
@@ -331,7 +319,7 @@ module Isomorfeus
331
319
  def document_execute_script(document, script, *args)
332
320
  await <<~JAVASCRIPT
333
321
  LastResult = await AllPageHandles[#{document.handle}].evaluate((arguments) => {
334
- #{script}
322
+ #{script.strip}
335
323
  }, #{args});
336
324
  JAVASCRIPT
337
325
  end
@@ -589,13 +577,11 @@ module Isomorfeus
589
577
  var url = '#{parsed_uri.to_s}';
590
578
  new_page.setDefaultTimeout(#{@puppeteer_timeout});
591
579
  await new_page.setViewport({width: #{@width}, height: #{@height}});
592
- if (!(BrowserType === 'firefox')) {
593
- var new_target = new_page.target();
594
- var cdp_session = await new_target.createCDPSession();
595
- await cdp_session.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: '#{Isomorfeus::Puppetmaster.download_path}'});
596
- if (#{@url_blacklist}.length > 0) { await cdp_session.send('Network.setBlockedURLs', {urls: #{@url_blacklist}}); }
597
- await cdp_session.detach();
598
- }
580
+ var new_target = new_page.target();
581
+ var cdp_session = await new_target.createCDPSession();
582
+ await cdp_session.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: '#{Isomorfeus::Puppetmaster.download_path}'});
583
+ if (#{@url_blacklist}.length > 0) { await cdp_session.send('Network.setBlockedURLs', {urls: #{@url_blacklist}}); }
584
+ await cdp_session.detach();
599
585
  var page_handle = RegisterPage(new_page);
600
586
  var result_response = null;
601
587
  if (url && url !== '') {
@@ -677,12 +663,7 @@ module Isomorfeus
677
663
  }, #{@puppeteer_reaction_timeout});
678
664
  });
679
665
  AllPageHandles[#{document.handle}].on('response', response_handler);
680
- var navigation_watcher;
681
- if (BrowserType === 'firefox') {
682
- navigation_watcher = AllPageHandles[#{document.handle}].waitFor(1000);
683
- } else {
684
- navigation_watcher = AllPageHandles[#{document.handle}].waitForNavigation();
685
- }
666
+ var navigation_watcher = AllPageHandles[#{document.handle}].waitForNavigation();
686
667
  await AllPageHandles[#{document.handle}].evaluate(function(){
687
668
  var options = {button: 2, bubbles: true, cancelable: true};
688
669
  var node = window;
@@ -780,18 +761,16 @@ module Isomorfeus
780
761
  end
781
762
 
782
763
  def document_set_extra_headers(document, headers_hash)
783
- await "await AllPageHandles[#{document.handle}].setExtraHTTPHeaders({#{headers_hash.map { |k, v| "'#{k}': '#{v}'" }.join(', ')}});"
764
+ await "await AllPageHandles[#{document.handle}].setExtraHTTPHeaders(#{Oj.dump(headers_hash, mode: :strict)});"
784
765
  end
785
766
 
786
767
  def document_set_url_blacklist(document, url_array)
787
768
  # https://www.chromium.org/administrators/url-blacklist-filter-format
788
769
  @url_blacklist = url_array
789
770
  await <<~JAVASCRIPT
790
- if (!(BrowserType === 'firefox')) {
791
- var cdp_session = await AllPageHandles[#{document.handle}].target().createCDPSession();
792
- await cdp_session.send('Network.setBlockedURLs', {urls: #{url_array}});
793
- await cdp_session.detach();
794
- }
771
+ var cdp_session = await AllPageHandles[#{document.handle}].target().createCDPSession();
772
+ await cdp_session.send('Network.setBlockedURLs', {urls: #{url_array}});
773
+ await cdp_session.detach();
795
774
  JAVASCRIPT
796
775
  end
797
776
 
@@ -27,12 +27,7 @@ module Isomorfeus
27
27
  }, #{@puppeteer_reaction_timeout});
28
28
  });
29
29
  AllPageHandles[#{node.document.handle}].on('response', response_handler);
30
- var navigation_watcher;
31
- if (BrowserType === 'firefox') {
32
- navigation_watcher = AllPageHandles[#{node.document.handle}].waitFor(1000);
33
- } else {
34
- navigation_watcher = AllPageHandles[#{node.document.handle}].waitForNavigation();
35
- }
30
+ var navigation_watcher = AllPageHandles[#{node.document.handle}].waitForNavigation();
36
31
  await AllElementHandles[#{node.handle}].executionContext().evaluate(function(node){
37
32
  var options = {button: 0, bubbles: true, cancelable: true};
38
33
  var x = #{x ? x : 'null'};
@@ -95,12 +90,7 @@ module Isomorfeus
95
90
  }, #{@puppeteer_reaction_timeout});
96
91
  });
97
92
  AllPageHandles[#{node.document.handle}].on('response', response_handler);
98
- var navigation_watcher;
99
- if (BrowserType === 'firefox') {
100
- navigation_watcher = AllPageHandles[#{node.document.handle}].waitFor(1000);
101
- } else {
102
- navigation_watcher = AllPageHandles[#{node.document.handle}].waitForNavigation();
103
- }
93
+ var navigation_watcher = AllPageHandles[#{node.document.handle}].waitForNavigation();
104
94
  await AllElementHandles[#{node.handle}].executionContext().evaluate(function(node){
105
95
  var options = {button: 0, bubbles: true, cancelable: true};
106
96
  var x = #{x ? x : 'null'};
@@ -475,12 +465,7 @@ module Isomorfeus
475
465
  }, #{@puppeteer_reaction_timeout});
476
466
  });
477
467
  AllPageHandles[#{node.document.handle}].on('response', response_handler);
478
- var navigation_watcher;
479
- if (BrowserType === 'firefox') {
480
- navigation_watcher = AllPageHandles[#{node.document.handle}].waitFor(1000);
481
- } else {
482
- navigation_watcher = AllPageHandles[#{node.document.handle}].waitForNavigation();
483
- }
468
+ var navigation_watcher = AllPageHandles[#{node.document.handle}].waitForNavigation();
484
469
  await AllElementHandles[#{node.handle}].executionContext().evaluate(function(node){
485
470
  var options = {button: 2, bubbles: true, cancelable: true};
486
471
  var x = #{x ? x : 'null'};
@@ -10,14 +10,6 @@ Isomorfeus::Puppetmaster.register_driver(:chromium_debug) do |app|
10
10
  Isomorfeus::Puppetmaster::Driver::Puppeteer.new(browser_type: :chromium, headless: false, devtools: true, app: app)
11
11
  end
12
12
 
13
- Isomorfeus::Puppetmaster.register_driver(:firefox) do |app|
14
- Isomorfeus::Puppetmaster::Driver::Puppeteer.new(browser_type: :firefox, headless: true, app: app)
15
- end
16
-
17
- Isomorfeus::Puppetmaster.register_driver(:firefox_debug) do |app|
18
- Isomorfeus::Puppetmaster::Driver::Puppeteer.new(browser_type: :firefox, headless: false, devtools: true, app: app)
19
- end
20
-
21
13
  Isomorfeus::Puppetmaster.register_driver(:jsdom) do |app|
22
14
  Isomorfeus::Puppetmaster::Driver::Jsdom.new(app: app)
23
15
  end
@@ -1,3 +1,3 @@
1
1
  module Isomorfeus
2
- PUPPETMASTER_VERSION = '0.2.9'
3
- end
2
+ PUPPETMASTER_VERSION = '0.3.0'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-puppetmaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-26 00:00:00.000000000 Z
11
+ date: 2019-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.10
33
+ version: 0.2.11
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.10
40
+ version: 0.2.11
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: method_source
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 2.8.2
117
+ version: 2.11.3
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 2.8.2
124
+ version: 2.11.3
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: chunky_png
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 0.7.33
173
+ version: 0.7.36
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 0.7.33
180
+ version: 0.7.36
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: irb
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -254,14 +254,14 @@ dependencies:
254
254
  requirements:
255
255
  - - "~>"
256
256
  - !ruby/object:Gem::Version
257
- version: 3.12.0
257
+ version: 4.2.1
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
- version: 3.12.0
264
+ version: 4.2.1
265
265
  - !ruby/object:Gem::Dependency
266
266
  name: rake
267
267
  requirement: !ruby/object:Gem::Requirement
@@ -375,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
375
  - !ruby/object:Gem::Version
376
376
  version: '0'
377
377
  requirements: []
378
- rubygems_version: 3.0.3
378
+ rubygems_version: 3.0.6
379
379
  signing_key:
380
380
  specification_version: 4
381
381
  summary: Acceptance testing for isomorfeus.