| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <body> |
| 5 <script> |
| 6 "use strict"; |
| 7 const CHILD_URL = "./resources/reference-css-no-cache.xhtml"; |
| 8 const EXPECTED_STYLE = "rgb(255, 0, 0) rgb(0, 128, 0)"; |
| 9 |
| 10 const queuedMessages = []; |
| 11 const callbacksAwaitingMessages = []; |
| 12 window.addEventListener("message", function(ev) { |
| 13 if (callbacksAwaitingMessages.length > 0) { |
| 14 const nextCallback = callbacksAwaitingMessages.shift(); |
| 15 nextCallback(ev.data); |
| 16 } else { |
| 17 queuedMessages.push(ev.data); |
| 18 } |
| 19 }); |
| 20 function dequeueMessage() { |
| 21 return new Promise((resolve, reject) => { |
| 22 if (queuedMessages.length === 0) { |
| 23 callbacksAwaitingMessages.push(resolve); |
| 24 } else { |
| 25 resolve(queuedMessages.shift()); |
| 26 } |
| 27 }); |
| 28 } |
| 29 |
| 30 function createFrame(name) { |
| 31 return new Promise((resolve, reject) => { |
| 32 const iframe = document.createElement("iframe"); |
| 33 iframe.name = name; |
| 34 iframe.addEventListener("load", () => resolve(iframe), {once: true}); |
| 35 iframe.src = CHILD_URL; |
| 36 window.document.documentElement.appendChild(iframe); |
| 37 }); |
| 38 } |
| 39 |
| 40 function reloadFrame(frame) { |
| 41 return new Promise(resolve => { |
| 42 frame.addEventListener("load", () => resolve(frame), {once: true}); |
| 43 frame.src = frame.src; |
| 44 }); |
| 45 } |
| 46 |
| 47 promise_test(() => { |
| 48 var frameA, frameB; |
| 49 return Promise.resolve() |
| 50 .then(() => createFrame("A")).then(result => { |
| 51 frameA = result; |
| 52 frameA.contentWindow.postMessage("query applied style", "*"); |
| 53 }) |
| 54 .then(dequeueMessage).then(styleInfoA => { |
| 55 assert_equals(styleInfoA, "A " + EXPECTED_STYLE, "frame A should have the
style applied"); |
| 56 }) |
| 57 .then(() => createFrame("B")).then(result => { |
| 58 frameB = result; |
| 59 frameB.contentWindow.postMessage("query applied style", "*"); |
| 60 }) |
| 61 .then(dequeueMessage).then(styleInfoB => { |
| 62 assert_equals(styleInfoB, "B " + EXPECTED_STYLE, "frame B should have the
style applied"); |
| 63 }) |
| 64 .then(() => reloadFrame(frameA)) |
| 65 .then(() => frameA.contentWindow.postMessage("query applied style", "*")) |
| 66 .then(dequeueMessage).then(styleInfoA => { |
| 67 assert_equals(styleInfoA, "A " + EXPECTED_STYLE, "frame A should have the
style applied"); |
| 68 }) |
| 69 .then(() => frameB.contentWindow.postMessage("query applied style", "*")) |
| 70 .then(dequeueMessage).then(styleInfoB => { |
| 71 assert_equals(styleInfoB, "B " + EXPECTED_STYLE, "frame B should have the
style applied"); |
| 72 }) |
| 73 .then(() => reloadFrame(frameB)) |
| 74 .then(() => frameA.contentWindow.postMessage("query applied style", "*")) |
| 75 .then(dequeueMessage).then(styleInfoA => { |
| 76 assert_equals(styleInfoA, "A " + EXPECTED_STYLE, "frame A should have the
style applied"); |
| 77 }) |
| 78 .then(() => frameB.contentWindow.postMessage("query applied style", "*")) |
| 79 .then(dequeueMessage).then(styleInfoB => { |
| 80 assert_equals(styleInfoB, "B " + EXPECTED_STYLE, "frame B should have the
style applied"); |
| 81 }); |
| 82 }, 'Revalidated CSS should not be unapplied on existing clients.'); |
| 83 </script> |
| OLD | NEW |