OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Service Worker: Mime type checking of CSS files fetched via SW.</title> |
| 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="../resources/get-host-info.js?pipe=sub"></script> |
| 6 <script src="resources/test-helpers.js"></script> |
| 7 <script> |
| 8 |
| 9 function getElementColorInFrame(frame, id) { |
| 10 var element = frame.contentDocument.getElementById(id); |
| 11 var style = frame.contentWindow.getComputedStyle(element, ''); |
| 12 return style['color']; |
| 13 } |
| 14 |
| 15 promise_test(function(t) { |
| 16 var SCOPE = |
| 17 'resources/fetch-request-css-cross-origin-mime-check-iframe.html'; |
| 18 var SCRIPT = |
| 19 'resources/fetch-request-css-cross-origin-mime-check-worker.js'; |
| 20 var EXPECTED_COLOR = 'rgb(0, 0, 255)'; |
| 21 |
| 22 return service_worker_unregister_and_register(t, SCRIPT, SCOPE) |
| 23 .then(r => wait_for_state(t, r.installing, 'activated')) |
| 24 .then(_ => with_iframe(SCOPE) ) |
| 25 .then(f => { |
| 26 assert_equals( |
| 27 getElementColorInFrame(f, 'crossOriginCss'), |
| 28 EXPECTED_COLOR, |
| 29 'The color must be overridden by cross origin CSS.'); |
| 30 assert_equals( |
| 31 getElementColorInFrame(f, 'crossOriginHtml'), |
| 32 EXPECTED_COLOR, |
| 33 'The color must not be overridden by cross origin non CSS file.'); |
| 34 assert_equals( |
| 35 getElementColorInFrame(f, 'sameOriginCss'), |
| 36 EXPECTED_COLOR, |
| 37 'The color must be overridden by same origin CSS.'); |
| 38 assert_equals( |
| 39 getElementColorInFrame(f, 'sameOriginHtml'), |
| 40 EXPECTED_COLOR, |
| 41 'The color must be overridden by same origin non CSS file.'); |
| 42 assert_equals( |
| 43 getElementColorInFrame(f, 'synthetic'), |
| 44 EXPECTED_COLOR, |
| 45 'The color must be overridden by synthetic CSS.'); |
| 46 f.remove(); |
| 47 return service_worker_unregister_and_done(t, SCOPE); |
| 48 }); |
| 49 }, 'Mime type checking of CSS files fetched via SW.'); |
| 50 </script> |
OLD | NEW |