diff options
Diffstat (limited to 'layout/base/tests/file_zoom_restore_bfcache.html')
-rw-r--r-- | layout/base/tests/file_zoom_restore_bfcache.html | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/layout/base/tests/file_zoom_restore_bfcache.html b/layout/base/tests/file_zoom_restore_bfcache.html new file mode 100644 index 0000000000..77451f3ef6 --- /dev/null +++ b/layout/base/tests/file_zoom_restore_bfcache.html @@ -0,0 +1,92 @@ +<!doctype html> +<script> + var bcName = "zoomRestoreBfcache" + window.location.search; + var bc = new BroadcastChannel(bcName); + if (window.location.search == "?2") { + bc.onmessage = (msgEvent) => { + var msg = msgEvent.data; + var command = msg.command; + dump(`Subpage ?2 received command=${command}\n`); + switch (command) { + case "case2sendData": { + bc.postMessage({command: "case2data", devicePixelRatio: window.devicePixelRatio, + frameDevicePixelRatio: document.querySelector("iframe").contentWindow.devicePixelRatio}); + break; + } + case "case2action": { + SpecialPowers.spawnChrome([], () => { + const FullZoom = this.browsingContext.embedderElement.ownerGlobal.FullZoom; + FullZoom.setZoom(2.0); + }); + SpecialPowers.setFullZoom(window, 2); + window.requestAnimationFrame(() => window.requestAnimationFrame(() => { + bc.postMessage({command: "case2dataAnimationFrame", devicePixelRatio: window.devicePixelRatio, + frameDevicePixelRatio: document.querySelector("iframe").contentWindow.devicePixelRatio }); + })); + break; + } + case "case2back": { + bc.close(); + window.history.back(); + break; + } + } + } + } else { + bc.onmessage = (msgEvent) => { + var msg = msgEvent.data; + var command = msg.command; + dump(`Subpage received command=${command}\n`); + switch (command) { + case "case1sendData": { + bc.postMessage({command: "case1data", devicePixelRatio: window.devicePixelRatio}); + break; + } + case "case1click": { + document.querySelector("a").click(); + // We are opening file_zoom_restore_bfcache.html?2, so the current + // page is going into bfcache + break; + } + case "case3sendData": { + // We came back from bfcache + SpecialPowers.spawnChrome([], () => { + // We use FullZoom to set the zoom level in the parent, but if FullZoom is not + // available then that will fail. So we don't wait here for the devicePixelRatio + // to change if FullZoom is not available, and test_zoom_restore_bfcache.html + // will mark this test as todo. + return "FullZoom" in this.browsingContext.embedderElement.ownerGlobal; + }).then((hasFullZoom) => { + function waitUntilZoomLevelRestored() { + // Zoom level is updated asynchronously when bfcache lives in the + // parent process. + if (!hasFullZoom || window.devicePixelRatio == 2) { + bc.postMessage({command: "case3data", devicePixelRatio: window.devicePixelRatio, + frameDevicePixelRatio: document.querySelector("iframe").contentWindow.devicePixelRatio}); + return; + } + window.requestAnimationFrame(waitUntilZoomLevelRestored); + } + window.requestAnimationFrame(waitUntilZoomLevelRestored); + }); + break; + } + case "close": { + SpecialPowers.spawnChrome([], () => { + const FullZoom = this.browsingContext.embedderElement.ownerGlobal.FullZoom; + FullZoom.setZoom(1.0); + }); + bc.postMessage({command: "closed"}); + bc.close(); + window.close(); + break; + } + } + } + } + window.addEventListener("pageshow", function(e) { + bc.postMessage({command: "handlePageShow", eventPersisted: e.persisted}); + }); +</script> +<a href="?2">This is a very interesting page</a> +<iframe srcdoc="And this is a nested frame"></iframe> |