(opts: {
name: string;
matchHost: string;
requireUrls?: string[];
resourceUrl?: string;
port: number;
})
| 72 | } |
| 73 | |
| 74 | function selfTestScript(opts: { |
| 75 | name: string; |
| 76 | matchHost: string; |
| 77 | requireUrls?: string[]; |
| 78 | resourceUrl?: string; |
| 79 | port: number; |
| 80 | }): string { |
| 81 | const requires = (opts.requireUrls || []).map((u) => `// @require ${u}`).join("\n"); |
| 82 | const resourceLine = opts.resourceUrl ? `// @resource cfg ${opts.resourceUrl}` : ""; |
| 83 | const grants = opts.resourceUrl ? "// @grant GM_getResourceText" : "// @grant none"; |
| 84 | return `// ==UserScript== |
| 85 | // @name ${opts.name} |
| 86 | // @namespace https://e2e.test |
| 87 | // @version 1.0.0 |
| 88 | // @description resource e2e |
| 89 | // @match http://${opts.matchHost}:${opts.port}/* |
| 90 | ${requires} |
| 91 | ${resourceLine} |
| 92 | ${grants} |
| 93 | // @noframes |
| 94 | // ==/UserScript== |
| 95 | |
| 96 | (function () { |
| 97 | var out = { |
| 98 | libVersion: (typeof window.__LIB_VERSION__ !== "undefined") ? window.__LIB_VERSION__ : null, |
| 99 | lib2: (typeof window.__LIB2_OK__ !== "undefined") ? window.__LIB2_OK__ : null, |
| 100 | bodyRan: true, |
| 101 | }; |
| 102 | ${opts.resourceUrl ? 'try { out.res = GM_getResourceText("cfg"); } catch (e) { out.resErr = String(e); }' : ""} |
| 103 | console.log("${SENTINEL}" + JSON.stringify(out)); |
| 104 | })(); |
| 105 | `; |
| 106 | } |
| 107 | |
| 108 | test.describe("Resource update & concurrency (#1193)", () => { |
| 109 | let server: MockServer; |
no outgoing calls
no test coverage detected