Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: ppapi/tests/test_case.html

Issue 9403039: PPAPI: Really force-free NPObjects on Instance destruction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/tests/test_case.cc ('k') | ppapi/tests/test_instance_deprecated.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_case.html
diff --git a/ppapi/tests/test_case.html b/ppapi/tests/test_case.html
index f5c046eb623abfcf588acb4cceed49964c7956f3..92aebdb832fac363d85e446295fea89d5a1553f2 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;
@@ -79,9 +84,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 = ":";
@@ -115,6 +121,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);
}
@@ -134,6 +180,8 @@ function handleTestingMessage(message_event) {
SetCookie(contents);
else if (type === "EvalScript")
EvalScript(contents);
+ else if (type == "AddPostCondition")
+ AddPostCondition(contents);
}
}
@@ -184,6 +232,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!");
}
« no previous file with comments | « ppapi/tests/test_case.cc ('k') | ppapi/tests/test_instance_deprecated.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698