diff options
-rw-r--r-- | build/common.gypi | 9 | ||||
-rw-r--r-- | chrome/test/ui/ppapi_uitest.cc | 4 | ||||
-rw-r--r-- | ppapi/proxy/dispatcher.cc | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_proxy_test.cc | 1 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.cc | 15 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.h | 1 | ||||
-rw-r--r-- | ppapi/tests/test_case.cc | 13 | ||||
-rw-r--r-- | ppapi/tests/test_case.h | 15 | ||||
-rw-r--r-- | ppapi/tests/test_case.html | 66 | ||||
-rw-r--r-- | ppapi/tests/test_post_message.cc | 11 | ||||
-rw-r--r-- | ppapi/tests/test_url_util.cc | 2 | ||||
-rw-r--r-- | ppapi/tests/test_var_deprecated.cc | 7 | ||||
-rw-r--r-- | ppapi/tests/test_var_deprecated.h | 6 | ||||
-rw-r--r-- | ppapi/tests/testing_instance.cc | 37 | ||||
-rw-r--r-- | ppapi/tests/testing_instance.h | 25 |
15 files changed, 178 insertions, 37 deletions
diff --git a/build/common.gypi b/build/common.gypi index 00a94d9..c2c56cc 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -348,6 +348,11 @@ # but that doesn't work as we'd like. 'msvs_debug_link_incremental%': '2', + # TODO(dmichael): eliminate this when possible. + # This flag, when 0, makes ppapi build without synchronous scripting + # support in public interfaces. This is a temporary transitional option. + 'pepper_scripting%': 1, + # Needed for some of the largest modules. 'msvs_debug_link_nonincremental%': '1', @@ -718,6 +723,10 @@ ['enable_flapper_hacks==1', { 'defines': ['ENABLE_FLAPPER_HACKS=1'], }], + ['pepper_scripting==0', { + 'defines': ['PPAPI_INSTANCE_REMOVE_SCRIPTING', + 'PPAPI_VAR_REMOVE_SCRIPTING'], + }], ['fastbuild!=0', { 'conditions': [ # For Windows, we don't genererate debug information. diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc index 566a070..c9d64c6 100644 --- a/chrome/test/ui/ppapi_uitest.cc +++ b/chrome/test/ui/ppapi_uitest.cc @@ -163,6 +163,10 @@ TEST_F(PPAPITest,PaintAggregator) { RunTestViaHTTP("PaintAggregator"); } +#if defined(OS_MACOSX) +// crbug.com/88754 +#define Scrollbar FAILS_Scrollbar +#endif TEST_F(PPAPITest, Scrollbar) { RunTest("Scrollbar"); } diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc index 8cb8028..ad32beb 100644 --- a/ppapi/proxy/dispatcher.cc +++ b/ppapi/proxy/dispatcher.cc @@ -139,10 +139,11 @@ InterfaceList::InterfaceList() { AddPPB(PPB_Graphics2D_Proxy::GetInfo()); AddPPB(PPB_ImageData_Proxy::GetInfo()); AddPPB(PPB_InputEvent_Proxy::GetInfo()); - AddPPB(PPB_Instance_Proxy::GetInfoPrivate()); AddPPB(PPB_Instance_Proxy::GetInfo0_4()); AddPPB(PPB_Instance_Proxy::GetInfo0_5()); AddPPB(PPB_Instance_Proxy::GetInfoFullscreen()); + AddPPB(PPB_Instance_Proxy::GetInfoMessaging()); + AddPPB(PPB_Instance_Proxy::GetInfoPrivate()); AddPPB(PPB_Memory_Proxy::GetInfo()); AddPPB(PPB_OpenGLES2_Proxy::GetInfo()); AddPPB(PPB_PDF_Proxy::GetInfo()); diff --git a/ppapi/proxy/ppapi_proxy_test.cc b/ppapi/proxy/ppapi_proxy_test.cc index c95ac4d..c8bb7eb 100644 --- a/ppapi/proxy/ppapi_proxy_test.cc +++ b/ppapi/proxy/ppapi_proxy_test.cc @@ -224,6 +224,7 @@ uint32 PluginProxyTestHarness::PluginDelegateMock::Register( void PluginProxyTestHarness::PluginDelegateMock::Unregister( uint32 plugin_dispatcher_id) { } + // PluginProxyTest ------------------------------------------------------------- PluginProxyTest::PluginProxyTest() { diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 6850971..7c3827f 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -7,6 +7,7 @@ #include "ppapi/c/dev/ppb_fullscreen_dev.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_instance.h" +#include "ppapi/c/ppb_messaging.h" #include "ppapi/proxy/host_dispatcher.h" #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/plugin_resource.h" @@ -70,6 +71,18 @@ const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo0_5() { } // static +const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoMessaging() { + static const Info info = { + ppapi::thunk::GetPPB_Messaging_Thunk(), + PPB_MESSAGING_INTERFACE, + INTERFACE_ID_NONE, // 0_5 is the canonical one. + false, + &CreateInstanceProxy, + }; + return &info; +} + +// static const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() { static const Info info = { ppapi::thunk::GetPPB_Instance_Private_Thunk(), @@ -112,6 +125,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnMsgIsFullFrame) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript, OnMsgExecuteScript) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage, + OnMsgPostMessage) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen, OnMsgSetFullscreen) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetScreenSize, diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index 3ae978e..d4de0a4 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -31,6 +31,7 @@ class PPB_Instance_Proxy : public InterfaceProxy, static const Info* GetInfo0_4(); static const Info* GetInfo0_5(); + static const Info* GetInfoMessaging(); static const Info* GetInfoPrivate(); static const Info* GetInfoFullscreen(); diff --git a/ppapi/tests/test_case.cc b/ppapi/tests/test_case.cc index 1d91ef5..15f24f0 100644 --- a/ppapi/tests/test_case.cc +++ b/ppapi/tests/test_case.cc @@ -35,20 +35,24 @@ std::string TestCase::MakeFailureMessage(const char* file, return output.str(); } -pp::Var TestCase::GetTestObject() { +#if !(defined __native_client__) +pp::VarPrivate TestCase::GetTestObject() { if (test_object_.is_undefined()) { pp::deprecated::ScriptableObject* so = CreateTestObject(); if (so) - test_object_ = pp::Var(instance_, so); // Takes ownership. + test_object_ = pp::VarPrivate(instance_, so); // Takes ownership. } return test_object_; } +#endif void TestCase::HandleMessage(const pp::Var& message_data) {} +#if !(defined __native_client__) pp::deprecated::ScriptableObject* TestCase::CreateTestObject() { return NULL; } +#endif bool TestCase::InitTestingInterface() { testing_interface_ = GetTestingInterface(); @@ -65,10 +69,7 @@ bool TestCase::InitTestingInterface() { } bool TestCase::EnsureRunningOverHTTP() { - pp::Var window = instance_->GetWindowObject(); - pp::Var location = window.GetProperty("location"); - pp::Var protocol = location.GetProperty("protocol"); - if (!protocol.is_string() || protocol.AsString() != "http:") { + if (instance_->protocol() != "http:") { instance_->AppendError("This test needs to be run over HTTP."); return false; } diff --git a/ppapi/tests/test_case.h b/ppapi/tests/test_case.h index 5ec4435..0a3cdc6 100644 --- a/ppapi/tests/test_case.h +++ b/ppapi/tests/test_case.h @@ -11,7 +11,12 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/cpp/dev/scrollbar_dev.h" + +#if (defined __native_client__) #include "ppapi/cpp/var.h" +#else +#include "ppapi/cpp/private/var_private.h" +#endif struct PPB_Testing_Dev; class TestingInstance; @@ -38,9 +43,11 @@ class TestCase { static std::string MakeFailureMessage(const char* file, int line, const char* cmd); +#if !(defined __native_client__) // Returns the scriptable test object for the current test, if any. // Internally, this uses CreateTestObject which each test overrides. - pp::Var GetTestObject(); + pp::VarPrivate GetTestObject(); +#endif // A function that is invoked whenever HandleMessage is called on the // associated TestingInstance. Default implementation does nothing. TestCases @@ -49,6 +56,7 @@ class TestCase { virtual void HandleMessage(const pp::Var& message_data); protected: +#if !(defined __native_client__) // Overridden by each test to supply a ScriptableObject corresponding to the // test. There can only be one object created for all test in a given class // so be sure your object is designed to be re-used. @@ -56,6 +64,7 @@ class TestCase { // This object should be created on the heap. Ownership will be passed to the // caller. Return NULL if there is no supported test object (the default). virtual pp::deprecated::ScriptableObject* CreateTestObject(); +#endif // Initializes the testing interface. bool InitTestingInterface(); @@ -73,8 +82,10 @@ class TestCase { bool force_async_; private: +#if !(defined __native_client__) // Holds the test object, if any was retrieved from CreateTestObject. - pp::Var test_object_; + pp::VarPrivate test_object_; +#endif }; // This class is an implementation detail. diff --git a/ppapi/tests/test_case.html b/ppapi/tests/test_case.html index 89bf1b6..1d395fe 100644 --- a/ppapi/tests/test_case.html +++ b/ppapi/tests/test_case.html @@ -66,6 +66,67 @@ function ExtractSearchParameter(name) { return ""; } +// Parses the message, looking for strings of the form: +// TESTING_MESSAGE:<message_type>:<message_contents> +// +// If the message_data is not a string or does not match the above format, then +// undefined is returned. +// +// Otherwise, returns an array containing 2 items. The 0th element is the +// message_type, one of: +// - ClearContents +// - DidExecuteTests +// - LogHTML +// - SetCookie +// The second item is the verbatim message_contents. +function ParseTestingMessage(message_data) { + if (typeof(message_data)!='string') + return undefined; + var testing_message_prefix = "TESTING_MESSAGE"; + var delim_str = ":"; + var delim1 = message_data.indexOf(delim_str); + if (message_data.substring(0, delim1) !== testing_message_prefix) + return undefined; + var delim2 = message_data.indexOf(delim_str, delim1 + 1); + if (delim2 == -1) + delim2 = message_data.length; + var message_type = message_data.substring(delim1 + 1, delim2); + var message_contents = message_data.substring(delim2 + 1); + return [message_type, message_contents]; +} + +function ClearConsole() { + window.document.getElementById("console").innerHTML = ""; +} + +function LogHTML(html) { + window.document.getElementById("console").innerHTML += html; +} + +function SetCookie(key_value_string) { + window.document.cookie = key_value_string + "; path=/"; +} + +function IsTestingMessage(message_data) { + return (ParseTestingMessage(message_data) != undefined); +} + +function handleTestingMessage(message_event) { + var type_contents_tuple = ParseTestingMessage(message_event.data); + if (type_contents_tuple) { + var type = type_contents_tuple[0]; + var contents = type_contents_tuple[1]; + if (type === "ClearConsole") + ClearConsole(); + else if (type === "DidExecuteTests") + DidExecuteTests(); + else if (type === "LogHTML") + LogHTML(contents); + else if (type === "SetCookie") + SetCookie(contents); + } +} + onload = function() { var testcase = ExtractSearchParameter("testcase"); var mode = ExtractSearchParameter("mode"); @@ -91,7 +152,10 @@ onload = function() { if (obj) { obj.setAttribute("id", "plugin"); obj.setAttribute("testcase", testcase); - document.getElementById("container").appendChild(obj); + obj.setAttribute("protocol", window.location.protocol); + var container = document.getElementById("container"); + container.appendChild(obj); + container.addEventListener("message", handleTestingMessage, true); } } </script> diff --git a/ppapi/tests/test_post_message.cc b/ppapi/tests/test_post_message.cc index a97ba42..ea29882 100644 --- a/ppapi/tests/test_post_message.cc +++ b/ppapi/tests/test_post_message.cc @@ -44,11 +44,18 @@ void TestPostMessage::HandleMessage(const pp::Var& message_data) { bool TestPostMessage::AddEchoingListener(const std::string& expression) { std::string js_code; + // Note the following code is dependent on some features of test_case.html. + // E.g., it is assumed that the DOM element where the plugin is embedded has + // an id of 'plugin', and there is a function 'IsTestingMessage' that allows + // us to ignore the messages that are intended for use by the testing + // framework itself. js_code += "var plugin = document.getElementById('plugin');" "var message_handler = function(message_event) {" - " plugin.postMessage("; + " if (!IsTestingMessage(message_event.data)) {" + " plugin.postMessage("; js_code += expression; - js_code += " );" + js_code += " );" + " }" "};" "plugin.addEventListener('message', message_handler);" // Maintain an array of all event listeners, attached to the diff --git a/ppapi/tests/test_url_util.cc b/ppapi/tests/test_url_util.cc index 964060d..dc6cb47 100644 --- a/ppapi/tests/test_url_util.cc +++ b/ppapi/tests/test_url_util.cc @@ -121,7 +121,7 @@ std::string TestURLUtil::TestDocumentCanAccessDocument() { std::string TestURLUtil::TestGetDocumentURL() { pp::Var url = util_->GetDocumentURL(*instance_); ASSERT_TRUE(url.is_string()); - pp::Var window = instance_->GetWindowObject(); + pp::VarPrivate window = instance_->GetWindowObject(); pp::Var href = window.GetProperty("location").GetProperty("href"); ASSERT_TRUE(href.is_string()); // In the test framework, they should be the same. diff --git a/ppapi/tests/test_var_deprecated.cc b/ppapi/tests/test_var_deprecated.cc index 34309ee..07ccf91 100644 --- a/ppapi/tests/test_var_deprecated.cc +++ b/ppapi/tests/test_var_deprecated.cc @@ -57,7 +57,7 @@ pp::Var VarScriptableObject::Call(const pp::Var& method_name, if (args.size() != 1) *exception = pp::Var("Bad argument to SetValue(<value>)"); else - test_var_deprecated_->set_var_from_page(args[0]); + test_var_deprecated_->set_var_from_page(pp::VarPrivate(args[0])); } return pp::Var(); @@ -297,7 +297,7 @@ std::string TestVarDeprecated::TestHasPropertyAndMethod() { uint32_t before_objects = testing_interface_->GetLiveObjectsForInstance( instance_->pp_instance()); { - pp::Var window = instance_->GetWindowObject(); + pp::VarPrivate window = instance_->GetWindowObject(); ASSERT_TRUE(window.is_object()); // Regular property. @@ -330,7 +330,7 @@ std::string TestVarDeprecated::TestHasPropertyAndMethod() { // Try to use something not an object. exception = pp::Var(); - pp::Var string_object("asdf"); + pp::VarPrivate string_object("asdf"); ASSERT_FALSE(string_object.HasProperty("find", &exception)); ASSERT_FALSE(exception.is_undefined()); exception = pp::Var(); @@ -397,3 +397,4 @@ std::string TestVarDeprecated::TestPassReference() { PASS(); } + diff --git a/ppapi/tests/test_var_deprecated.h b/ppapi/tests/test_var_deprecated.h index faed7be..8e64ece 100644 --- a/ppapi/tests/test_var_deprecated.h +++ b/ppapi/tests/test_var_deprecated.h @@ -7,7 +7,7 @@ #include <string> -#include "ppapi/cpp/var.h" +#include "ppapi/cpp/private/var_private.h" #include "ppapi/tests/test_case.h" struct PPB_Var_Deprecated; @@ -20,7 +20,7 @@ class TestVarDeprecated : public TestCase { virtual bool Init(); virtual void RunTest(); - void set_var_from_page(const pp::Var& v) { var_from_page_ = v; } + void set_var_from_page(const pp::VarPrivate& v) { var_from_page_ = v; } protected: // Test case protected overrides. @@ -41,7 +41,7 @@ class TestVarDeprecated : public TestCase { const PPB_Var_Deprecated* var_interface_; // Saves the var from when a value is set on the test from the page. - pp::Var var_from_page_; + pp::VarPrivate var_from_page_; }; #endif // PPAPI_TEST_TEST_VAR_DEPRECATED_H_ diff --git a/ppapi/tests/testing_instance.cc b/ppapi/tests/testing_instance.cc index 87022bb..138ef16 100644 --- a/ppapi/tests/testing_instance.cc +++ b/ppapi/tests/testing_instance.cc @@ -17,7 +17,11 @@ TestCaseFactory* TestCaseFactory::head_ = NULL; // 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) { @@ -36,8 +40,9 @@ bool TestingInstance::Init(uint32_t argc, 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++) { @@ -57,12 +62,14 @@ bool TestingInstance::Init(uint32_t argc, return true; } +#if !(defined __native_client__) pp::Var TestingInstance::GetInstanceObject() { if (current_case_) return current_case_->GetTestObject(); - return pp::Var(this, NULL); + return pp::VarPrivate(); } +#endif void TestingInstance::HandleMessage(const pp::Var& message_data) { current_case_->HandleMessage(message_data); @@ -109,10 +116,7 @@ void TestingInstance::ExecuteTests(int32_t unused) { SetCookie("STARTUP_COOKIE", "STARTED"); // Clear the console. - // This does: window.document.getElementById("console").innerHTML = ""; - pp::Var window = GetWindowObject(); - window.GetProperty("document"). - Call("getElementById", "console").SetProperty("innerHTML", ""); + PostMessage(pp::Var("TESTING_MESSAGE:ClearConsole")); if (!errors_.empty()) { // Catch initialization errors and output the current error string to @@ -131,8 +135,7 @@ void TestingInstance::ExecuteTests(int32_t unused) { // Declare we're done by setting a cookie to either "PASS" or the errors. SetCookie("COMPLETION_COOKIE", errors_.empty() ? "PASS" : errors_); - - window.Call("DidExecuteTests"); + PostMessage(pp::Var("TESTING_MESSAGE:DidExecuteTests")); } TestCase* TestingInstance::CaseForTestName(const char* name) { @@ -168,6 +171,7 @@ void TestingInstance::LogAvailableTests() { } html.append("</dl>"); html.append("<button onclick='RunAll()'>Run All Tests</button>"); + LogHTML(html); } @@ -180,19 +184,18 @@ void TestingInstance::LogError(const std::string& text) { } void TestingInstance::LogHTML(const std::string& html) { - // 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); + std::string message("TESTING_MESSAGE:LogHTML:"); + message.append(html); + PostMessage(pp::Var(message)); } void TestingInstance::SetCookie(const std::string& name, const std::string& value) { - // window.document.cookie = "<name>=<value>; path=/" - std::string cookie_string = name + "=" + value + "; path=/"; - pp::Var document = GetWindowObject().GetProperty("document"); - document.SetProperty("cookie", cookie_string); + std::string message("TESTING_MESSAGE:SetCookie:"); + message.append(name); + message.append("="); + message.append(value); + PostMessage(pp::Var(message)); } class Module : public pp::Module { diff --git a/ppapi/tests/testing_instance.h b/ppapi/tests/testing_instance.h index 2201e13..9f42409 100644 --- a/ppapi/tests/testing_instance.h +++ b/ppapi/tests/testing_instance.h @@ -8,11 +8,23 @@ #include <string> #include "ppapi/cpp/completion_callback.h" + +#if defined(__native_client__) #include "ppapi/cpp/instance.h" +#else +#include "ppapi/cpp/private/instance_private.h" +#endif class TestCase; -class TestingInstance : public pp::Instance { +// In trusted builds, we use InstancePrivate and allow tests that use +// synchronous scripting. NaCl does not support synchronous scripting. +class TestingInstance : public +#if defined(__native_client__) +pp::Instance { +#else +pp::InstancePrivate { +#endif public: explicit TestingInstance(PP_Instance instance); virtual ~TestingInstance(); @@ -20,7 +32,10 @@ class TestingInstance : public pp::Instance { // pp::Instance override. virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip); + +#if !(defined __native_client__) virtual pp::Var GetInstanceObject(); +#endif // Outputs the information from one test run, using the format // <test_name> [PASS|FAIL <error_message>] @@ -46,6 +61,10 @@ class TestingInstance : public pp::Instance { // TestClass object that's associated with this instance. virtual void HandleMessage(const pp::Var& message_data); + const std::string& protocol() { + return protocol_; + } + private: void ExecuteTests(int32_t unused); @@ -78,6 +97,10 @@ class TestingInstance : public pp::Instance { // True if running in Native Client. bool nacl_mode_; + + // String representing the protocol. Used for detecting whether we're running + // with http. + std::string protocol_; }; #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ |