Import fetch/api/cors tests
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / fetch / api / cors / cors-preflight-not-cors-safelisted.any.js
1 // META: script=/common/utils.js
2 // META: script=../resources/utils.js
3 // META: script=/common/get-host-info.sub.js
4 // META: script=resources/corspreflight.js
5
6 const corsURL = get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "preflight.py";
7
8 promise_test(() => fetch("resources/not-cors-safelisted.json").then(res => res.json().then(runTests)), "Loading data‚Ķ");
9
10 function runTests(testArray) {
11   testArray.forEach(testItem => {
12     const [headerName, headerValue] = testItem;
13     corsPreflight("Need CORS-preflight for " + headerName + "/" + headerValue + " header",
14                   corsURL,
15                   "GET",
16                   true,
17                   [[headerName, headerValue]]);
18   });
19 }