diff options
author | hclam@google.com <hclam@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-22 20:49:21 +0000 |
---|---|---|
committer | hclam@google.com <hclam@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-22 20:49:21 +0000 |
commit | 842ffc55330e73a0a33ec9ea8facced86b348de5 (patch) | |
tree | 60f652f33a005891e665473fe9924ddd251bed85 | |
parent | f055adaf0e0acfadd3d947b30ad32ffddf267f1a (diff) | |
download | chromium_src-842ffc55330e73a0a33ec9ea8facced86b348de5.zip chromium_src-842ffc55330e73a0a33ec9ea8facced86b348de5.tar.gz chromium_src-842ffc55330e73a0a33ec9ea8facced86b348de5.tar.bz2 |
Additional test to exploit memory leaks in <video>
TEST=MediaLeakTest.ManyVideoBear
This test inject and remove a <video> element many (50) times.
Trying to exploit memory leaks during the creation and
destruction of the internal media player and the glue code
with WebKit.
Review URL: http://codereview.chromium.org/159204
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21317 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/data/media/manybear.html | 38 | ||||
-rw-r--r-- | webkit/tools/test_shell/media_leak_test.cc | 30 |
2 files changed, 58 insertions, 10 deletions
diff --git a/webkit/data/media/manybear.html b/webkit/data/media/manybear.html new file mode 100644 index 0000000..066c270 --- /dev/null +++ b/webkit/data/media/manybear.html @@ -0,0 +1,38 @@ +<html> +<body> +<div id="container"></div> +<script> + layoutTestController.waitUntilDone(); + + var count = 0; + var file = "bear_silent.ogv"; + + function loop() { + var c = document.getElementById('container'); + var v = null; + + if (c.childNodes != null && c.childNodes.length > 0) { + v = c.childNodes[0]; + } + + // If there is a video tag as child, remove it. + if (v) { + c.removeChild(v); + window.setTimeout(function () { loop(); }, 0); + } else { + v = document.createElement("video"); + c.appendChild(v); + v.src = file; + v.addEventListener("load", function () { loop(); }, false); + v.load(); + } + + if (count++ == 50) { + layoutTestController.notifyDone(); + } + } + + loop(); +</script> +</body> +</html> diff --git a/webkit/tools/test_shell/media_leak_test.cc b/webkit/tools/test_shell/media_leak_test.cc index 2b58021..381c097 100644 --- a/webkit/tools/test_shell/media_leak_test.cc +++ b/webkit/tools/test_shell/media_leak_test.cc @@ -10,21 +10,31 @@ #include "webkit/tools/test_shell/test_shell_test.h" class MediaLeakTest : public TestShellTest { + public: + void RunTest(const char* file) { + FilePath media_file; + ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &media_file)); + media_file = media_file.Append(FILE_PATH_LITERAL("webkit")) + .Append(FILE_PATH_LITERAL("data")) + .Append(FILE_PATH_LITERAL("media")) + .Append(FILE_PATH_LITERAL(file)); + test_shell_->LoadURL(media_file.ToWStringHack().c_str()); + test_shell_->WaitTestFinished(); + } }; #if defined(OS_WIN) || defined(OS_LINUX) -// This test is to be executed in test_shell_tests so we can capture memory -// leak analysis in automated runs. +// This test plays a Theora video file for 1 second. It tries to expose +// memory leaks during a normal playback. TEST_F(MediaLeakTest, VideoBear) { - FilePath media_file; - ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &media_file)); - media_file = media_file.Append(FILE_PATH_LITERAL("webkit")) - .Append(FILE_PATH_LITERAL("data")) - .Append(FILE_PATH_LITERAL("media")) - .Append(FILE_PATH_LITERAL("bear.html")); - test_shell_->LoadURL(media_file.ToWStringHack().c_str()); - test_shell_->WaitTestFinished(); + RunTest("bear.html"); +} + +// This test loads a Theora video file and unloads it many times. It tries +// to expose memory leaks in the glue layer with WebKit. +TEST_F(MediaLeakTest, ManyVideoBear) { + RunTest("manybear.html"); } #endif |