eyes_selenium 3.17.19 → 3.17.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6289f627e365bab6d1a0c3908dd1af84e838492ba38778c90aa190374fb1dc71
4
- data.tar.gz: 343c13925eb6c8c6e1d443aed4b73a102765b24389b8a0f31a03f6d328506eb2
3
+ metadata.gz: 94222e9f9e0b16492fd4d984c42d0142865c54b35508492d177325a49337f69e
4
+ data.tar.gz: b82d1d07bb6bd80c35e11631274dca4cb01f2f5901d297c861ceccc913c46f9b
5
5
  SHA512:
6
- metadata.gz: bb7e4c3cb57a319a8477d3f06de322875f3619eef31ff5f8f43291440d3cc7920bebee51b85887866aca9921fd4745548600811e56784accb602750f362df4e9
7
- data.tar.gz: abc47d3ac64cc4f80e42b74329dac0dbcf0de0fb8d70989af4f55acd8190c0fbf2934ed6d1061b7c5e6cfe937a7210b7c05b2b490a50ad9c1b8b69731bff8b59
6
+ metadata.gz: c32c6b2ff43f980696d98f89cfbf7f39f856ead5600f1be984c7cfa9f454492a3a53090a89ca8c6437f95e12ae3d6dff3281a465c9f4328df2491698b85bbd87
7
+ data.tar.gz: 89fb8dd500897f121d07f16c6cd38692e3832c15fe255d07e02f8ad8cb42d30e38078f69f29fb6dceec1244ee941ffd3e4aa57f40c06bfa7d244e739c70dd17d
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ yarn.lock
3
+ yarn-error.log
4
+ process_page_and_poll.rb
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "applitools_related_scripts",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "license": "MIT",
6
+ "dependencies": {
7
+ "@applitools/dom-snapshot": "^4.0.5"
8
+ }
9
+ }
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Applitools
4
2
  module Selenium
5
3
  module Scripts
