| <!DOCTYPE html> |
| <title>Service Worker: FetchEvent for HTMLImports</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/common/get-host-info.sub.js"></script> |
| <script src="resources/test-helpers.sub.js"></script> |
| <script> |
| promise_test(function(t) { |
| var SCOPE = 'resources/fetch-request-html-imports-iframe.html'; |
| var SCRIPT = 'resources/fetch-request-html-imports-worker.js'; |
| var host_info = get_host_info(); |
| return service_worker_unregister_and_register(t, SCRIPT, SCOPE) |
| .then(function(registration) { |
| t.add_cleanup(function() { |
| return service_worker_unregister(t, SCOPE); |
| }); |
| |
| return wait_for_state(t, registration.installing, 'activated'); |
| }) |
| .then(function() { return with_iframe(SCOPE); }) |
| .then(function(frame) { |
| t.add_cleanup(function() { |
| frame.remove(); |
| }); |
| var same = frame.contentWindow.document.getElementById("same").import; |
| var same_same = same.getElementById("same-same").import; |
| var same_other = same.getElementById("same-other").import; |
| var other = |
| frame.contentWindow.document.getElementById("other").import; |
| var other_same = other.getElementById("other-same").import; |
| var other_other = other.getElementById("other-other").import; |
| |
| assert_equals( |
| same.body.innerText, |
| 'mode=cors credentials=same-origin', |
| 'The request mode and credentials for same origin HTMLImport ' + |
| 'must be set correctly.'); |
| assert_equals( |
| same_same.body.innerText, |
| 'mode=cors credentials=same-origin', |
| 'The request mode and credentials for same origin HTMLImport ' + |
| 'from same origin HTMLImports must be set correctly.'); |
| assert_equals( |
| same_other.body.innerText, |
| 'mode=cors credentials=same-origin', |
| 'The request mode and credentials for other origin HTMLImport ' + |
| 'from same origin HTMLImports must be set correctly.'); |
| assert_equals( |
| other.body.innerText, |
| 'mode=cors credentials=same-origin', |
| 'The request mode and credentials for other origin HTMLImport ' + |
| 'must be set correctly.'); |
| assert_equals( |
| other_same.body.innerText, |
| 'mode=cors credentials=same-origin', |
| 'The request mode and credentials for same origin HTMLImport ' + |
| 'from other origin HTMLImports must be set correctly.'); |
| assert_equals( |
| other_other.body.innerText, |
| 'mode=cors credentials=same-origin', |
| 'The request mode and credentials for other origin HTMLImport ' + |
| 'from other origin HTMLImport must be set correctly.'); |
| }); |
| }, 'Verify the FetchEvent for HTMLImports'); |
| </script> |