There should be a way to simulate memory pressure in layout tests
<https://webkit.org/b/159743>
Reviewed by Simon Fraser.
Source/WebCore:
Add three window.internal APIs:
- boolean isUnderMemoryPressure (readonly attribute)
- void beginSimulatedMemoryPressure()
- void endSimulatedMemoryPressure()
These make it possible to write tests that exercise behaviors that only
occur during memory pressure situations.
I also implemented the "org.WebKit.lowMemory" notification handler using the new API.
Test: memory/memory-pressure-simulation.html
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::beginSimulatedMemoryPressure):
(WebCore::MemoryPressureHandler::endSimulatedMemoryPressure):
* platform/MemoryPressureHandler.h:
(WebCore::MemoryPressureHandler::isUnderMemoryPressure):
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::platformReleaseMemory):
(WebCore::MemoryPressureHandler::install):
* testing/Internals.cpp:
(WebCore::Internals::isUnderMemoryPressure):
(WebCore::Internals::beginSimulatedMemoryPressure):
(WebCore::Internals::endSimulatedMemoryPressure):
* testing/Internals.h:
* testing/Internals.idl:
LayoutTests:
Add a basic test for the new APIs.
* memory/memory-pressure-simulation-expected.txt: Added.
* memory/memory-pressure-simulation.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@203379 268f45cc-cd09-0410-ab3c-d52691b4dbfc
10 files changed