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