diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-16 22:34:22 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-16 22:34:22 +0000 |
commit | 13e343c565819075ce1eef5a001c875c795f7c33 (patch) | |
tree | b6a9e03b6b77fef5d9d5a09101da1c25ff86487e /ppapi/tests/test_case.html | |
parent | b86aad87785f4cdeaf9839619b2d1cc7e32e2f7f (diff) | |
download | chromium_src-13e343c565819075ce1eef5a001c875c795f7c33.zip chromium_src-13e343c565819075ce1eef5a001c875c795f7c33.tar.gz chromium_src-13e343c565819075ce1eef5a001c875c795f7c33.tar.bz2 |
Re-land http://codereview.chromium.org/9403039/, r124106
Original description:
"""
PPAPI: Really force-free NPObjects on Instance destruction.
(There still seems to be a memory leak with this patch; I may have to check our NPObject reference counting next.)
BUG=114023
TEST=
"""
BUG=114023
TEST=
TBR=dmichael@chromium.org
Review URL: http://codereview.chromium.org/9564024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127273 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_case.html')
-rw-r--r-- | ppapi/tests/test_case.html | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/ppapi/tests/test_case.html b/ppapi/tests/test_case.html index 3a72366..1a11546 100644 --- a/ppapi/tests/test_case.html +++ b/ppapi/tests/test_case.html @@ -10,6 +10,11 @@ function AdjustHeight(frameWin) { } function DidExecuteTests() { + var plugin = document.getElementById("plugin"); + plugin.parentNode.removeChild(plugin); + plugin = undefined; + CheckPostConditions(); + if (window == top) return; @@ -83,9 +88,10 @@ function ExtractSearchParameter(name) { // - LogHTML // - SetCookie // - EvalScript +// - AddPostCondition // The second item is the verbatim message_contents. function ParseTestingMessage(message_data) { - if (typeof(message_data)!='string') + if (typeof(message_data) != "string") return undefined; var testing_message_prefix = "TESTING_MESSAGE"; var delim_str = ":"; @@ -119,6 +125,46 @@ function EvalScript(script) { } } +var conditions = []; +// Add a "PostCondition". These are bits of script that are run after the plugin +// is destroyed. If they evaluate to false or throw an exception, it's +// considered a failure. +function AddPostCondition(script) { + conditions.push(script); +} +// Update the HTML to show the failure and update cookies so that ui_tests +// doesn't count this as a pass. +function ConditionFailed(error) { + error_string = "Post condition check failed: " + error; + var i = 0; + // If the plugin thinks the test passed but a post-condition failed, we want + // to clear the PASS cookie so that ui_tests doesn't count it is a passed + // test. + if (window.document.cookie.indexOf("PASS") != -1) { + while (window.document.cookie.indexOf("PPAPI_PROGRESS_" + i) != -1) { + window.document.cookie = "PPAPI_PROGRESS_" + i + "=; max-age=0"; + ++i; + } + window.document.cookie = "PPAPI_PROGRESS_0=" + error_string + } + LogHTML("<p>" + error_string); +} +// Iterate through the post conditions defined in |conditions| and check that +// they all pass. +function CheckPostConditions() { + for (var i = 0; i < conditions.length; ++i) { + var script = conditions[i]; + try { + if (!eval(script)) { + ConditionFailed("\"" + script + "\""); + } + } catch (ex) { + ConditionFailed("\"" + script + "\"" + " failed with exception: " + + "\"" + ex.toString() + "\""); + } + } +} + function IsTestingMessage(message_data) { return (ParseTestingMessage(message_data) != undefined); } @@ -138,6 +184,8 @@ function handleTestingMessage(message_event) { SetCookie(contents); else if (type === "EvalScript") EvalScript(contents); + else if (type == "AddPostCondition") + AddPostCondition(contents); } } @@ -191,6 +239,9 @@ onload = function() { // particular, we replace document.createEvent, MessageEvent.initMessageEvent, // and the MessageEvent constructor. Previous versions of the PostMessage // implementation made use of these and would fail (http://crbug.com/82604). +// TODO(dmichael): These should clear the PASS cookie so that ui_tests sees +// these as a failure (see ConditionFailed for how to do this). +// crbug.com/109775 document.createEvent = function() { LogHTML("<p>Bad document.createEvent called!"); } |