tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_image_selection.html (2328B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=599368
      5 -->
      6 <head>
      7  <title>Test for Bug 599368</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <script src="/tests/SimpleTest/WindowSnapshot.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12 </head>
     13 <body>
     14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=599368">Mozilla Bug 599368</a>
     15 <iframe id="display" src="about:blank"></iframe>
     16 <div id="content" style="display: none">
     17  
     18 </div>
     19 <pre id="test">
     20 <script type="application/javascript">
     21 
     22 /** Test for Bug 599368 */
     23 
     24 SimpleTest.waitForExplicitFinish();
     25 
     26 window.addEventListener("load", step1);
     27 
     28 var gImage;
     29 var gIframe;
     30 var gBlueNotSelected;
     31 var gBlueSelected;
     32 var gFuchsiaSelected;
     33 
     34 function step1()
     35 {
     36  gIframe = document.getElementById("display");
     37  doc = gIframe.contentDocument;
     38 
     39  gImage = doc.createElement('img');
     40  var src = String(window.location).split("/");
     41  src.pop();
     42  src.push("blue-32x32.png");
     43  src = src.join("/");
     44  gImage.src = src;
     45  gImage.addEventListener("load", step2);
     46  doc.body.appendChild(gImage);
     47 
     48  doc.designMode = "on";
     49 }
     50 
     51 function step2() {
     52  gImage.removeEventListener("load", step2);
     53 
     54  gBlueNotSelected = snapshotWindow(gIframe.contentWindow, false);
     55 
     56  synthesizeMouse(gImage, 5, 5, {}, gIframe.contentWindow);
     57  setTimeout(step3, 0);
     58 }
     59 
     60 function step3() {
     61  gBlueSelected = snapshotWindow(gIframe.contentWindow, false);
     62 
     63  var src = String(window.location).split("/");
     64  src.pop();
     65  src.push("fuchsia-32x32.png");
     66  src = src.join("/");
     67  gImage.addEventListener("load", step4);
     68  gImage.src = src;
     69 }
     70 
     71 function step4() {
     72  gImage.removeEventListener("load", step4);
     73 
     74  gFuchsiaSelected = snapshotWindow(gIframe.contentWindow, false);
     75 
     76  // FYI: test_image_selection_in_contenteditable.html tests the detail.
     77  assertSnapshots(gBlueNotSelected, gBlueSelected, false, null,
     78                  "blue image without selection",
     79                  "blue image which is selected or added resizers");
     80  assertSnapshots(gBlueSelected, gFuchsiaSelected, false, null,
     81                  "blue image which is selected",
     82                  "fuchsia image which is selected");
     83 
     84  SimpleTest.finish();
     85 }
     86 
     87 </script>
     88 </pre>
     89 </body>
     90 </html>