layout/base/tests/test_remote_frame.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     5   <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
     6   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     7   <style>
     8   div, iframe {
     9     position:absolute;
    10     left:0; top:50px;
    11     width:400px; height:400px;
    12     transform: translateY(50px);
    13     border:5px solid black;
    14   }
    15   </style>
    16 </head>
    17   <body>
    18     <div id="d" style="background:blue"></div>
    20   <script type="application/javascript;version=1.7">
    21     "use strict";
    23     var referenceSnapshot;
    24     var iterations = 0;
    26     SimpleTest.waitForExplicitFinish();
    28     function pollForTestPass() {
    29       var snapshot = snapshotWindow(window);
    30       if (compareSnapshots(referenceSnapshot, snapshot, true)[0]) {
    31         ok(true, "Test passed after " + iterations + " iterations");
    32         SimpleTest.finish();
    33         return;
    34       }
    36       ++iterations;
    37       if (iterations == 20) {
    38         todo(false, "We couldn't draw the frame, but at least we didn't crash");
    39         SimpleTest.finish();
    40         return;
    41       }
    42       setTimeout(pollForTestPass, 10);
    43     }
    44     function addRemoteFrame() {
    45       let iframe = document.createElement("iframe");
    46       SpecialPowers.wrap(iframe).mozbrowser = true;
    47       iframe.src = "data:text/html,<html style='background:blue;'>";
    49       document.body.appendChild(iframe);
    51       pollForTestPass();
    52     }
    53     addEventListener("load", function() {
    54       referenceSnapshot = snapshotWindow(window);
    55       document.getElementById("d").style.display = 'none';
    56       SpecialPowers.addPermission("browser", true, document);
    57       SpecialPowers.pushPrefEnv({
    58         "set": [
    59           ["dom.ipc.browser_frames.oop_by_default", true],
    60           ["dom.mozBrowserFramesEnabled", true]
    61         ]
    62       }, addRemoteFrame);      
    63     });
    64   </script>
    65 </body>

mercurial