Bug 1116016 - Make file_iframe_sandbox_e_if5.html navigate away reliably.
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 07 May 2019 14:49:43 +0200
changeset 534763 cac07df678c379c2fed3e3a647e82214ef25f46e
parent 534762 85ca0fd33049018c147148a5a3b82898c01c1e9e
child 534764 c620d5893b60882304ee79f614965beb3d667376
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1116016
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1116016 - Make file_iframe_sandbox_e_if5.html navigate away reliably. Same fix as https://hg.mozilla.org/mozilla-central/rev/5b63c5b38dcc.
dom/html/test/file_iframe_sandbox_e_if5.html
--- a/dom/html/test/file_iframe_sandbox_e_if5.html
+++ b/dom/html/test/file_iframe_sandbox_e_if5.html
@@ -2,18 +2,29 @@
 <html>
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 341604</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script src="/tests/SimpleTest/EventUtils.js"></script>
 </head>
 <script type="application/javascript">
-function doTest() {
-  sendMouseEvent({type:'click'}, 'anchor');
+function navigateAway() {
+  // Anchor clicks are only handled if we have a pres-context, and we may not
+  // have one yet by the time this runs, and getBoundingClientRect() /
+  // sendMouseEvent won't construct it after bug 1440537.
+  //
+  // So we may need to wait a few frames to make this reliable.
+  //
+  // FIXME(emilio, bug 1218456): This dance shouldn't be needed.
+  let anchor = document.getElementById("anchor");
+  if (anchor.getBoundingClientRect().width > 0)
+    anchor.click();
+  else
+    requestAnimationFrame(navigateAway);
 }
 </script>
-<body onload="doTest()">
+<body onload="navigateAway()">
   I am sandboxed with 'allow-scripts and allow-top-navigation'
 
-  <a href="file_iframe_sandbox_top_navigation_pass.html" target='_top' id='anchor'>
+  <a href="file_iframe_sandbox_top_navigation_pass.html" target='_top' id='anchor'>Click me</a>
 </body>
 </html>