OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Service Worker: CSS's base URL must be the request URL even when fetched
from other URL</title> |
| 3 <script src="/resources/testharness.js"></script> |
| 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <script src="resources/get-host-info.sub.js"></script> |
| 6 <script src="resources/test-helpers.sub.js?pipe=sub"></script> |
| 7 <script> |
| 8 async_test(function(t) { |
| 9 var SCOPE = 'resources/fetch-request-css-base-url-iframe.html'; |
| 10 var SCRIPT = 'resources/fetch-request-css-base-url-worker.js'; |
| 11 var worker; |
| 12 var testDonePromise; |
| 13 |
| 14 return service_worker_unregister_and_register(t, SCRIPT, SCOPE) |
| 15 .then(function(registration) { |
| 16 worker = registration.installing; |
| 17 return wait_for_state(t, worker, 'activated'); |
| 18 }) |
| 19 .then(function() { |
| 20 return new Promise(function(resolve) { |
| 21 var channel = new MessageChannel(); |
| 22 testDonePromise = new Promise(function(resolveTestDone) { |
| 23 channel.port1.onmessage = t.step_func(function(msg) { |
| 24 if (msg.data.ready) { |
| 25 resolve(); |
| 26 return; |
| 27 } |
| 28 var result = msg.data; |
| 29 var base = get_host_info()['HTTPS_ORIGIN'] + base_path(); |
| 30 assert_equals( |
| 31 result.url, |
| 32 base + 'resources/dummy.png', |
| 33 'The base URL while loading the images referred from CSS ' + |
| 34 'must be the request URL of CSS.'); |
| 35 assert_equals( |
| 36 result.referrer, |
| 37 base + 'resources/fetch-request-css-base-url-style.css', |
| 38 'While loading the image defined in CSS the referrer must '
+ |
| 39 'be the request URL of CSS.'); |
| 40 resolveTestDone(); |
| 41 }); |
| 42 }); |
| 43 worker.postMessage( |
| 44 {port: channel.port2}, [channel.port2]); |
| 45 }); |
| 46 }) |
| 47 .then(function() { return with_iframe(SCOPE); }) |
| 48 .then(function(f) { |
| 49 return testDonePromise.then(function() { |
| 50 f.remove(); |
| 51 return service_worker_unregister_and_done(t, SCOPE); |
| 52 }); |
| 53 }) |
| 54 .catch(unreached_rejection(t)); |
| 55 }, 'CSS\'s base URL must be the request URL even when fetched from other URL.'
); |
| 56 </script> |
OLD | NEW |