Skip to content
Snippets Groups Projects
Select Git revision
  • 7efff3740b24450abf6b658ba6fb8aeb0d82b05b
  • master default protected
  • v1.23.2
  • v1.23.1
  • v1.23.0
  • v1.22.0
  • v1.21.1
  • v1.21.0
  • v1.20.3
  • v1.20.2
  • v1.20.1
  • v1.20.0
  • v1.19.4
  • v1.19.3
  • v1.19.2
  • v1.19.1
  • v1.19.0
  • v1.18.2
  • v1.18.1
  • v1.18.0
  • v1.17.0
  • v1.16.1
22 results

job-log.go

Blame
  • jsdom.mjs 3.37 KiB
    'use strict';
    
    import {extend} from "../../source/data/extend.mjs";
    import {getGlobal} from "../../source/types/global.mjs";
    
    export const isBrowser = new Function("try {return this===window;}catch(e){ return false;}");
    export const isNode = new Function("try {return this===global;}catch(e){return false;}");
    
    let JSDOMExport = null;
    
    /**
     * this helper function creates the dom stack in the node environment
     *
     * @return {Promise<unknown>|Promise<void>}
     */
    function initJSDOM(options) {
        if (typeof window === "object" && window['DOMParser']) return Promise.resolve();
    
        const g = getGlobal();
    
        options = extend({}, {
            pretendToBeVisual: true,
            contentType: "text/html",
            includeNodeLocations: true,
            storageQuota: 10000000,
            runScripts: "dangerously",
            resources: "usable"
        }, options || {})
    
        return import("jsdom").then(({JSDOM}) => {
            JSDOMExport = JSDOM;
            const {window} = new JSDOM(`<!DOCTYPE html><html lang="en"><head><title>Test</title></head><body><div id="mocks"></div></body></html>`, options);
    
            g['window'] = window;
            
            return new Promise((resolve, reject) =>
                window.addEventListener("load", () => {
    
                    [
                        'Blob',
                        'CSSStyleSheet',
                        'customElements',
                        'CustomEvent',
                        'document',
                        'Document',
                        'DocumentFragment',
                        'DOMParser',
                        'Element',
                        'ElementInternals',
                        'Event',
                        'EventTarget',
                        'getComputedStyle',
                        'HTMLButtonElement',
                        'HTMLCollection',
                        'HTMLDivElement',
                        'HTMLDocument',
                        'HTMLElement',
                        'HTMLFormElement',
                        'HTMLInputElement',
                        'HTMLScriptElement',
                        'requestAnimationFrame',
                        'HTMLSelectElement',
                        'HTMLTemplateElement',
                        'HTMLTextAreaElement',
                        'InputEvent',
                        'KeyboardEvent',
                        'MutationObserver',
                        'navigator',
                        'Node',
                        'NodeFilter',