Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/loading/css-no-cache-revalidation.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/loading/css-no-cache-revalidation.html b/third_party/WebKit/LayoutTests/http/tests/loading/css-no-cache-revalidation.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8c91064f62481ae1e15617765d6a9560b853f45c |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/loading/css-no-cache-revalidation.html |
| @@ -0,0 +1,83 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<body> |
| +<script> |
| +"use strict"; |
| +const CHILD_URL = "./resources/reference-css-no-cache.xhtml"; |
| +const EXPECTED_STYLE = "rgb(255, 0, 0) rgb(0, 128, 0)"; |
| + |
| +const queuedMessages = []; |
| +const callbacksAwaitingMessages = []; |
| +window.addEventListener("message", function(ev) { |
| + if (callbacksAwaitingMessages.length > 0) { |
| + const nextCallback = callbacksAwaitingMessages.shift(); |
| + nextCallback(ev.data); |
| + } else { |
| + queuedMessages.push(ev.data); |
| + } |
| +}); |
| +function dequeueMessage() { |
| + return new Promise((resolve, reject) => { |
| + if (queuedMessages.length === 0) { |
| + callbacksAwaitingMessages.push(resolve); |
| + } else { |
| + resolve(queuedMessages.shift()); |
| + } |
| + }); |
| +} |
| + |
| +function createFrame(name) { |
| + return new Promise((resolve, reject) => { |
| + const iframe = document.createElement("iframe"); |
| + iframe.name = name; |
| + iframe.addEventListener("load", () => resolve(iframe), {once: true}); |
| + iframe.src = CHILD_URL; |
| + window.document.documentElement.appendChild(iframe); |
| + }); |
| +} |
| + |
| +function reloadFrame(frame) { |
| + return new Promise((resolve, _) => { |
|
yhirano
2016/09/21 00:59:37
[optional] you can write as below if you don't wan
kouhei (in TOK)
2016/09/21 01:02:07
Done.
|
| + frame.addEventListener("load", () => resolve(frame), {once: true}); |
| + frame.src = frame.src; |
| + }); |
| +} |
| + |
| +promise_test(() => { |
| + var frameA, frameB; |
| + return Promise.resolve() |
| + .then(() => createFrame("A")).then((result) => { |
|
yhirano
2016/09/21 00:59:37
[optional] |(x) => {...}| can be written as |x =>
kouhei (in TOK)
2016/09/21 01:02:07
Done.
|
| + frameA = result; |
| + frameA.contentWindow.postMessage("query applied style", "*"); |
| + }) |
| + .then(dequeueMessage).then((styleInfoA) => { |
| + assert_equals(styleInfoA, "A " + EXPECTED_STYLE, "frame A should have the style applied"); |
| + }) |
| + .then(() => createFrame("B")).then((result) => { |
| + frameB = result; |
| + frameB.contentWindow.postMessage("query applied style", "*"); |
| + }) |
| + .then(dequeueMessage).then((styleInfoB) => { |
| + assert_equals(styleInfoB, "B " + EXPECTED_STYLE, "frame B should have the style applied"); |
| + }) |
| + .then(() => reloadFrame(frameA)) |
| + .then(() => frameA.contentWindow.postMessage("query applied style", "*")) |
| + .then(dequeueMessage).then((styleInfoA) => { |
| + assert_equals(styleInfoA, "A " + EXPECTED_STYLE, "frame A should have the style applied"); |
| + }) |
| + .then(() => frameB.contentWindow.postMessage("query applied style", "*")) |
| + .then(dequeueMessage).then((styleInfoB) => { |
| + assert_equals(styleInfoB, "B " + EXPECTED_STYLE, "frame B should have the style applied"); |
| + }) |
| + .then(() => reloadFrame(frameB)) |
| + .then(() => frameA.contentWindow.postMessage("query applied style", "*")) |
| + .then(dequeueMessage).then((styleInfoA) => { |
| + assert_equals(styleInfoA, "A " + EXPECTED_STYLE, "frame A should have the style applied"); |
| + }) |
| + .then(() => frameB.contentWindow.postMessage("query applied style", "*")) |
| + .then(dequeueMessage).then((styleInfoB) => { |
| + assert_equals(styleInfoB, "B " + EXPECTED_STYLE, "frame B should have the style applied"); |
| + }) |
| +}, 'Revalidated CSS should not be unapplied on existing clients.'); |
| +</script> |