Changeset 150645 in webkit


Ignore:
Timestamp:
May 24, 2013 10:16:24 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Improve loader/go-back-cached-main-resource.html test
https://bugs.webkit.org/show_bug.cgi?id=116709

Patch by Manuel Rego Casasnovas <Manuel Rego Casasnovas> on 2013-05-24
Reviewed by Alexey Proskuryakov.

It is only needed to register the listeners on the initial load as they
are already present when restoring from page cache. Modified the test to
use event.persisted property to know if we are handling the first load
in order to register the listeners only once.

  • loader/resources/first-page.html: Rename registerListeners() function

to a more accurate name didShowPage() and use event.persisted to
register the listeners only in the first load.

  • loader/resources/other-page.html: Ditto.
Location:
trunk/LayoutTests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r150643 r150645  
     12013-05-24  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        Improve loader/go-back-cached-main-resource.html test
     4        https://bugs.webkit.org/show_bug.cgi?id=116709
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        It is only needed to register the listeners on the initial load as they
     9        are already present when restoring from page cache. Modified the test to
     10        use event.persisted property to know if we are handling the first load
     11        in order to register the listeners only once.
     12
     13        * loader/resources/first-page.html: Rename registerListeners() function
     14        to a more accurate name didShowPage() and use event.persisted to
     15        register the listeners only in the first load.
     16        * loader/resources/other-page.html: Ditto.
     17
    1182013-05-24  Noam Rosenthal  <noam@webkit.org>
    219
  • trunk/LayoutTests/loader/resources/first-page.html

    r150594 r150645  
    22<head>
    33    <script>
    4     function registerListeners() {
     4    function didShowPage() {
    55        // Notify opener.
    66        opener.postMessage('first-page', '*');
    77
    8         // Our opener will tell us to perform various loads.
    9         window.addEventListener('message', function(event) {
     8        // We register the listeners in the initial load (this is not needed
     9        // when the page is restored from cache).
     10        if (!event.persisted) {
     11            // Our opener will tell us to perform various loads.
     12            window.addEventListener('message', function(event) {
    1013
    11             // Navigate to other page.
    12             if (event.data === 'navigate-other-page') {
    13                 window.location = 'other-page.html';
    14                 return;
    15             }
     14                // Navigate to other page.
     15                if (event.data === 'navigate-other-page') {
     16                    window.location = 'other-page.html';
     17                    return;
     18                }
    1619
    17         }, false);
     20            }, false);
     21        }
    1822    }
    1923    </script>
    2024</head>
    21 <body onpageshow="registerListeners();">
     25<body onpageshow="didShowPage();">
    2226</body>
    2327</html>
  • trunk/LayoutTests/loader/resources/other-page.html

    r150594 r150645  
    22<head>
    33    <script>
    4     function registerListeners() {
     4    function didShowPage() {
    55        // Notify opener.
    66        opener.postMessage('other-page', '*');
    77
    8         // Our opener will tell us to perform various loads.
    9         window.addEventListener('message', function(event) {
     8        // We register the listeners in the initial load (this is not needed
     9        // when the page is restored from cache).
     10        if (!event.persisted) {
     11            // Our opener will tell us to perform various loads.
     12            window.addEventListener('message', function(event) {
    1013
    11             // Navigate first resource.
    12             if (event.data === 'navigate-first-page') {
    13                 window.location = 'first-page.html';
    14                 return;
    15             }
     14                // Navigate first resource.
     15                if (event.data === 'navigate-first-page') {
     16                    window.location = 'first-page.html';
     17                    return;
     18                }
    1619
    17             // Navigate back.
    18             if (event.data === 'navigate-back') {
    19                 window.history.back();
    20                 return;
    21             }
     20                // Navigate back.
     21                if (event.data === 'navigate-back') {
     22                    window.history.back();
     23                    return;
     24                }
    2225
    23         }, false);
     26            }, false);
     27        }
    2428    }
    2529    </script>
    2630</head>
    27 <body onpageshow="registerListeners();">
     31<body onpageshow="didShowPage();">
    2832</body>
    2933</html>
Note: See TracChangeset for help on using the changeset viewer.