History.pushState causes intense memory pressure.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jan 2016 22:48:15 +0000 (22:48 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jan 2016 22:48:15 +0000 (22:48 +0000)
commit7d3a44d4650fea2c23d9b3a406a0e4839afb7b41
tree94b8543cc0150de880f00d61a44148b0669f7d23
parentc3ca4fa690301614088cb657ac7324a8864d4367
History.pushState causes intense memory pressure.
https://bugs.webkit.org/show_bug.cgi?id=153435

Reviewed by Sam Weinig, Oliver Hunt, and Geoff Garen.

Source/WebCore:

Tests: fast/loader/stateobjects/pushstate-frequency-iframe.html
       fast/loader/stateobjects/pushstate-frequency-with-user-gesture.html
       fast/loader/stateobjects/pushstate-frequency.html
       fast/loader/stateobjects/replacestate-frequency-iframe.html
       fast/loader/stateobjects/replacestate-frequency-with-user-gesture.html
       fast/loader/stateobjects/replacestate-frequency.html
       loader/stateobjects/pushstate-size-iframe.html
       loader/stateobjects/pushstate-size.html
       loader/stateobjects/replacestate-size-iframe.html
       loader/stateobjects/replacestate-size.html

Add restrictions on how frequently push/replaceState can be called,
as well as how much of a cumulative payload they can deliver.

* bindings/js/JSHistoryCustom.cpp:
(WebCore::JSHistory::pushState):
(WebCore::JSHistory::replaceState):

* page/History.cpp:
(WebCore::History::stateObjectAdded):
* page/History.h:

LayoutTests:

* TestExpectations: Mark some of the new tests as slow.

* fast/loader/stateobjects/pushstate-frequency-expected.txt: Added.
* fast/loader/stateobjects/pushstate-frequency-iframe-expected.txt: Added.
* fast/loader/stateobjects/pushstate-frequency-iframe.html: Added.
* fast/loader/stateobjects/pushstate-frequency-with-user-gesture-expected.txt: Added.
* fast/loader/stateobjects/pushstate-frequency-with-user-gesture.html: Added.
* fast/loader/stateobjects/pushstate-frequency.html: Added.
* fast/loader/stateobjects/replacestate-frequency-expected.txt: Added.
* fast/loader/stateobjects/replacestate-frequency-iframe-expected.txt: Added.
* fast/loader/stateobjects/replacestate-frequency-iframe.html: Added.
* fast/loader/stateobjects/replacestate-frequency-with-user-gesture-expected.txt: Added.
* fast/loader/stateobjects/replacestate-frequency-with-user-gesture.html: Added.
* fast/loader/stateobjects/replacestate-frequency.html: Added.
* fast/loader/stateobjects/resources/pushstate-iframe.html: Added.
* fast/loader/stateobjects/resources/replacestate-iframe.html: Added.
* loader/stateobjects/pushstate-size-expected.txt: Added.
* loader/stateobjects/pushstate-size-iframe-expected.txt: Added.
* loader/stateobjects/pushstate-size-iframe.html: Added.
* loader/stateobjects/pushstate-size.html: Added.
* loader/stateobjects/replacestate-size-expected.txt: Added.
* loader/stateobjects/replacestate-size-iframe-expected.txt: Added.
* loader/stateobjects/replacestate-size-iframe.html: Added.
* loader/stateobjects/replacestate-size.html: Added.
* loader/stateobjects/resources/pushstate-iframe.html: Added.
* loader/stateobjects/resources/replacestate-iframe.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195625 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/loader/stateobjects/pushstate-frequency-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/pushstate-frequency-iframe-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/pushstate-frequency-iframe.html [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/pushstate-frequency-with-user-gesture-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/pushstate-frequency-with-user-gesture.html [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/pushstate-frequency.html [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/replacestate-frequency-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/replacestate-frequency-iframe-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/replacestate-frequency-iframe.html [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/replacestate-frequency-with-user-gesture-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/replacestate-frequency-with-user-gesture.html [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/replacestate-frequency.html [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/resources/pushstate-iframe.html [new file with mode: 0644]
LayoutTests/fast/loader/stateobjects/resources/replacestate-iframe.html [new file with mode: 0644]
LayoutTests/loader/stateobjects/pushstate-size-expected.txt [new file with mode: 0644]
LayoutTests/loader/stateobjects/pushstate-size-iframe-expected.txt [new file with mode: 0644]
LayoutTests/loader/stateobjects/pushstate-size-iframe.html [new file with mode: 0644]
LayoutTests/loader/stateobjects/pushstate-size.html [new file with mode: 0644]
LayoutTests/loader/stateobjects/replacestate-size-expected.txt [new file with mode: 0644]
LayoutTests/loader/stateobjects/replacestate-size-iframe-expected.txt [new file with mode: 0644]
LayoutTests/loader/stateobjects/replacestate-size-iframe.html [new file with mode: 0644]
LayoutTests/loader/stateobjects/replacestate-size.html [new file with mode: 0644]
LayoutTests/loader/stateobjects/resources/pushstate-iframe.html [new file with mode: 0644]
LayoutTests/loader/stateobjects/resources/replacestate-iframe.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSHistoryCustom.cpp
Source/WebCore/page/History.cpp
Source/WebCore/page/History.h