| 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 page-with-fragment.html#fragment | 
|  | 22   // 2. load blank2 | 
|  | 23   // 3. go back to page-with-fragment.html | 
|  | 24   async_test(function(t) { | 
|  | 25     iframe.src = './resources/page-with-fragment.html#fragment'; | 
|  | 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, /page-with-f
    ragment/, 'should be on page-with-fragment page'); | 
|  | 33             // wait one animation frame to ensure layout is run and fragment scr
    olling is complete | 
|  | 34             iframe.contentWindow.requestAnimationFrame(function() { | 
|  | 35               assert_equals(iframe.contentWindow.scrollY, 800, 'should scroll to
     fragment'); | 
|  | 36 | 
|  | 37               iframe.contentWindow.history.scrollRestoration = 'manual'; | 
|  | 38               assert_equals(iframe.contentWindow.history.scrollRestoration, 'man
    ual'); | 
|  | 39 | 
|  | 40               // navigate to new page | 
|  | 41               setTimeout(function() { | 
|  | 42                 iframe.src = './resources/blank1.html'; | 
|  | 43               }, 0); | 
|  | 44             }); | 
|  | 45           }); | 
|  | 46           break; | 
|  | 47         case 2: | 
|  | 48           t.step(function() { | 
|  | 49             assert_regexp_match(iframe.contentWindow.location.href, /blank1/, 's
    hould be on second blank page'); | 
|  | 50             assert_equals(iframe.contentWindow.history.scrollRestoration, 'auto'
    , 'new page loads should set scrollRestoration to "auto"'); | 
|  | 51 | 
|  | 52             setTimeout(function() { | 
|  | 53               iframe.contentWindow.history.back(); | 
|  | 54             }, 0); | 
|  | 55           }); | 
|  | 56           break; | 
|  | 57         case 3: | 
|  | 58           t.step(function() { | 
|  | 59             // coming back from history, scrollRestoration should be set to manu
    al and respected | 
|  | 60             assert_regexp_match(iframe.contentWindow.location.href, /page-with-f
    ragment/, 'should be back on page-with-fragment page'); | 
|  | 61             iframe.contentWindow.requestAnimationFrame(function() { | 
|  | 62               assert_equals(iframe.contentWindow.history.scrollRestoration, 'man
    ual', 'navigating back should retain scrollRestoration value'); | 
|  | 63               assert_equals(iframe.contentWindow.scrollX, 0, 'should not scroll 
    to fragment'); | 
|  | 64               assert_equals(iframe.contentWindow.scrollY, 0, 'should not scroll 
    to fragment'); | 
|  | 65               t.done(); | 
|  | 66             }); | 
|  | 67           }); | 
|  | 68           break; | 
|  | 69         default: | 
|  | 70           assert_unreached('iframe should load 3 times'); | 
|  | 71       } | 
|  | 72     }); | 
|  | 73   }, 'Manual scroll restoration should take precedent over scrolling to fragment
    '); | 
|  | 74 </script> | 
| OLD | NEW | 
|---|