@@ -13,7 +11,6 @@ const s=t?yc(Date.now()):jl;s("processPage start"),s("skipResources length: "+(a
13
11
 
14
12
  return processPageAndSerializePoll.apply(this, arguments);
15
13
  }
16
-
17
14
  END
18
15
  end
19
16
  end
@@ -0,0 +1,33 @@
1
+ module Applitools
2
+ module Selenium
3
+ module ScriptTemplates
4
+ extend self
5
+ def get_script_by_file_name(fname)
6
+ script = nil
7
+ begin
8
+ Dir.chdir(Applitools::JS_PATH) do
9
+ script = File.open(File.join('@applitools', 'dom-snapshot', 'dist', "#{fname}.js"), 'r').read
10
+ end
11
+ rescue StandardError => e
12
+ puts e.class
13
+ puts e.message
14
+ script = ''
15
+ end
16
+ script
17
+ end
18
+
19
+ # JS_FILES_PATH = File.join(Applitools::JS_PATH, '@applitools', 'dom-snapshot', 'dist')
20
+ PROCESS_PAGE_AND_POLL_RB = <<"SCRIPT"
21
+ module Applitools
22
+ module Selenium
23
+ module Scripts
24
+ PROCESS_PAGE_AND_POLL = <<'END'
25
+ #{get_script_by_file_name('processPageAndSerializePoll')}
26
+ END
27
+ end
28
+ end
29
+ end
30
+ SCRIPT
31
+ end
32
+ end
33
+ end
@@ -8,14 +8,18 @@ module Applitools
8
8
  module Selenium
9
9
  class VGResource
10
10
  include Applitools::Jsonable
11
- json_fields :contentType, :hash, :hashFormat
11
+ json_fields :contentType, :hash, :hashFormat, :errorStatusCode
12
12
  attr_accessor :url, :content, :handle_discovered_resources_block
13
13
  alias content_type contentType
14
14
  alias content_type= contentType=
15
15
 
16
16
  class << self
17
17
  def parse_blob_from_script(blob, options = {})
18
- return new(blob['url'], "application/X-error-response-#{blob['errorStatusCode']}", blob['value'] || '') if blob['errorStatusCode']
18
+ return new(
19
+ blob['url'],
20
+ "application/X-error-response-#{blob['errorStatusCode']}",
21
+ blob['value'] || ''
22
+ ).tap {|r| r.error_status_code = blob['errorStatusCode']} if blob['errorStatusCode']
19
23
  content = Base64.decode64(blob['value'])
20
24
  new(blob['url'], blob['type'], content, options)
21
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Applitools
4
- VERSION = '3.17.19'.freeze
4
+ VERSION = '3.17.20'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyes_selenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.17.19
4
+ version: 3.17.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Applitools Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-18 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eyes_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.17.19
19
+ version: 3.17.20
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.17.19
26
+ version: 3.17.20
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: selenium-webdriver
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -138,9 +138,11 @@ files:
138
138
  - lib/applitools/selenium/render_resources.rb
139
139
  - lib/applitools/selenium/rgrid_dom.rb
140
140
  - lib/applitools/selenium/sauce/driver.rb
141
+ - lib/applitools/selenium/scripts/.gitignore
141
142
  - lib/applitools/selenium/scripts/get_element_xpath.rb
143
+ - lib/applitools/selenium/scripts/package.json
142
144
  - lib/applitools/selenium/scripts/process_page_and_poll.rb
143
- - lib/applitools/selenium/scripts/process_page_and_serialize.rb
145
+ - lib/applitools/selenium/scripts/templates.rb
144
146
  - lib/applitools/selenium/scroll_position_provider.rb
145
147
  - lib/applitools/selenium/selenium_eyes.rb
146
148
  - lib/applitools/selenium/stitch_modes.rb
@@ -1,536 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Selenium
5
- module Scripts
6
- PROCESS_RESOURCES = <<'END'
7
- // @applitools/dom-snapshot@1.1.2
8
- function __processPageAndSerialize() {
9
- var processPageAndSerialize = (function () {
10
- 'use strict';
11
-
12
- // This code was copied and modified from https://github.com/beatgammit/base64-js/blob/bf68aaa277/index.js
13
- // License: https://github.com/beatgammit/base64-js/blob/bf68aaa277d9de7007cc0c58279c411bb10670ac/LICENSE
14
-
15
- function arrayBufferToBase64(ab) {
16
- const lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
17
-
18
- const uint8 = new Uint8Array(ab);
19
- const len = uint8.length;
20
- const extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
21
- const parts = [];
22
- const maxChunkLength = 16383; // must be multiple of 3
23
-
24
- let tmp;
25
-
26
- // go through the array every three bytes, we'll deal with trailing stuff later
27
- for (let i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
28
- parts.push(encodeChunk(i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
29
- }
30
-
31
- // pad the end with zeros, but make sure to not forget the extra bytes
32
- if (extraBytes === 1) {
33
- tmp = uint8[len - 1];
34
- parts.push(lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3f] + '==');
35
- } else if (extraBytes === 2) {
36
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
37
- parts.push(lookup[tmp >> 10] + lookup[(tmp >> 4) & 0x3f] + lookup[(tmp << 2) & 0x3f] + '=');
38
- }
39
-
40
- return parts.join('');
41
-
42
- function tripletToBase64(num) {
43
- return (
44
- lookup[(num >> 18) & 0x3f] +
45
- lookup[(num >> 12) & 0x3f] +
46
- lookup[(num >> 6) & 0x3f] +
47
- lookup[num & 0x3f]
48
- );
49
- }
50
-
51
- function encodeChunk(start, end) {
52
- let tmp;
53
- const output = [];
54
- for (let i = start; i < end; i += 3) {
55
- tmp = ((uint8[i] << 16) & 0xff0000) + ((uint8[i + 1] << 8) & 0xff00) + (uint8[i + 2] & 0xff);
56
- output.push(tripletToBase64(tmp));
57
- }
58
- return output.join('');
59
- }
60
- }
61
-
62
- var arrayBufferToBase64_1 = arrayBufferToBase64;
63
-
64
- function extractLinks(doc = document) {
65
- const srcsetUrls = [...doc.querySelectorAll('img[srcset],source[srcset]')]
66
- .map(srcsetEl =>
67
- srcsetEl
68
- .getAttribute('srcset')
69
- .split(',')
70
- .map(str => str.trim().split(/\s+/)[0]),
71
- )
72
- .reduce((acc, urls) => acc.concat(urls), []);
73
-
74
- const srcUrls = [...doc.querySelectorAll('img[src],source[src]')].map(srcEl =>
75
- srcEl.getAttribute('src'),
76
- );
77
-
78
- const cssUrls = [...doc.querySelectorAll('link[rel="stylesheet"]')].map(link =>
79
- link.getAttribute('href'),
80
- );
81
-
82
- const videoPosterUrls = [...doc.querySelectorAll('video[poster]')].map(videoEl =>
83
- videoEl.getAttribute('poster'),
84
- );
85
-
86
- return [...srcsetUrls, ...srcUrls, ...cssUrls, ...videoPosterUrls];
87
- }
88
-
89
- var extractLinks_1 = extractLinks;
90
-
91
- /* eslint-disable no-use-before-define */
92
-
93
- function domNodesToCdt(docNode) {
94
- const NODE_TYPES = {
95
- ELEMENT: 1,
96
- TEXT: 3,
97
- DOCUMENT: 9,
98
- DOCUMENT_TYPE: 10,
99
- DOCUMENT_FRAGMENT_NODE: 11,
100
- };
101
-
102
- const domNodes = [
103
- {
104
- nodeType: NODE_TYPES.DOCUMENT,
105
- },
106
- ];
107
- domNodes[0].childNodeIndexes = childrenFactory(domNodes, docNode.childNodes);
108
- return domNodes;
109
-
110
- function childrenFactory(domNodes, elementNodes) {
111
- if (!elementNodes || elementNodes.length === 0) return null;
112
-
113
- const childIndexes = [];
114
- elementNodes.forEach(elementNode => {
115
- const index = elementNodeFactory(domNodes, elementNode);
116
- if (index !== null) {
117
- childIndexes.push(index);
118
- }
119
- });
120
-
121
- return childIndexes;
122
- }
123
-
124
- function elementNodeFactory(domNodes, elementNode) {
125
- let node;
126
- const {nodeType} = elementNode;
127
- if ([NODE_TYPES.ELEMENT, NODE_TYPES.DOCUMENT_FRAGMENT_NODE].includes(nodeType)) {
128
- if (elementNode.nodeName !== 'SCRIPT') {
129
- if (
130
- elementNode.nodeName === 'STYLE' &&
131
- !elementNode.textContent &&
132
- elementNode.sheet &&
133
- elementNode.sheet.cssRules.length
134
- ) {
135
- elementNode.appendChild(
136
- docNode.createTextNode(
137
- [...elementNode.sheet.cssRules].map(rule => rule.cssText).join(''),
138
- ),
139
- );
140
- }
141
-
142
- node = {
143
- nodeType: nodeType,
144
- nodeName: elementNode.nodeName,
145
- attributes: Object.keys(elementNode.attributes || {}).map(key => {
146
- let value = elementNode.attributes[key].value;
147
- const name = elementNode.attributes[key].localName;
148
-
149
- if (/^blob:/.test(value)) {
150
- value = value.replace(/^blob:/, '');
151
- }
152
-
153
- return {
154
- name,
155
- value,
156
- };
157
- }),
158
- childNodeIndexes: elementNode.childNodes.length
159
- ? childrenFactory(domNodes, elementNode.childNodes)
160
- : [],
161
- };
162
-
163
- if (elementNode.shadowRoot) {
164
- node.shadowRootIndex = elementNodeFactory(domNodes, elementNode.shadowRoot);
165
- }
166
-
167
- if (elementNode.checked && !elementNode.attributes.checked) {
168
- node.attributes.push({name: 'checked', value: 'checked'});
169
- }
170
- if (
171
- elementNode.value !== undefined &&
172
- elementNode.attributes.value === undefined &&
173
- elementNode.tagName === 'INPUT'
174
- ) {
175
- node.attributes.push({name: 'value', value: elementNode.value});
176
- }
177
- }
178
- } else if (nodeType === NODE_TYPES.TEXT) {
179
- node = {
180
- nodeType: NODE_TYPES.TEXT,
181
- nodeValue: elementNode.nodeValue,
182
- };
183
- } else if (nodeType === NODE_TYPES.DOCUMENT_TYPE) {
184
- node = {
185
- nodeType: NODE_TYPES.DOCUMENT_TYPE,
186
- nodeName: elementNode.nodeName,
187
- };
188
- }
189
-
190
- if (node) {
191
- domNodes.push(node);
192
- return domNodes.length - 1;
193
- } else {
194
- // console.log(`Unknown nodeType: ${nodeType}`);
195
- return null;
196
- }
197
- }
198
- }
199
-
200
- var domNodesToCdt_1 = domNodesToCdt;
201
- var NODE_TYPES = {
202
- ELEMENT: 1,
203
- TEXT: 3,
204
- DOCUMENT: 9,
205
- DOCUMENT_TYPE: 10,
206
- };
207
- domNodesToCdt_1.NODE_TYPES = NODE_TYPES;
208
-
209
- function extractFrames(doc = document) {
210
- return [...doc.querySelectorAll('iframe[src]:not([src=""])')]
211
- .map(srcEl => {
212
- try {
213
- const contentDoc = srcEl.contentDocument;
214
- return (
215
- contentDoc &&
216
- /^https?:$/.test(contentDoc.location.protocol) &&
217
- contentDoc.defaultView &&
218
- contentDoc.defaultView.frameElement &&
219
- contentDoc
220
- );
221
- } catch (err) {
222
- //for CORS frames
223
- }
224
- })
225
- .filter(x => !!x);
226
- }
227
-
228
- var extractFrames_1 = extractFrames;
229
-
230
- function uniq(arr) {
231
- const result = [];
232
- new Set(arr).forEach(v => v && result.push(v));
233
- return result;
234
- }
235
-
236
- var uniq_1 = uniq;
237
-
238
- function aggregateResourceUrlsAndBlobs(resourceUrlsAndBlobsArr) {
239
- return resourceUrlsAndBlobsArr.reduce(
240
- ({resourceUrls: allResourceUrls, blobsObj: allBlobsObj}, {resourceUrls, blobsObj}) => ({
241
- resourceUrls: uniq_1(allResourceUrls.concat(resourceUrls)),
242
- blobsObj: Object.assign(allBlobsObj, blobsObj),
243
- }),
244
- {resourceUrls: [], blobsObj: {}},
245
- );
246
- }
247
-
248
- var aggregateResourceUrlsAndBlobs_1 = aggregateResourceUrlsAndBlobs;
249
-
250
- function makeGetResourceUrlsAndBlobs({processResource, aggregateResourceUrlsAndBlobs}) {
251
- return function getResourceUrlsAndBlobs(doc, baseUrl, urls) {
252
- return Promise.all(
253
- urls.map(url => processResource(url, doc, baseUrl, getResourceUrlsAndBlobs.bind(null, doc))),
254
- ).then(resourceUrlsAndBlobsArr => aggregateResourceUrlsAndBlobs(resourceUrlsAndBlobsArr));
255
- };
256
- }
257
-
258
- var getResourceUrlsAndBlobs = makeGetResourceUrlsAndBlobs;
259
-
260
- function filterInlineUrl(absoluteUrl) {
261
- return /^(blob|https?):/.test(absoluteUrl);
262
- }
263
-
264
- var filterInlineUrl_1 = filterInlineUrl;
265
-
266
- function absolutizeUrl(url, absoluteUrl) {
267
- return new URL(url, absoluteUrl).href;
268
- }
269
-
270
- var absolutizeUrl_1 = absolutizeUrl;
271
-
272
- function makeProcessResource({
273
- fetchUrl,
274
- findStyleSheetByUrl,
275
- extractResourcesFromStyleSheet,
276
- isSameOrigin,
277
- cache = {},
278
- }) {
279
- return function processResource(absoluteUrl, doc, baseUrl, getResourceUrlsAndBlobs) {
280
- return cache[absoluteUrl] || (cache[absoluteUrl] = doProcessResource(absoluteUrl));
281
-
282
- function doProcessResource(url) {
283
- return fetchUrl(url)
284
- .catch(e => {
285
- if (probablyCORS(e, url)) {
286
- return {probablyCORS: true, url};
287
- } else {
288
- throw e;
289
- }
290
- })
291
- .then(({url, type, value, probablyCORS}) => {
292
- if (probablyCORS) {
293
- return {resourceUrls: [url]};
294
- }
295
- const result = {blobsObj: {[url]: {type, value}}};
296
- if (/text\/css/.test(type)) {
297
- const styleSheet = findStyleSheetByUrl(url, doc);
298
- if (!styleSheet) {
299
- return result;
300
- }
301
- const resourceUrls = extractResourcesFromStyleSheet(styleSheet, doc.defaultView)
302
- .map(resourceUrl => absolutizeUrl_1(resourceUrl, url.replace(/^blob:/, '')))
303
- .filter(filterInlineUrl_1);
304
- return getResourceUrlsAndBlobs(baseUrl, resourceUrls).then(
305
- ({resourceUrls, blobsObj}) => ({
306
- resourceUrls,
307
- blobsObj: Object.assign(blobsObj, {[url]: {type, value}}),
308
- }),
309
- );
310
- } else {
311
- return result;
312
- }
313
- })
314
- .catch(err => {
315
- console.log('[dom-snapshot] error while fetching', url, err);
316
- return {};
317
- });
318
- }
319
-
320
- function probablyCORS(err, url) {
321
- const msgCORS = err.message && err.message.includes('Failed to fetch');
322
- const nameCORS = err.name && err.name.includes('TypeError');
323
- return msgCORS && nameCORS && !isSameOrigin(url, baseUrl);
324
- }
325
- };
326
- }
327
-
328
- var processResource = makeProcessResource;
329
-
330
- /* global window */
331
-
332
- function fetchUrl(url, fetch = window.fetch) {
333
- return fetch(url, {cache: 'force-cache', credentials: 'same-origin'}).then(resp =>
334
- resp.arrayBuffer().then(buff => ({
335
- url,
336
- type: resp.headers.get('Content-Type'),
337
- value: buff,
338
- })),
339
- );
340
- }
341
-
342
- var fetchUrl_1 = fetchUrl;
343
-
344
- function makeFindStyleSheetByUrl({styleSheetCache}) {
345
- return function findStyleSheetByUrl(url, doc) {
346
- return styleSheetCache[url] || [...doc.styleSheets].find(styleSheet => styleSheet.href === url);
347
- };
348
- }
349
-
350
- var findStyleSheetByUrl = makeFindStyleSheetByUrl;
351
-
352
- function getUrlFromCssText(cssText) {
353
- const re = /url\((?!['"]?:)['"]?([^'")]*)['"]?\)/g;
354
- const ret = [];
355
- let result;
356
- while ((result = re.exec(cssText)) !== null) {
357
- ret.push(result[1]);
358
- }
359
- return ret;
360
- }
361
-
362
- var getUrlFromCssText_1 = getUrlFromCssText;
363
-
364
- // NOTE this code is very similar to the node part of visual-grid-client, but there is a different related to the browser's cssom with import rules
365
- function makeExtractResourcesFromStyleSheet({styleSheetCache}) {
366
- return function extractResourcesFromStyleSheet(styleSheet, win = window) {
367
- return uniq_1(
368
- [...(styleSheet.cssRules || [])].reduce((acc, rule) => {
369
- if (rule instanceof win.CSSImportRule) {
370
- styleSheetCache[rule.styleSheet.href] = rule.styleSheet;
371
- return acc.concat(rule.href);
372
- } else if (rule instanceof win.CSSFontFaceRule) {
373
- return acc.concat(getUrlFromCssText_1(rule.style.getPropertyValue('src')));
374
- } else if (rule instanceof win.CSSSupportsRule || rule instanceof win.CSSMediaRule) {
375
- return acc.concat(extractResourcesFromStyleSheet(rule));
376
- } else if (rule instanceof win.CSSStyleRule) {
377
- for (let i = 0, ii = rule.style.length; i < ii; i++) {
378
- const urls = getUrlFromCssText_1(rule.style.getPropertyValue(rule.style[i]));
379
- urls.length && (acc = acc.concat(urls));
380
- }
381
- }
382
- return acc;
383
- }, []),
384
- );
385
- };
386
- }
387
-
388
- var extractResourcesFromStyleSheet = makeExtractResourcesFromStyleSheet;
389
-
390
- function extractResourceUrlsFromStyleAttrs(cdt) {
391
- return cdt.reduce((acc, node) => {
392
- if (node.nodeType === 1) {
393
- const styleAttr =
394
- node.attributes && node.attributes.find(attr => attr.name.toUpperCase() === 'STYLE');
395
-
396
- if (styleAttr) acc = acc.concat(getUrlFromCssText_1(styleAttr.value));
397
- }
398
- return acc;
399
- }, []);
400
- }
401
-
402
- var extractResourceUrlsFromStyleAttrs_1 = extractResourceUrlsFromStyleAttrs;
403
-
404
- function makeExtractResourceUrlsFromStyleTags(extractResourcesFromStyleSheet) {
405
- return function extractResourceUrlsFromStyleTags(doc) {
406
- return uniq_1(
407
- [...doc.getElementsByTagName('style')].reduce((resourceUrls, styleEl) => {
408
- const styleSheet = [...doc.styleSheets].find(
409
- styleSheet => styleSheet.ownerNode === styleEl,
410
- );
411
- return resourceUrls.concat(extractResourcesFromStyleSheet(styleSheet, doc.defaultView));
412
- }, []),
413
- );
414
- };
415
- }
416
-
417
- var extractResourceUrlsFromStyleTags = makeExtractResourceUrlsFromStyleTags;
418
-
419
- function isSameOrigin(url, baseUrl) {
420
- const blobOrData = /^(blob|data):/;
421
- if (blobOrData.test(url)) return true;
422
- if (blobOrData.test(baseUrl)) return false;
423
-
424
- const {origin} = new URL(url, baseUrl);
425
- const {origin: baseOrigin} = new URL(baseUrl);
426
- return origin === baseOrigin;
427
- }
428
-
429
- var isSameOrigin_1 = isSameOrigin;
430
-
431
- function processPage(doc = document) {
432
- const styleSheetCache = {};
433
- const extractResourcesFromStyleSheet$$1 = extractResourcesFromStyleSheet({styleSheetCache});
434
- const findStyleSheetByUrl$$1 = findStyleSheetByUrl({styleSheetCache});
435
- const processResource$$1 = processResource({
436
- fetchUrl: fetchUrl_1,
437
- findStyleSheetByUrl: findStyleSheetByUrl$$1,
438
- extractResourcesFromStyleSheet: extractResourcesFromStyleSheet$$1,
439
- absolutizeUrl: absolutizeUrl_1,
440
- isSameOrigin: isSameOrigin_1,
441
- });
442
-
443
- const getResourceUrlsAndBlobs$$1 = getResourceUrlsAndBlobs({
444
- processResource: processResource$$1,
445
- aggregateResourceUrlsAndBlobs: aggregateResourceUrlsAndBlobs_1,
446
- });
447
-
448
- const extractResourceUrlsFromStyleTags$$1 = extractResourceUrlsFromStyleTags(
449
- extractResourcesFromStyleSheet$$1,
450
- );
451
-
452
- return doProcessPage(doc);
453
-
454
- function doProcessPage(doc) {
455
- const frameElement = doc.defaultView && doc.defaultView.frameElement;
456
- const url = frameElement ? frameElement.src : doc.location.href;
457
-
458
- const cdt = domNodesToCdt_1(doc);
459
-
460
- const links = uniq_1(
461
- extractLinks_1(doc)
462
- .concat(extractResourceUrlsFromStyleAttrs_1(cdt))
463
- .concat(extractResourceUrlsFromStyleTags$$1(doc)),
464
- )
465
- .map(absolutizeThisUrl)
466
- .filter(filterInlineUrlsIfExisting);
467
-
468
- const resourceUrlsAndBlobsPromise = getResourceUrlsAndBlobs$$1(doc, url, links);
469
-
470
- const frameDocs = extractFrames_1(doc);
471
- const processFramesPromise = frameDocs.map(doProcessPage);
472
-
473
- return Promise.all([resourceUrlsAndBlobsPromise, ...processFramesPromise]).then(
474
- ([{resourceUrls, blobsObj}, ...framesResults]) => ({
475
- cdt,
476
- url,
477
- resourceUrls,
478
- blobs: blobsObjToArray(blobsObj),
479
- frames: framesResults,
480
- srcAttr: frameElement ? frameElement.getAttribute('src') : undefined,
481
- }),
482
- );
483
-
484
- function absolutizeThisUrl(someUrl) {
485
- try {
486
- return absolutizeUrl_1(someUrl, url);
487
- } catch (err) {
488
- // can't do anything with a non-absolute url
489
- }
490
- }
491
- }
492
- }
493
-
494
- function blobsObjToArray(blobsObj) {
495
- return Object.keys(blobsObj).map(blobUrl =>
496
- Object.assign(
497
- {
498
- url: blobUrl.replace(/^blob:/, ''),
499
- },
500
- blobsObj[blobUrl],
501
- ),
502
- );
503
- }
504
-
505
- function filterInlineUrlsIfExisting(absoluteUrl) {
506
- return absoluteUrl && filterInlineUrl_1(absoluteUrl);
507
- }
508
-
509
- var processPage_1 = processPage;
510
-
511
- function processPageAndSerialize(doc) {
512
- return processPage_1(doc).then(serializeFrame);
513
- }
514
-
515
- function serializeFrame(frame) {
516
- frame.blobs = frame.blobs.map(({url, type, value}) => ({
517
- url,
518
- type,
519
- value: arrayBufferToBase64_1(value),
520
- }));
521
- frame.frames.forEach(serializeFrame);
522
- return frame;
523
- }
524
-
525
- var processPageAndSerialize_1 = processPageAndSerialize;
526
-
527
- return processPageAndSerialize_1;
528
-
529
- }());
530
-
531
- return processPageAndSerialize.apply(this, arguments);
532
- }
533
- END
534
- end
535
- end
536
- end