Index: ppapi/tests/testing_instance.cc |
=================================================================== |
--- ppapi/tests/testing_instance.cc (revision 91865) |
+++ ppapi/tests/testing_instance.cc (working copy) |
@@ -17,11 +17,7 @@ |
// Returns a new heap-allocated test case for the given test, or NULL on |
// failure. |
TestingInstance::TestingInstance(PP_Instance instance) |
-#if (defined __native_client__) |
: pp::Instance(instance), |
-#else |
- : pp::InstancePrivate(instance), |
-#endif |
current_case_(NULL), |
executed_tests_(false), |
nacl_mode_(false) { |
@@ -40,9 +36,8 @@ |
if (std::strcmp(argn[i], "mode") == 0) { |
if (std::strcmp(argv[i], "nacl") == 0) |
nacl_mode_ = true; |
+ break; |
} |
- else if (std::strcmp(argn[i], "protocol") == 0) |
- protocol_ = argv[i]; |
} |
// Create the proper test case from the argument. |
for (uint32_t i = 0; i < argc; i++) { |
@@ -62,14 +57,12 @@ |
return true; |
} |
-#if !(defined __native_client__) |
pp::Var TestingInstance::GetInstanceObject() { |
if (current_case_) |
return current_case_->GetTestObject(); |
- return pp::VarPrivate(); |
+ return pp::Var(this, NULL); |
} |
-#endif |
void TestingInstance::HandleMessage(const pp::Var& message_data) { |
current_case_->HandleMessage(message_data); |
@@ -116,7 +109,10 @@ |
SetCookie("STARTUP_COOKIE", "STARTED"); |
// Clear the console. |
- PostMessage(pp::Var("TESTING_MESSAGE:ClearConsole")); |
+ // This does: window.document.getElementById("console").innerHTML = ""; |
+ pp::Var window = GetWindowObject(); |
+ window.GetProperty("document"). |
+ Call("getElementById", "console").SetProperty("innerHTML", ""); |
if (!errors_.empty()) { |
// Catch initialization errors and output the current error string to |
@@ -135,7 +131,8 @@ |
// Declare we're done by setting a cookie to either "PASS" or the errors. |
SetCookie("COMPLETION_COOKIE", errors_.empty() ? "PASS" : errors_); |
- PostMessage(pp::Var("TESTING_MESSAGE:DidExecuteTests")); |
+ |
+ window.Call("DidExecuteTests"); |
} |
TestCase* TestingInstance::CaseForTestName(const char* name) { |
@@ -171,7 +168,6 @@ |
} |
html.append("</dl>"); |
html.append("<button onclick='RunAll()'>Run All Tests</button>"); |
- |
LogHTML(html); |
} |
@@ -184,18 +180,19 @@ |
} |
void TestingInstance::LogHTML(const std::string& html) { |
- std::string message("TESTING_MESSAGE:LogHTML:"); |
- message.append(html); |
- PostMessage(pp::Var(message)); |
+ // This does: window.document.getElementById("console").innerHTML += html |
+ pp::Var console = GetWindowObject().GetProperty("document"). |
+ Call("getElementById", "console"); |
+ pp::Var inner_html = console.GetProperty("innerHTML"); |
+ console.SetProperty("innerHTML", inner_html.AsString() + html); |
} |
void TestingInstance::SetCookie(const std::string& name, |
const std::string& value) { |
- std::string message("TESTING_MESSAGE:SetCookie:"); |
- message.append(name); |
- message.append("="); |
- message.append(value); |
- PostMessage(pp::Var(message)); |
+ // window.document.cookie = "<name>=<value>; path=/" |
+ std::string cookie_string = name + "=" + value + "; path=/"; |
+ pp::Var document = GetWindowObject().GetProperty("document"); |
+ document.SetProperty("cookie", cookie_string); |
} |
class Module : public pp::Module { |