| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Service Worker: fetch()</title> | 2 <title>Service Worker: fetch()</title> |
| 3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="resources/test-helpers.js"></script> | 5 <script src="resources/test-helpers.js"></script> |
| 6 <body> | 6 <body> |
| 7 <script> | 7 <script> |
| 8 var SCOPE = 'resources/fetch-access-control-iframe.html'; | 8 var SCOPE = 'resources/fetch-access-control-iframe.html'; |
| 9 var BASE_URL = 'http://127.0.0.1:8000/serviceworker/resources/fetch-access-contr
ol.php?'; | 9 var BASE_URL = 'http://127.0.0.1:8000/serviceworker/resources/fetch-access-contr
ol.php?'; |
| 10 var OTHER_BASE_URL = 'http://localhost:8000/serviceworker/resources/fetch-access
-control.php?'; | 10 var OTHER_BASE_URL = 'http://localhost:8000/serviceworker/resources/fetch-access
-control.php?'; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 var checkJsonpAuth = function (username, password, url, data) { | 91 var checkJsonpAuth = function (username, password, url, data) { |
| 92 assert_equals(data.jsonpResult, | 92 assert_equals(data.jsonpResult, |
| 93 'success', | 93 'success', |
| 94 url + ' jsonpResult must be success'); | 94 url + ' jsonpResult must be success'); |
| 95 assert_equals(data.username, | 95 assert_equals(data.username, |
| 96 username, | 96 username, |
| 97 'Username must match. url: ' + url); | 97 'Username must match. url: ' + url); |
| 98 assert_equals(data.password, | 98 assert_equals(data.password, |
| 99 password, | 99 password, |
| 100 'Password must match. url: ' + url); | 100 'Password must match. url: ' + url); |
| 101 assert_equals(data.cookie, |
| 102 username, |
| 103 'Cookie must match. url: ' + url); |
| 101 }; | 104 }; |
| 102 var checkJsonpError = checkJsonpResult.bind(this, 'error'); | 105 var checkJsonpError = checkJsonpResult.bind(this, 'error'); |
| 103 var checkJsonpSuccess = checkJsonpResult.bind(this, 'success'); | 106 var checkJsonpSuccess = checkJsonpResult.bind(this, 'success'); |
| 104 var hasCustomHeader = | 107 var hasCustomHeader = |
| 105 checkJsonpHeader.bind(this, 'x-serviceworker-test', 'test'); | 108 checkJsonpHeader.bind(this, 'x-serviceworker-test', 'test'); |
| 106 var noCustomHeader = | 109 var noCustomHeader = |
| 107 checkJsonpHeader.bind(this, 'x-serviceworker-test', undefined); | 110 checkJsonpHeader.bind(this, 'x-serviceworker-test', undefined); |
| 108 var methodIsGET = checkJsonpMethod.bind(this, 'GET'); | 111 var methodIsGET = checkJsonpMethod.bind(this, 'GET'); |
| 109 var methodIsPOST = checkJsonpMethod.bind(this, 'POST'); | 112 var methodIsPOST = checkJsonpMethod.bind(this, 'POST'); |
| 110 var methodIsPUT = checkJsonpMethod.bind(this, 'PUT'); | 113 var methodIsPUT = checkJsonpMethod.bind(this, 'PUT'); |
| 111 var methodIsXXX = checkJsonpMethod.bind(this, 'XXX'); | 114 var methodIsXXX = checkJsonpMethod.bind(this, 'XXX'); |
| 115 var authCheckNone = checkJsonpAuth.bind(this, 'undefined', 'undefined'); |
| 112 var authCheck1 = checkJsonpAuth.bind(this, 'username1', 'password1'); | 116 var authCheck1 = checkJsonpAuth.bind(this, 'username1', 'password1'); |
| 113 var authCheck2 = checkJsonpAuth.bind(this, 'username2', 'password2'); | 117 var authCheck2 = checkJsonpAuth.bind(this, 'username2', 'password2'); |
| 114 | 118 |
| 115 var TEST_TARGETS = [ | 119 var TEST_TARGETS = [ |
| 116 [BASE_URL + 'method=GET', | 120 [BASE_URL + 'method=GET', |
| 117 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 121 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 118 [methodIsGET]], | 122 [methodIsGET, authCheckNone]], |
| 119 [BASE_URL + 'method=GET&headers={}', | 123 [BASE_URL + 'method=GET&headers={}', |
| 120 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 124 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 121 [methodIsGET]], | 125 [methodIsGET]], |
| 122 [BASE_URL + 'method=GET&headers=CUSTOM', | 126 [BASE_URL + 'method=GET&headers=CUSTOM', |
| 123 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 127 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 124 [methodIsGET, noCustomHeader]], | 128 [methodIsGET, noCustomHeader]], |
| 125 [BASE_URL + 'method=POST&headers=CUSTOM', | 129 [BASE_URL + 'method=POST&headers=CUSTOM', |
| 126 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 130 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 127 [methodIsPOST, noCustomHeader]], | 131 [methodIsPOST, noCustomHeader]], |
| 128 [BASE_URL + 'method=PUT', | 132 [BASE_URL + 'method=PUT', |
| 129 [fetchError]], | 133 [fetchError]], |
| 130 [BASE_URL + 'method=XXX', | 134 [BASE_URL + 'method=XXX', |
| 131 [fetchError]], | 135 [fetchError]], |
| 132 | 136 |
| 133 [BASE_URL + 'mode=same-origin&method=GET', | 137 [BASE_URL + 'mode=same-origin&method=GET', |
| 134 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 138 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 135 [methodIsGET]], | 139 [methodIsGET, authCheckNone]], |
| 136 [BASE_URL + 'mode=same-origin&method=GET&headers={}', | 140 [BASE_URL + 'mode=same-origin&method=GET&headers={}', |
| 137 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 141 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 138 [methodIsGET]], | 142 [methodIsGET]], |
| 139 [BASE_URL + 'mode=same-origin&method=GET&headers=CUSTOM', | 143 [BASE_URL + 'mode=same-origin&method=GET&headers=CUSTOM', |
| 140 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 144 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 141 [methodIsGET, hasCustomHeader]], | 145 [methodIsGET, hasCustomHeader]], |
| 142 [BASE_URL + 'mode=same-origin&method=POST&headers=CUSTOM', | 146 [BASE_URL + 'mode=same-origin&method=POST&headers=CUSTOM', |
| 143 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 147 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 144 [methodIsPOST, hasCustomHeader]], | 148 [methodIsPOST, hasCustomHeader]], |
| 145 [BASE_URL + 'mode=same-origin&method=PUT&headers=CUSTOM', | 149 [BASE_URL + 'mode=same-origin&method=PUT&headers=CUSTOM', |
| 146 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 150 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 147 [methodIsPUT, hasCustomHeader]], | 151 [methodIsPUT, hasCustomHeader]], |
| 148 [BASE_URL + 'mode=same-origin&method=XXX&headers=CUSTOM', | 152 [BASE_URL + 'mode=same-origin&method=XXX&headers=CUSTOM', |
| 149 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 153 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 150 [methodIsXXX, hasCustomHeader]], | 154 [methodIsXXX, hasCustomHeader]], |
| 151 | 155 |
| 152 [BASE_URL + 'mode=no-cors&method=GET', | 156 [BASE_URL + 'mode=no-cors&method=GET', |
| 153 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 157 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 154 [methodIsGET]], | 158 [methodIsGET, authCheckNone]], |
| 155 [BASE_URL + 'mode=no-cors&method=GET&headers={}', | 159 [BASE_URL + 'mode=no-cors&method=GET&headers={}', |
| 156 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 160 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 157 [methodIsGET]], | 161 [methodIsGET]], |
| 158 [BASE_URL + 'mode=no-cors&method=GET&headers=CUSTOM', | 162 [BASE_URL + 'mode=no-cors&method=GET&headers=CUSTOM', |
| 159 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 163 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 160 [methodIsGET, noCustomHeader]], | 164 [methodIsGET, noCustomHeader]], |
| 161 [BASE_URL + 'mode=no-cors&method=POST&headers=CUSTOM', | 165 [BASE_URL + 'mode=no-cors&method=POST&headers=CUSTOM', |
| 162 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 166 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 163 [methodIsPOST, noCustomHeader]], | 167 [methodIsPOST, noCustomHeader]], |
| 164 [BASE_URL + 'mode=no-cors&method=PUT', | 168 [BASE_URL + 'mode=no-cors&method=PUT', |
| 165 [fetchError]], | 169 [fetchError]], |
| 166 [BASE_URL + 'mode=no-cors&method=XXX', | 170 [BASE_URL + 'mode=no-cors&method=XXX', |
| 167 [fetchError]], | 171 [fetchError]], |
| 168 | 172 |
| 169 [BASE_URL + 'mode=cors&method=GET', | 173 [BASE_URL + 'mode=cors&method=GET', |
| 170 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 174 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 171 [methodIsGET]], | 175 [methodIsGET, authCheckNone]], |
| 172 [BASE_URL + 'mode=cors&method=GET&headers={}', | 176 [BASE_URL + 'mode=cors&method=GET&headers={}', |
| 173 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 177 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 174 [methodIsGET]], | 178 [methodIsGET]], |
| 175 [BASE_URL + 'mode=cors&method=GET&headers=CUSTOM', | 179 [BASE_URL + 'mode=cors&method=GET&headers=CUSTOM', |
| 176 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 180 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 177 [methodIsGET, hasCustomHeader]], | 181 [methodIsGET, hasCustomHeader]], |
| 178 [BASE_URL + 'mode=cors&method=POST&headers=CUSTOM', | 182 [BASE_URL + 'mode=cors&method=POST&headers=CUSTOM', |
| 179 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 183 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 180 [methodIsPOST, hasCustomHeader]], | 184 [methodIsPOST, hasCustomHeader]], |
| 181 [BASE_URL + 'mode=cors&method=PUT&headers=CUSTOM', | 185 [BASE_URL + 'mode=cors&method=PUT&headers=CUSTOM', |
| 182 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 186 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 183 [methodIsPUT, hasCustomHeader]], | 187 [methodIsPUT, hasCustomHeader]], |
| 184 [BASE_URL + 'mode=cors&method=XXX&headers=CUSTOM', | 188 [BASE_URL + 'mode=cors&method=XXX&headers=CUSTOM', |
| 185 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 189 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
| 186 [methodIsXXX, hasCustomHeader]], | 190 [methodIsXXX, hasCustomHeader]], |
| 187 | 191 |
| 188 // CORS test | 192 // CORS test |
| 189 [OTHER_BASE_URL + 'method=GET&headers=CUSTOM', | 193 [OTHER_BASE_URL + 'method=GET&headers=CUSTOM', |
| 190 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque], | 194 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque], |
| 191 [methodIsGET, noCustomHeader]], | 195 [methodIsGET, noCustomHeader, authCheckNone]], |
| 192 [OTHER_BASE_URL + 'method=POST&headers=CUSTOM', | 196 [OTHER_BASE_URL + 'method=POST&headers=CUSTOM', |
| 193 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque], | 197 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque], |
| 194 [methodIsPOST, noCustomHeader]], | 198 [methodIsPOST, noCustomHeader]], |
| 195 [OTHER_BASE_URL + 'method=PUT&headers=CUSTOM', | 199 [OTHER_BASE_URL + 'method=PUT&headers=CUSTOM', |
| 196 [fetchError]], | 200 [fetchError]], |
| 197 [OTHER_BASE_URL + 'method=XXX&headers=CUSTOM', | 201 [OTHER_BASE_URL + 'method=XXX&headers=CUSTOM', |
| 198 [fetchError]], | 202 [fetchError]], |
| 199 | 203 |
| 200 [OTHER_BASE_URL + 'mode=same-origin&method=GET', [fetchRejected]], | 204 [OTHER_BASE_URL + 'mode=same-origin&method=GET', [fetchRejected]], |
| 201 [OTHER_BASE_URL + 'mode=same-origin&method=POST', [fetchRejected]], | 205 [OTHER_BASE_URL + 'mode=same-origin&method=POST', [fetchRejected]], |
| 202 [OTHER_BASE_URL + 'mode=same-origin&method=PUT', [fetchRejected]], | 206 [OTHER_BASE_URL + 'mode=same-origin&method=PUT', [fetchRejected]], |
| 203 [OTHER_BASE_URL + 'mode=same-origin&method=XXX', [fetchRejected]], | 207 [OTHER_BASE_URL + 'mode=same-origin&method=XXX', [fetchRejected]], |
| 204 | 208 |
| 205 [OTHER_BASE_URL + 'mode=no-cors&method=GET&headers=CUSTOM', | 209 [OTHER_BASE_URL + 'mode=no-cors&method=GET&headers=CUSTOM', |
| 206 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque], | 210 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque], |
| 207 [methodIsGET, noCustomHeader]], | 211 [methodIsGET, noCustomHeader, authCheckNone]], |
| 208 [OTHER_BASE_URL + 'mode=no-cors&method=POST&headers=CUSTOM', | 212 [OTHER_BASE_URL + 'mode=no-cors&method=POST&headers=CUSTOM', |
| 209 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque], | 213 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque], |
| 210 [methodIsPOST, noCustomHeader]], | 214 [methodIsPOST, noCustomHeader]], |
| 211 [OTHER_BASE_URL + 'mode=no-cors&method=PUT&headers=CUSTOM', | 215 [OTHER_BASE_URL + 'mode=no-cors&method=PUT&headers=CUSTOM', |
| 212 [fetchError]], | 216 [fetchError]], |
| 213 [OTHER_BASE_URL + 'mode=no-cors&method=XXX&headers=CUSTOM', | 217 [OTHER_BASE_URL + 'mode=no-cors&method=XXX&headers=CUSTOM', |
| 214 [fetchError]], | 218 [fetchError]], |
| 215 | 219 |
| 216 [OTHER_BASE_URL + 'mode=cors&method=GET', | 220 [OTHER_BASE_URL + 'mode=cors&method=GET', |
| 217 [fetchRejected]], | 221 [fetchRejected]], |
| 218 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*', | 222 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*', |
| 219 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | 223 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], |
| 220 [methodIsGET]], | 224 [methodIsGET, authCheckNone]], |
| 221 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://127.0.0.1:8000', | 225 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://127.0.0.1:8000', |
| 222 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | 226 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], |
| 223 [methodIsGET]], | 227 [methodIsGET]], |
| 224 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://127.0.0.1:8000,http:/
/www.example.com', | 228 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://127.0.0.1:8000,http:/
/www.example.com', |
| 225 [fetchRejected]], | 229 [fetchRejected]], |
| 226 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://www.example.com', | 230 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://www.example.com', |
| 227 [fetchRejected]], | 231 [fetchRejected]], |
| 228 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*&ACEHeaders=X-ServiceWorker
-ServerHeader', | 232 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*&ACEHeaders=X-ServiceWorker
-ServerHeader', |
| 229 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors], | 233 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors], |
| 230 [methodIsGET]], | 234 [methodIsGET]], |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 })) | 589 })) |
| 586 .then(test.step_func(function() { | 590 .then(test.step_func(function() { |
| 587 frameWindow.postMessage( | 591 frameWindow.postMessage( |
| 588 {url: TEST_TARGETS[counter][0]}, | 592 {url: TEST_TARGETS[counter][0]}, |
| 589 IFRAME_ORIGIN); | 593 IFRAME_ORIGIN); |
| 590 })); | 594 })); |
| 591 } | 595 } |
| 592 }); | 596 }); |
| 593 </script> | 597 </script> |
| 594 </body> | 598 </body> |
| OLD | NEW |