Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / serviceworker / chromium / resources / respond-with-body-accessed-response-iframe.html
blobd4f955635be9c95f200ca1273cc338e6d0574a8f
1 <script src="../../../../resources/testharness.js"></script>
2 <script>
3 var callback;
5 function getJSONP(url) {
6 var sc = document.createElement('script');
7 sc.src = url;
8 var promise = new Promise(function(resolve, reject) {
9 // This callback function is called by appending a script element.
10 callback = resolve;
11 sc.addEventListener(
12 'error',
13 function() { reject('Failed to load url:' + url); });
14 });
15 document.body.appendChild(sc);
16 return promise;
19 var TEST_CASES = [
20 "type=basic",
21 "type=opaque",
22 "type=default",
23 "type=basic&clone=1",
24 "type=opaque&clone=1",
25 "type=default&clone=1",
26 "type=basic&clone=2",
27 "type=opaque&clone=2",
28 "type=default&clone=2",
29 "type=basic&passThroughCache=true",
30 "type=opaque&passThroughCache=true",
31 "type=default&passThroughCache=true",
32 "type=basic&clone=1&passThroughCache=true",
33 "type=opaque&clone=1&passThroughCache=true",
34 "type=default&clone=1&passThroughCache=true",
35 "type=basic&clone=2&passThroughCache=true",
36 "type=opaque&clone=2&passThroughCache=true",
37 "type=default&clone=2&passThroughCache=true",
40 function executeTest(url) {
41 return getJSONP(url)
42 .then(function(result) {
43 assert_equals(result, 'OK', 'The result must be OK url:' + url);
44 });
47 function do_test() {
48 var urls = TEST_CASES.map(function(param) { return 'TestRequest?' + param; });
49 var promise = Promise.resolve();
50 for (var i = 0; i < urls.length; ++i) {
51 promise = promise.then(executeTest.bind(undefined, urls[i]));
53 return promise;
55 </script>