@applitools/dom-capture 11.2.1 → 11.2.2
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.
- package/CHANGELOG.md +5 -0
- package/dist/captureDom.js +3 -3
- package/dist/captureDomForIE.js +3 -3
- package/dist/captureDomPoll.js +3 -3
- package/dist/captureDomPollCjs.js +3 -3
- package/dist/captureDomPollForIE.js +3 -3
- package/dist/pollResult.js +2 -2
- package/dist/pollResultCjs.js +2 -2
- package/dist/pollResultForIE.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/captureDom.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/* @applitools/dom-capture@11.2.
|
|
1
|
+
/* @applitools/dom-capture@11.2.2 */
|
|
2
2
|
function __captureDom() {
|
|
3
|
-
var captureDom=function(){"use strict";var
|
|
3
|
+
var captureDom=function(){"use strict";var t=function(){const t=function(t){return function(){function e(t,e=0){const n=t.charCodeAt(e);return n>=55296&&n<56320?1024*(n-55296)+(t.charCodeAt(e+1)-56320)+65536:56320<=n&&n<=57343?-1:n}var n=function(t,n){const o=[];let r=0;for(let s=0;s<t.length;++s){const a=e(t,s);let c=0;a>0&&(c=a<128?1:a<2048?2:a<65536?3:a<2097152?4:a<67108864?5:6),r+c>n?(o.push(s),r=c):r+=c}return o};const o=n,r="SUCCESS",s="SUCCESS_CHUNKED",a="ERROR";var c=function(t,e,n={}){const c=function(t,{chunkByteLength:e=0}={}){if(t){if(t.value){if(e){if(!t.chunks){const n=JSON.stringify(t.value);t.chunks=o(n,e),t.chunks.length>0&&(t.from=0,t.value=n)}if(t.from>=0)return{status:s,value:t.value.substring(t.from,t.from=t.chunks.shift()),done:!t.from}}return{status:r,value:t.value}}return t.error?{status:a,error:t.error}:{status:"WIP"}}return{status:a,error:"unexpected poll request received - cannot find state of current operation"}}((t=t||{})[e],n);return(c.status===r||c.status===a||c.status===s&&c.done)&&(t[e]=null),c};const i=c;var u={chunkify:n,pollify:function(t,e,n){return o=>function(){return e[n]||(e[n]={},t.apply(null,arguments).then((t=>e[n].value=t)).catch((t=>e[n].error=t.message))),i(e,n,o)}},poll:c,absolutizeUrl:function(t,e){return new URL(t,e).href},isInlineFrame:function(t){return t.contentDocument&&t.contentDocument.location&&!/^https?:$/.test(t.contentDocument.location.protocol)},isAccessibleFrame:function(t){try{const e=t.contentDocument;return Boolean(e&&e.defaultView&&e.defaultView.frameElement)}catch(t){return!1}}};const l=/url\((?!['"]?:)['"]?([^'")]*)['"]?\)/;var d={EYES_NAMESPACE:"__EYES__APPLITOOLS__",DOM_CAPTURE_KEY:"domCaptureResult",NODE_TYPES:{ELEMENT:1,TEXT:3,DOCUMENT_FRAGMENT:11},DEFAULT_STYLE_PROPS:["background-repeat","background-origin","background-position","background-color","background-image","background-size","border-width","border-color","border-style","color","display","font-size","font-weight","line-height","margin","opacity","overflow","padding","visibility","text-align","position","border-radius","z-index"],DEFAULT_RECT_PROPS:["width","height","top","left"],DEFAULT_IGNORED_TAG_NAMES:["HEAD","SCRIPT"]};const{NODE_TYPES:f}=d;function m(t){return Array.prototype.filter.call(t.parentNode.childNodes,(e=>e.tagName===t.tagName)).indexOf(t)+1}var h=function(e){var n=t.implementation.createHTMLDocument(""),o=n.createElement("style");return o.textContent=e,n.body.appendChild(o),o.sheet},p=function(t){const e=Array.from(t.attributes).find((t=>"href"===t.name.toLowerCase()));return e&&e.value},g=function(t){if(t.nodeName&&"LINK"===t.nodeName.toUpperCase()&&t.attributes){const e=new Map(Array.from(t.attributes,(t=>[t.name.toLowerCase(),t.value.toLowerCase()])));return"stylesheet"===e.get("rel")||"style"===e.get("as")&&["preload","prefetch"].includes(e.get("rel"))}return!1};const y=p,C=g;const{absolutizeUrl:w,isInlineFrame:E}=u,T=h,N=p,b=g,{NODE_TYPES:S}=d;const{absolutizeUrl:$,isInlineFrame:A}=u,D=function(t){const e=t?t.match(l):void 0;return e?e[1]:e},R=async function({bgImages:t,timeout:e=5e3,Image:n=window.Image}){return(await Promise.all(Array.from(t).map((t=>{return Promise.race([new Promise((e=>{const o=new n;o.onload=()=>e({url:t,width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>e(),o.src=t})),(o=e,new Promise((t=>{setTimeout(t,o)})))]);var o})))).reduce(((t,e)=>(e&&(t[e.url]={width:e.width,height:e.height}),t)),{})},_=function t(e){if(!e.ownerDocument)return"";let n="",o=e,r=e.ownerDocument,s=r.defaultView.frameElement;for(;o!==r&&(!o||o.nodeType!==f.DOCUMENT_FRAGMENT);)n=`${o.tagName}[${m(o)}]/${n}`,o=o.parentNode;return s&&(n=`${t(s)},${n}`),n.replace(/\/$/,"")},P=function({parseCss:t,CSSImportRule:e,absolutizeUrl:n,getCssFromCache:o,unfetchedToken:r}){return function s(a,c){let i,u="";try{const l=t(a);for(const t of Array.from(l.cssRules))if(t instanceof e){const e=n(t.href,c),a=o(e);if(void 0!==a){const{bundledCss:t,unfetchedResources:n}=s(a,e);n&&(i=new Set(n)),u=`${u}${t}`}else i=new Set([e]),u=`\n${r}${e}${r}`}}catch(t){console.log(`error during getBundledCssFromCssText, styleBaseUrl=${c}`,t)}var l,d;return u=`${u}${l=a,d=c,`\n/** ${d} **/\n${l}`}`,{bundledCss:u,unfetchedResources:i}}},U=h,v=function(t){const e=["before","after"];try{let n=[];return e.forEach((e=>{const o=t.ownerDocument.defaultView.getComputedStyle(t,`:${e}`);o&&"none"!==o.getPropertyValue("content")&&n.push(e)})),n.join("_and_")}catch(t){return!1}},F=function(t,{fetchTimeLimit:e}={}){return async function(n){const o=new AbortController,r=[t(n,{cache:"force-cache",signal:o.signal}).then((t=>{if(t.ok)return t.text();console.log("/failed to fetch (status "+t.status+") css from: "+n+"/")})).catch((t=>{console.log("/failed to fetch (error "+t.toString()+") css from: "+n+"/")}))];return Number.isNaN(Number(e))||r.push(new Promise((t=>setTimeout(t,e))).then((()=>o.abort()))),Promise.race(r)}},k=function({getCssFromCache:t,absolutizeUrl:e}){return function(n,o){let r,s,a;if(n&&function(t){return t.nodeName&&"STYLE"===t.nodeName.toUpperCase()}(n))r=Array.from(n.childNodes).map((t=>t.nodeValue)).join(""),s=o;else if(n&&C(n)){const c=y(n);!function(t){return t&&t.startsWith("data:")}(c)?(s=e(c,o),r=t(s)):(s=o,r=c.match(/,(.+)/)[1]),a=void 0===r}return{cssText:r,styleBaseUrl:s,isUnfetched:a}}},O=function({extractCssFromNode:t,getBundledCssFromCssText:e,unfetchedToken:n}){return function(o,r){const{styleBaseUrl:s,cssText:a,isUnfetched:c}=t(o,r);let i,u="";if(a){const{bundledCss:t,unfetchedResources:n}=e(a,s);u+=t,i=new Set(n)}else c&&(u+=`${n}${s}${n}`,i=new Set([s]));return{bundledCss:u,unfetchedResources:i}}},I=function(e){return async function(n=t){const o={},r=Date.now(),s=[];return function t(n,o,r,s){function c(t){if(s.push(async function(t,n,o){let r,s;t&&b(t)&&(s=w(N(t),n),r=await e(s),void 0!==r&&(o[s]=r)),r&&await a(r,s,o)}(t,o,r)),t.nodeType===S.ELEMENT)return"IFRAME"===t.tagName.toUpperCase()?u(t):i(t)}async function i(t){Array.prototype.map.call(t.childNodes,c)}async function u(e){if(i(e),e.contentDocument)try{const n=E(e)?e.baseURI:e.contentDocument.location.href;t(e.contentDocument,n,r,s)}catch(e){console.log(e)}}c(n.documentElement)}(n,n.location.href,o,s),await Promise.all(s),console.log("[prefetchAllCss]",Date.now()-r),function(t){return o[t]};async function a(t,n,o){try{const r=T(t),s=[];for(const t of Array.from(r.cssRules))t instanceof CSSImportRule&&s.push((async()=>{const r=w(t.href,n),s=await e(r);o[r]=s,void 0!==s&&await a(s,r,o)})());await Promise.all(s)}catch(t){console.log(`error during fetchBundledCss, resourceUrl=${n}`,t)}}}},{NODE_TYPES:L,DEFAULT_STYLE_PROPS:x,DEFAULT_RECT_PROPS:M,DEFAULT_IGNORED_TAG_NAMES:V}=d,B="1.3.0";return async function({doc:e=t,styleProps:n=x,rectProps:o=M,ignoredTagNames:r=V,addStats:s=!1,fetchTimeLimit:a=3e4}={}){
|
|
4
4
|
/* MARKER FOR TEST - DO NOT DELETE */
|
|
5
|
-
arguments[1]&&(
|
|
5
|
+
arguments[1]&&(e=arguments[1]),arguments[2]&&(s=arguments[2]),arguments[3]&&(a=arguments[3]);const c={total:{},prefetchCss:{},doCaptureDoc:{},waitForImages:{}};function i(t){t.startTime=Date.now()}function u(t){t.endTime=Date.now(),t.elapsedTime=t.endTime-t.startTime}const l=[];i(c.total);const d=new Set,f=[],m="@@@@@",h="#####",p="-----";i(c.prefetchCss);const g=I(F(fetch,{fetchTimeLimit:a})),y=await g(e);u(c.prefetchCss);const C=P({parseCss:U,CSSImportRule:CSSImportRule,getCssFromCache:y,absolutizeUrl:$,unfetchedToken:h}),w=k({getCssFromCache:y,absolutizeUrl:$}),E=O({extractCssFromNode:w,getBundledCssFromCssText:C,unfetchedToken:h});i(c.doCaptureDoc);const T=j(e);u(c.doCaptureDoc),i(c.waitForImages),await Promise.all(l),u(c.waitForImages),T.version=B,T.scriptVersion="11.2.2";const N=f.length?`${f.join("\n")}\n`:"",b=d.size?`${Array.from(d).join("\n")}\n`:"",S=JSON.stringify({separator:p,cssStartToken:h,cssEndToken:h,iframeStartToken:`"${m}`,iframeEndToken:`${m}"`});function z(){return s?`\n${p}\n${JSON.stringify(c)}`:""}u(c.total);const Y=`${S}\n${b}${p}\n${N}${p}\n${JSON.stringify(T)}${z()}`;return console.log("[captureFrame]",JSON.stringify(c)),Y;function G(t){return Object.keys(t).length?t:void 0}function J(t){return{tagName:"#text",text:t.textContent}}function j(t,s=t.location&&t.location.href){const a=new Set;let c="";const i=u(t.documentElement||t);return i.css=c,l.push(R({bgImages:a}).then((t=>i.images=t))),i;function u(t){if(t.hasAttribute&&t.hasAttribute("data-applitools-skip"))return null;const{bundledCss:e,unfetchedResources:n}=E(t,s);if(c+=e,n)for(const t of n)d.add(t);switch(t.nodeType){case L.TEXT:return J(t);case L.ELEMENT:return"IFRAME"===t.tagName.toUpperCase()?function(t){const e=h(t);let n;try{n=t.contentDocument}catch(t){return o(),e}try{n?e.childNodes=[j(n,A(t)?t.baseURI:n.location.href)]:o()}catch(t){console.log("error in iframeToJSON",t)}return e;function o(){const n=_(t);f.push(n),e.childNodes=[`${m}${n}${m}`]}}(t):h(t);case L.DOCUMENT_FRAGMENT:return{childNodes:Array.prototype.map.call(t.childNodes,u).filter(Boolean)};default:return null}}function h(t){const c=Array.prototype.map.call(t.childNodes,u).filter(Boolean),i=t.shadowRoot&&j(t.shadowRoot,s),l=t.tagName.toUpperCase();if(r.indexOf(l)>-1)return null;const d=e.defaultView.getComputedStyle(t),f=t.getBoundingClientRect(),m={};for(const t of n)m[t]=d.getPropertyValue(t);m["border-width"]||(m["border-width"]=`${d.getPropertyValue("border-top-width")} ${d.getPropertyValue("border-right-width")} ${d.getPropertyValue("border-bottom-width")} ${d.getPropertyValue("border-left-width")}`);const h={};for(const t of o)h[t]=f[t];const p=Array.from(t.attributes).map((t=>({key:t.name,value:t.value}))).reduce(((t,e)=>(t[e.key]=e.value,t)),{}),g=D(d.getPropertyValue("background-image"));g&&a.add(g);const y=v(t);y&&(p["data-applitools-has-pseudo"]=y);const C={tagName:l,style:G(m),rect:G(h),attributes:G(p),childNodes:c};return i&&(C.shadowRoot=i),C}}}}()};let e=!0;try{let n=document.head.querySelector("[data-applitools-sandbox]");n||(n=document.createElement("iframe"),n.setAttribute("data-applitools-sandbox",""),n.setAttribute("data-applitools-skip",""),document.head.appendChild(n));const o=window.crypto.getRandomValues(new Uint32Array(1))[0],r=n.contentDocument.createElement("script");r.textContent=`window['ctor-${o}'] = ${t.toString()};`,n.contentDocument.head.appendChild(r);const s=n.contentWindow[`ctor-${o}`];if("function"!=typeof s)throw new Error("Sandbox failed to extract function");return e=!1,s(document).apply(null,arguments)}catch(n){try{return t(document).apply(null,arguments)}catch(t){throw e?t:n}}};return t}();
|
|
6
6
|
|
|
7
7
|
return captureDom.apply(this, arguments);
|
|
8
8
|
}
|