| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="/js-test-resources/js-test.js"></script> |
| <script> |
| |
| document.cookie = "ModuleSecret=42" |
| window.jsTestIsAsync = true; |
| |
| function pass(url, messagePrefix) |
| { |
| testPassed(`${messagePrefix} with origin ${url}.`); |
| debug(""); |
| runNextScriptTest(); |
| } |
| |
| function fail(url, messagePrefix) |
| { |
| testFailed(`${messagePrefix} with origin ${url}.`); |
| debug(""); |
| runNextScriptTest(); |
| } |
| |
| function done() |
| { |
| finishJSTest(); |
| } |
| |
| let counter = 0; |
| function runNextScriptTest() |
| { |
| var test = scriptTests.shift(); |
| if (!test) { |
| done(); |
| return; |
| } |
| var script = document.createElement("script"); |
| script.type = "module"; |
| if (test.crossOrigin != null) |
| script.crossOrigin = test.crossOrigin; |
| var url = test.src + "?source=module-propagate&testId=" + (counter++); |
| script.onload = () => test.onload(url); |
| script.onerror = () => test.onerror(url); |
| script.src = "./resources/module-nest-import.py?url=" + encodeURIComponent(url); |
| document.getElementById("test-container").appendChild(script); |
| } |
| |
| window.onload = runNextScriptTest; |
| |
| // Tests |
| |
| const DidLoadScript = "did load script"; |
| const DidNotLoadScript = "did not load script"; |
| |
| var scriptTests = [ |
| { |
| src: "./cookie-protected-script.py", |
| onload: (url) => pass(url, DidLoadScript), |
| onerror: (url) => fail(url, DidNotLoadScript), |
| }, |
| { |
| src: "http://127.0.0.1:8000/security/resources/cookie-protected-script.py", |
| onload: (url) => pass(url, DidLoadScript), |
| onerror: (url) => fail(url, DidNotLoadScript), |
| }, |
| { |
| src: "https://127.0.0.1:8443/security/resources/cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| }, |
| { |
| src: "http://localhost:8000/security/resources/cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| }, |
| { |
| src: "./cookie-protected-script.py", |
| onload: (url) => pass(url, DidLoadScript), |
| onerror: (url) => fail(url, DidNotLoadScript), |
| crossOrigin: "", |
| }, |
| { |
| src: "http://127.0.0.1:8000/security/resources/cookie-protected-script.py", |
| onload: (url) => pass(url, DidLoadScript), |
| onerror: (url) => fail(url, DidNotLoadScript), |
| crossOrigin: "", |
| }, |
| { |
| src: "https://127.0.0.1:8443/security/resources/cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| crossOrigin: "", |
| }, |
| { |
| src: "http://localhost:8000/security/resources/cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| crossOrigin: "", |
| }, |
| { |
| src: "./cookie-protected-script.py", |
| onload: (url) => pass(url, DidLoadScript), |
| onerror: (url) => fail(url, DidNotLoadScript), |
| crossOrigin: "anonymous", |
| }, |
| { |
| src: "http://127.0.0.1:8000/security/resources/cookie-protected-script.py", |
| onload: (url) => pass(url, DidLoadScript), |
| onerror: (url) => fail(url, DidNotLoadScript), |
| crossOrigin: "anonymous", |
| }, |
| { |
| src: "https://127.0.0.1:8443/security/resources/cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| crossOrigin: "anonymous", |
| }, |
| { |
| src: "http://localhost:8000/security/resources/cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| crossOrigin: "anonymous", |
| }, |
| { |
| src: "./cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| crossOrigin: "omit", |
| }, |
| { |
| src: "http://127.0.0.1:8000/security/resources/cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| crossOrigin: "omit", |
| }, |
| { |
| src: "https://127.0.0.1:8443/security/resources/cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| crossOrigin: "omit", |
| }, |
| { |
| src: "http://localhost:8000/security/resources/cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| crossOrigin: "omit", |
| }, |
| { |
| src: "./cookie-protected-script.py", |
| onload: (url) => pass(url, DidLoadScript), |
| onerror: (url) => fail(url, DidNotLoadScript), |
| crossOrigin: "use-credentials", |
| }, |
| { |
| src: "http://127.0.0.1:8000/security/resources/cookie-protected-script.py", |
| onload: (url) => pass(url, DidLoadScript), |
| onerror: (url) => fail(url, DidNotLoadScript), |
| crossOrigin: "use-credentials", |
| }, |
| { |
| src: "https://127.0.0.1:8443/security/resources/cookie-protected-script.py", |
| onload: (url) => pass(url, DidLoadScript), |
| onerror: (url) => fail(url, DidNotLoadScript), |
| crossOrigin: "use-credentials", |
| }, |
| { |
| src: "http://localhost:8000/security/resources/cookie-protected-script.py", |
| onload: (url) => fail(url, DidLoadScript), |
| onerror: (url) => pass(url, DidNotLoadScript), |
| crossOrigin: "use-credentials", |
| }, |
| ]; |
| </script> |
| </head> |
| <body> |
| <div id="test-container"></div> |
| </body> |
| </html> |