Title: [150645] trunk/LayoutTests
Revision
150645
Author
commit-qu...@webkit.org
Date
2013-05-24 10:16:24 -0700 (Fri, 24 May 2013)

Log Message

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

Patch by Manuel Rego Casasnovas <r...@igalia.com> 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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (150644 => 150645)


--- trunk/LayoutTests/ChangeLog	2013-05-24 16:46:10 UTC (rev 150644)
+++ trunk/LayoutTests/ChangeLog	2013-05-24 17:16:24 UTC (rev 150645)
@@ -1,3 +1,20 @@
+2013-05-24  Manuel Rego Casasnovas  <r...@igalia.com>
+
+        Improve loader/go-back-cached-main-resource.html test
+        https://bugs.webkit.org/show_bug.cgi?id=116709
+
+        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.
+
 2013-05-24  Noam Rosenthal  <n...@webkit.org>
 
         WebProcess is crashing on http://achicu.github.io/css-presentation when direct pattern compositing is enabled

Modified: trunk/LayoutTests/loader/resources/first-page.html (150644 => 150645)


--- trunk/LayoutTests/loader/resources/first-page.html	2013-05-24 16:46:10 UTC (rev 150644)
+++ trunk/LayoutTests/loader/resources/first-page.html	2013-05-24 17:16:24 UTC (rev 150645)
@@ -1,23 +1,27 @@
 <html>
 <head>
     <script>
-    function registerListeners() {
+    function didShowPage() {
         // Notify opener.
         opener.postMessage('first-page', '*');
 
-        // Our opener will tell us to perform various loads.
-        window.addEventListener('message', function(event) {
+        // We register the listeners in the initial load (this is not needed
+        // when the page is restored from cache).
+        if (!event.persisted) {
+            // Our opener will tell us to perform various loads.
+            window.addEventListener('message', function(event) {
 
-            // Navigate to other page.
-            if (event.data ="" 'navigate-other-page') {
-                window.location = 'other-page.html';
-                return;
-            }
+                // Navigate to other page.
+                if (event.data ="" 'navigate-other-page') {
+                    window.location = 'other-page.html';
+                    return;
+                }
 
-        }, false);
+            }, false);
+        }
     }
     </script>
 </head>
-<body _onpageshow_="registerListeners();">
+<body _onpageshow_="didShowPage();">
 </body>
 </html>

Modified: trunk/LayoutTests/loader/resources/other-page.html (150644 => 150645)


--- trunk/LayoutTests/loader/resources/other-page.html	2013-05-24 16:46:10 UTC (rev 150644)
+++ trunk/LayoutTests/loader/resources/other-page.html	2013-05-24 17:16:24 UTC (rev 150645)
@@ -1,29 +1,33 @@
 <html>
 <head>
     <script>
-    function registerListeners() {
+    function didShowPage() {
         // Notify opener.
         opener.postMessage('other-page', '*');
 
-        // Our opener will tell us to perform various loads.
-        window.addEventListener('message', function(event) {
+        // We register the listeners in the initial load (this is not needed
+        // when the page is restored from cache).
+        if (!event.persisted) {
+            // Our opener will tell us to perform various loads.
+            window.addEventListener('message', function(event) {
 
-            // Navigate first resource.
-            if (event.data ="" 'navigate-first-page') {
-                window.location = 'first-page.html';
-                return;
-            }
+                // Navigate first resource.
+                if (event.data ="" 'navigate-first-page') {
+                    window.location = 'first-page.html';
+                    return;
+                }
 
-            // Navigate back.
-            if (event.data ="" 'navigate-back') {
-                window.history.back();
-                return;
-            }
+                // Navigate back.
+                if (event.data ="" 'navigate-back') {
+                    window.history.back();
+                    return;
+                }
 
-        }, false);
+            }, false);
+        }
     }
     </script>
 </head>
-<body _onpageshow_="registerListeners();">
+<body _onpageshow_="didShowPage();">
 </body>
 </html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to