Changeset 66628 in webkit
- Timestamp:
- Sep 1, 2010 6:00:51 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r66625 r66628 1 2010-09-01 Mihai Parparita <mihaip@chromium.org> 2 3 Reviewed by Brady Eidson. 4 5 popstate event is not fired until document opts in by calling pushstate. 6 https://bugs.webkit.org/show_bug.cgi?id=41372 7 8 Add two tests to check how often popstate is being fired (for both 9 fragment changes and page changes, especially with the page cache 10 enabled). 11 12 Update existing state object tests to handle popstate being fired for 13 the page being navigated to (right after onload). 14 15 * fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html: 16 * fast/loader/stateobjects/document-destroyed-navigate-back.html: 17 * fast/loader/stateobjects/popstate-after-load-complete-addeventlistener.html: 18 * fast/loader/stateobjects/popstate-after-load-complete-body-attribute.html: 19 * fast/loader/stateobjects/popstate-after-load-complete-body-inline-attribute.html: 20 * fast/loader/stateobjects/popstate-after-load-complete-window-attribute.html: 21 * fast/loader/stateobjects/popstate-fires-on-history-traversal-expected.txt: Added. 22 * fast/loader/stateobjects/popstate-fires-on-history-traversal.html: Added. 23 * fast/loader/stateobjects/popstate-fires-with-page-cache-expected.txt: Added. 24 * fast/loader/stateobjects/popstate-fires-with-page-cache.html: Added. 25 * fast/loader/stateobjects/pushstate-object-types.html: 26 * fast/loader/stateobjects/pushstate-then-replacestate.html: 27 * fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html: 28 * fast/loader/stateobjects/replacestate-in-iframe.html: 29 * fast/loader/stateobjects/replacestate-then-pushstate.html: 30 * fast/loader/stateobjects/resources/popstate-fires-with-page-cache-1.html: Added. 31 * fast/loader/stateobjects/resources/popstate-fires-with-page-cache-2.html: Added. 32 * fast/loader/stateobjects/resources/replacestate-in-iframe-window-child.html: 33 1 34 2010-09-01 Matthew Willis <lilmatt@flock.com> 2 35 -
trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html
r60608 r66628 33 33 } 34 34 35 function loaded()35 function runTest() 36 36 { 37 37 alert("LOADED"); … … 44 44 } 45 45 46 var beganTest = false; 47 46 48 function statePopped() 47 49 { 50 // The first time popstate fires, it's because the page has finished loading. 51 // Only then can we begin the test. 52 if (!beganTest) { 53 beganTest = true; 54 runTest(); 55 // Continue with the handler if we've already began the test. 56 if (!sessionStorage.stage) 57 return; 58 } 59 48 60 alert("State popped - " + event.state + " (type " + typeof event.state + ")"); 49 61 … … 80 92 81 93 </script> 82 <body on load="loaded();" onpopstate="statePopped();" onhashchange="hashChanged();" onunload="/* disable page cache */">94 <body onpopstate="statePopped();" onhashchange="hashChanged();" onunload="/* disable page cache */"> 83 95 <pre> 84 96 This test: -
trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html
r65340 r66628 32 32 } 33 33 34 function loaded()34 function runTest() 35 35 { 36 36 if (!sessionStorage.stage) { … … 43 43 } 44 44 45 var beganTest = false; 46 45 47 function statePopped() 46 48 { 49 // The first time popstate fires, it's because the page has finished loading. 50 // Only then can we begin the test. 51 if (!beganTest) { 52 beganTest = true; 53 runTest(); 54 // Continue with the handler if we've already began the test. 55 if (!sessionStorage.stage) 56 return; 57 } 58 47 59 alert("State popped - " + event.state + " (type " + typeof event.state + ")"); 48 60 if (event.state == "FirstEntry") { … … 63 75 64 76 </script> 65 <body on load="loaded();" onpopstate="statePopped();" onunload="/* disable page cache */">77 <body onpopstate="statePopped();" onunload="/* disable page cache */"> 66 78 <pre> 67 79 This test: -
trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-addeventlistener.html
r51644 r66628 21 21 } 22 22 23 var beganTest = false; 24 23 25 function statePopped() 24 26 { 27 // The first time popstate fires, it's because the page has finished loading. 28 // Only then can we begin the test. 29 if (!beganTest) { 30 beganTest = true; 31 runTest(); 32 return; 33 } 34 25 35 log("State popped - " + event.state + " (type " + typeof event.state + ")"); 26 36 if (event.state == null) … … 33 43 34 44 </script> 35 <body onload="runTest();">45 <body> 36 46 <pre> 37 47 This test does the following: -
trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-attribute.html
r51644 r66628 21 21 } 22 22 23 var beganTest = false; 24 23 25 function statePopped() 24 26 { 27 // The first time popstate fires, it's because the page has finished loading. 28 // Only then can we begin the test. 29 if (!beganTest) { 30 beganTest = true; 31 runTest(); 32 return; 33 } 34 25 35 log("State popped - " + event.state + " (type " + typeof event.state + ")"); 26 36 if (event.state == null) { … … 32 42 33 43 </script> 34 <body onload="runTest();">44 <body> 35 45 <pre> 36 46 This test does the following: -
trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-inline-attribute.html
r51644 r66628 21 21 } 22 22 23 var beganTest = false; 24 23 25 function statePopped() 24 26 { 27 // The first time popstate fires, it's because the page has finished loading. 28 // Only then can we begin the test. 29 if (!beganTest) { 30 beganTest = true; 31 runTest(); 32 return; 33 } 34 25 35 log("State popped - " + event.state + " (type " + typeof event.state + ")"); 26 36 if (event.state == null) { … … 32 42 33 43 </script> 34 <body on load="runTest();" onpopstate="statePopped();">44 <body onpopstate="statePopped();"> 35 45 <pre> 36 46 This test does the following: -
trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-window-attribute.html
r51644 r66628 21 21 } 22 22 23 var beganTest = false; 24 23 25 function statePopped() 24 26 { 27 // The first time popstate fires, it's because the page has finished loading. 28 // Only then can we begin the test. 29 if (!beganTest) { 30 beganTest = true; 31 runTest(); 32 return; 33 } 34 25 35 log("State popped - " + event.state + " (type " + typeof event.state + ")"); 26 36 if (event.state == null) … … 33 43 34 44 </script> 35 <body onload="runTest();">45 <body> 36 46 <pre> 37 47 This test does the following: -
trunk/LayoutTests/fast/loader/stateobjects/pushstate-object-types.html
r51655 r66628 11 11 function log(txt) 12 12 { 13 document.getElementById("logger"). innerText += txt + "\n";13 document.getElementById("logger").appendChild(document.createTextNode(txt + "\n")); 14 14 } 15 15 16 16 function runTest() 17 17 { 18 beganTest = true; 18 19 history.replaceState("FirstEntry", "Initial entry"); 19 20 history.pushState(undefined, "undefined entry"); … … 40 41 } 41 42 42 function statePopped() 43 var beganTest = false; 44 45 onpopstate = function(event) 43 46 { 47 // The first time popstate fires, it's because the page has finished loading. 48 // Only then can we begin the test. 49 if (!beganTest) { 50 beganTest = true; 51 runTest(); 52 return; 53 } 54 44 55 if (event.state instanceof Date) 45 log("State popped - " + event.state * 1+ " (type " + typeof event.state + ")");56 log("State popped - " + event.state.getTime() + " (type " + typeof event.state + ")"); 46 57 else 47 58 log("State popped - " + event.state + " (type " + typeof event.state + ")"); … … 55 66 56 67 </script> 57 <body onload="runTest();" onpopstate="statePopped();">58 <p re id="someelement">68 <body> 69 <p> 59 70 This test calls pushState with state objects of all the different object types supported by the HTML5 "internal structured cloning algorithm" and makes sure the events contain the expected objects when the states are popped. 60 </p re><br>71 </p> 61 72 <pre id="logger"></pre> 62 73 </body> -
trunk/LayoutTests/fast/loader/stateobjects/pushstate-then-replacestate.html
r51644 r66628 23 23 } 24 24 25 function statePopped() 25 var beganTest = false; 26 27 onpopstate = function(event) 26 28 { 29 // The first time popstate fires, it's because the page has finished loading. 30 // Only then can we begin the test. 31 if (!beganTest) { 32 beganTest = true; 33 runTest(); 34 return; 35 } 36 27 37 log("State popped - " + event.state + " (type " + typeof event.state + ")"); 28 38 if (event.state == null) … … 33 43 34 44 </script> 35 <body onload="runTest();" onpopstate="statePopped();">45 <body> 36 46 <pre> 37 47 This test does the following: -
trunk/LayoutTests/fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html
r53672 r66628 45 45 } 46 46 47 function statePopped() 47 var beganTest = false; 48 49 onpopstate = function(event) 48 50 { 51 // The first time popstate fires, it's because the page has finished loading. 52 // Only then can we begin the test. 53 if (!beganTest) { 54 beganTest = true; 55 runTest(); 56 return; 57 } 58 49 59 log("State popped with event " + event.state + " (type " + typeof event.state + ") and last path component " + lastPathComponent()); 50 60 if (event.state != "OriginalEntry") … … 54 64 } 55 65 56 function hashChanged()66 onhashchange = function() 57 67 { 58 68 log("Hash change fired and last path component is " + lastPathComponent()); … … 60 70 61 71 </script> 62 <body onload="runTest();" onpopstate="statePopped();" onhashchange="hashChanged();">72 <body> 63 73 <pre> 64 74 This test pushes a series of state objects with different URLs and fragment identifiers meant to test the hashChange event as states are popped. -
trunk/LayoutTests/fast/loader/stateobjects/replacestate-in-iframe.html
r57042 r66628 34 34 onload = function() { 35 35 testWin = open("resources/replacestate-in-iframe-window.html"); 36 testWin.onload = windowLoaded;37 36 } 38 37 </script> -
trunk/LayoutTests/fast/loader/stateobjects/replacestate-then-pushstate.html
r51644 r66628 23 23 } 24 24 25 function statePopped() 25 var beganTest = false; 26 27 onpopstate = function(event) 26 28 { 29 // The first time popstate fires, it's because the page has finished loading. 30 // Only then can we begin the test. 31 if (!beganTest) { 32 beganTest = true; 33 runTest(); 34 return; 35 } 36 27 37 log("State popped - " + event.state + " (type " + typeof event.state + ")"); 28 38 if (event.state == "OriginalHistoryItem") … … 33 43 34 44 </script> 35 <body onload="runTest();" onpopstate="statePopped();">45 <body> 36 46 <pre> 37 47 This test does the following: -
trunk/LayoutTests/fast/loader/stateobjects/resources/replacestate-in-iframe-window-child.html
r57042 r66628 5 5 6 6 onpopstate = function(e) { 7 if (!sessionStorage.beganTest) { 8 sessionStorage.beganTest = true; 9 top.opener.windowLoaded(); 10 return; 11 } 12 7 13 alert("onpopstate"); 8 14 top.opener.notifyDone(window == parent ? "FAIL" : "PASS"); -
trunk/WebCore/ChangeLog
r66624 r66628 1 2010-09-01 Mihai Parparita <mihaip@chromium.org> 2 3 Reviewed by Brady Eidson. 4 5 popstate event is not fired until document opts in by calling pushstate. 6 https://bugs.webkit.org/show_bug.cgi?id=41372 7 8 Fire popstate even when we don't have a state object when a page is 9 loaded (for both regular loads and those from the page cache). Also 10 fire popstate when doing in-document navigation via fragment changes. 11 This is consistent with both Gecko and recent the HTML5 spec change: 12 http://html5.org/tools/web-apps-tracker?from=5376&to=5377 13 14 Tests: fast/loader/stateobjects/popstate-fires-on-history-traversal.html 15 fast/loader/stateobjects/popstate-fires-with-page-cache.html 16 17 * bindings/js/SerializedScriptValue.cpp: 18 * bindings/js/SerializedScriptValue.h: 19 (WebCore::SerializedScriptValue::create): 20 * bindings/v8/SerializedScriptValue.cpp: 21 * bindings/v8/SerializedScriptValue.h: 22 * dom/Document.cpp: 23 (WebCore::Document::implicitClose): 24 * dom/Document.h: 25 * history/CachedFrame.cpp: 26 (WebCore::CachedFrameBase::restore): 27 * loader/FrameLoader.cpp: 28 (WebCore::FrameLoader::loadInSameDocument): 29 (WebCore::FrameLoader::transitionToCommitted): 30 * loader/HistoryController.cpp: 31 (WebCore::HistoryController::pushState): 32 (WebCore::HistoryController::replaceState): 33 1 34 2010-09-01 Ryosuke Niwa <rniwa@webkit.org> 2 35 -
trunk/WebCore/bindings/js/SerializedScriptValue.cpp
r65102 r66628 1081 1081 } 1082 1082 1083 SerializedScriptValue* SerializedScriptValue::nullValue() 1084 { 1085 DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, nullValue, (SerializedScriptValue::create())); 1086 return nullValue.get(); 1087 } 1088 1083 1089 JSValueRef SerializedScriptValue::deserialize(JSContextRef destinationContext, JSValueRef* exception) 1084 1090 { -
trunk/WebCore/bindings/js/SerializedScriptValue.h
r65104 r66628 214 214 return adoptRef(new SerializedScriptValue(SerializedScriptValueData())); 215 215 } 216 217 static SerializedScriptValue* nullValue(); 216 218 217 219 PassRefPtr<SerializedScriptValue> release() -
trunk/WebCore/bindings/v8/SerializedScriptValue.cpp
r65105 r66628 1097 1097 } 1098 1098 1099 SerializedScriptValue* SerializedScriptValue::nullValue() 1100 { 1101 DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, nullValue, (SerializedScriptValue::create())); 1102 return nullValue.get(); 1103 } 1104 1099 1105 PassRefPtr<SerializedScriptValue> SerializedScriptValue::release() 1100 1106 { -
trunk/WebCore/bindings/v8/SerializedScriptValue.h
r61114 r66628 53 53 static PassRefPtr<SerializedScriptValue> create(String data); 54 54 static PassRefPtr<SerializedScriptValue> create(); 55 56 static SerializedScriptValue* nullValue(); 55 57 56 58 PassRefPtr<SerializedScriptValue> release(); -
trunk/WebCore/dom/Document.cpp
r66498 r66628 83 83 #include "HTMLTitleElement.h" 84 84 #include "HTTPParsers.h" 85 #include "HistoryItem.h"86 85 #include "HitTestRequest.h" 87 86 #include "HitTestResult.h" … … 2022 2021 dispatchWindowLoadEvent(); 2023 2022 enqueuePageshowEvent(PageshowEventNotPersisted); 2024 if (m_pendingStateObject) 2025 enqueuePopstateEvent(m_pendingStateObject.release()); 2023 enqueuePopstateEvent(m_pendingStateObject ? m_pendingStateObject.release() : SerializedScriptValue::nullValue()); 2026 2024 2027 2025 if (f) -
trunk/WebCore/dom/Document.h
r66498 r66628 86 86 class HTMLInputElement; 87 87 class HTMLMapElement; 88 class HistoryItem;89 88 class HitTestRequest; 90 89 class HitTestResult; … … 991 990 void enqueuePageshowEvent(PageshowEventPersistence); 992 991 void enqueueHashchangeEvent(const String& oldURL, const String& newURL); 992 void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject); 993 993 994 994 void addMediaCanStartListener(MediaCanStartListener*); … … 1059 1059 void createStyleSelector(); 1060 1060 1061 void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);1062 1061 void pendingEventTimerFired(Timer<Document>*); 1063 1062 -
trunk/WebCore/history/CachedFrame.cpp
r62677 r66628 34 34 #include "FrameLoaderClient.h" 35 35 #include "FrameView.h" 36 #include "HistoryItem.h" 36 37 #include "Logging.h" 37 38 #include "PageTransitionEvent.h" … … 107 108 108 109 m_document->enqueuePageshowEvent(PageshowEventPersisted); 110 111 HistoryItem* historyItem = frame->loader()->history()->currentItem(); 112 m_document->enqueuePopstateEvent(historyItem && historyItem->stateObject() ? historyItem->stateObject() : SerializedScriptValue::nullValue()); 113 109 114 #if ENABLE(TOUCH_EVENTS) 110 115 if (m_document->hasListenerType(Document::TOUCH_LISTENER)) -
trunk/WebCore/loader/FrameLoader.cpp
r66549 r66628 1169 1169 m_client->dispatchDidNavigateWithinPage(); 1170 1170 1171 if (stateObject) { 1172 m_frame->document()->statePopped(stateObject); 1173 m_client->dispatchDidPopStateWithinPage(); 1174 } 1171 m_frame->document()->statePopped(stateObject ? stateObject : SerializedScriptValue::nullValue()); 1172 m_client->dispatchDidPopStateWithinPage(); 1175 1173 1176 1174 if (hashChange) { … … 1948 1946 history()->updateForBackForwardNavigation(); 1949 1947 1950 if (history()->currentItem()) 1948 // For cached pages, CachedFrame::restore will take care of firing the popstate event with the history item's state object 1949 if (history()->currentItem() && !cachedPage) 1951 1950 m_pendingStateObject = history()->currentItem()->stateObject(); 1952 1951 -
trunk/WebCore/loader/HistoryController.cpp
r66238 r66628 658 658 m_currentItem->setURLString(urlString); 659 659 660 // Create a null state object for the previous HistoryItem so that we will661 // generate a popstate event when navigating back to it.662 // FIXME: http://webkit.org/b/41372 implies that we shouldn't need this.663 if (!m_previousItem->stateObject())664 m_previousItem->setStateObject(SerializedScriptValue::create());665 666 660 page->backForwardList()->addItem(topItem.release()); 667 661 }
Note: See TracChangeset
for help on using the changeset viewer.