OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 iframe { |
| 4 height: 300px; |
| 5 width: 300px; |
| 6 } |
| 7 </style> |
| 8 |
| 9 <body> |
| 10 <iframe></iframe> |
| 11 </body> |
| 12 |
| 13 <script src="../../../resources/testharness.js"></script> |
| 14 <script src="../../../resources/testharnessreport.js"></script> |
| 15 <script type="text/javascript"> |
| 16 'use strict'; |
| 17 var iframe = document.querySelector('iframe'); |
| 18 var loadCount = 0; |
| 19 |
| 20 // The test does the following navigation steps for iframe |
| 21 // 1. load blank1 |
| 22 // 2. load blank2 |
| 23 // 3. go back to blank1 |
| 24 async_test(function(t) { |
| 25 iframe.src = './resources/blank1.html'; |
| 26 |
| 27 iframe.onload = t.step_func(function() { |
| 28 loadCount += 1; |
| 29 switch (loadCount) { |
| 30 case 1: |
| 31 t.step(function() { |
| 32 assert_regexp_match(iframe.contentWindow.location.href, /blank1/, 's
hould be on first blank page'); |
| 33 iframe.contentWindow.history.scrollRestoration = 'manual'; |
| 34 assert_equals(iframe.contentWindow.history.scrollRestoration, 'manua
l'); |
| 35 iframe.contentWindow.scrollTo(500, 500); |
| 36 assert_equals(iframe.contentWindow.scrollX, 500, 'scripted scrolling
should take effect'); |
| 37 assert_equals(iframe.contentWindow.scrollY, 500, 'scripted scrolling
should take effect'); |
| 38 |
| 39 // navigate to new page |
| 40 setTimeout(function() { |
| 41 iframe.src = './resources/blank2.html'; |
| 42 }, 0); |
| 43 }); |
| 44 break; |
| 45 case 2: |
| 46 t.step(function() { |
| 47 assert_regexp_match(iframe.contentWindow.location.href, /blank2/, 's
hould be on second blank page'); |
| 48 assert_equals(iframe.contentWindow.history.scrollRestoration, 'auto'
, 'new page loads should set scrollRestoration to "auto"'); |
| 49 |
| 50 setTimeout(function() { |
| 51 iframe.contentWindow.history.back(); |
| 52 }, 0); |
| 53 }); |
| 54 break; |
| 55 case 3: |
| 56 t.step(function() { |
| 57 // coming back from history, scrollRestoration should be restored to
manual and respect |
| 58 assert_regexp_match(iframe.contentWindow.location.href, /blank1/, 's
hould be back on first blank page'); |
| 59 assert_equals(iframe.contentWindow.history.scrollRestoration, 'manua
l', 'navigating back should retain scrollRestoration value'); |
| 60 assert_equals(iframe.contentWindow.scrollX, 0, 'horizontal scroll of
fset should not be restored'); |
| 61 assert_equals(iframe.contentWindow.scrollY, 0, 'vertical scroll offs
et should not be restored'); |
| 62 }); |
| 63 t.done(); |
| 64 break; |
| 65 default: |
| 66 assert_unreached('iframe should load 3 times'); |
| 67 } |
| 68 }); |
| 69 }, 'Navigating to new page should reset to "auto"'); |
| 70 </script> |
OLD | NEW |