diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 20:07:25 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 20:07:25 +0000 |
commit | e5098cd07ec6bd839e5a4138c4c82863671df4df (patch) | |
tree | aa5b5104bafedb1a449f8d61360ce5eb853cebbd /webkit/glue/plugins | |
parent | b3b01ab4ee312e566081c6bd6dce1a3ac020a691 (diff) | |
download | chromium_src-e5098cd07ec6bd839e5a4138c4c82863671df4df.zip chromium_src-e5098cd07ec6bd839e5a4138c4c82863671df4df.tar.gz chromium_src-e5098cd07ec6bd839e5a4138c4c82863671df4df.tar.bz2 |
Add an optional WebFrame parameter to WebView::findFrameByName.
This parameter is used to support _self and other names that
need to be evaluated relative to a subframe.
R=jam
BUG=23009
TEST=none
Review URL: http://codereview.chromium.org/257005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27646 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r-- | webkit/glue/plugins/test/plugin_client.cc | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/test/plugin_get_javascript_url2_test.cc | 131 | ||||
-rw-r--r-- | webkit/glue/plugins/test/plugin_get_javascript_url2_test.h | 38 |
3 files changed, 173 insertions, 0 deletions
diff --git a/webkit/glue/plugins/test/plugin_client.cc b/webkit/glue/plugins/test/plugin_client.cc index 66e41b8..18b7013f 100644 --- a/webkit/glue/plugins/test/plugin_client.cc +++ b/webkit/glue/plugins/test/plugin_client.cc @@ -7,6 +7,7 @@ #include "webkit/glue/plugins/test/plugin_arguments_test.h" #include "webkit/glue/plugins/test/plugin_delete_plugin_in_stream_test.h" #include "webkit/glue/plugins/test/plugin_get_javascript_url_test.h" +#include "webkit/glue/plugins/test/plugin_get_javascript_url2_test.h" #include "webkit/glue/plugins/test/plugin_geturl_test.h" #include "webkit/glue/plugins/test/plugin_javascript_open_popup.h" #include "webkit/glue/plugins/test/plugin_new_fails_test.h" @@ -119,6 +120,9 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, } else if (test_name == "getjavascripturl") { new_test = new NPAPIClient::ExecuteGetJavascriptUrlTest(instance, NPAPIClient::PluginClient::HostFunctions()); + } else if (test_name == "getjavascripturl2") { + new_test = new NPAPIClient::ExecuteGetJavascriptUrl2Test(instance, + NPAPIClient::PluginClient::HostFunctions()); #if defined(OS_WIN) // TODO(port): plugin_window_size_test.*. } else if (test_name == "checkwindowrect") { diff --git a/webkit/glue/plugins/test/plugin_get_javascript_url2_test.cc b/webkit/glue/plugins/test/plugin_get_javascript_url2_test.cc new file mode 100644 index 0000000..e332328 --- /dev/null +++ b/webkit/glue/plugins/test/plugin_get_javascript_url2_test.cc @@ -0,0 +1,131 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/glue/plugins/test/plugin_get_javascript_url2_test.h" + +#include "base/basictypes.h" + +// url for "self". +#define SELF_URL "javascript:window.location+\"\"" +// The identifier for the self url stream. +#define SELF_URL_STREAM_ID 1 + +// The identifier for the fetched url stream. +#define FETCHED_URL_STREAM_ID 2 + +// The maximum chunk size of stream data. +#define STREAM_CHUNK 197 + +const int kNPNEvaluateTimerID = 100; +const int kNPNEvaluateTimerElapse = 50; + +namespace NPAPIClient { + +ExecuteGetJavascriptUrl2Test::ExecuteGetJavascriptUrl2Test( + NPP id, NPNetscapeFuncs *host_functions) + : PluginTest(id, host_functions), + test_started_(false) { +} + +NPError ExecuteGetJavascriptUrl2Test::SetWindow(NPWindow* pNPWindow) { + if (!test_started_) { + std::string url = SELF_URL; + HostFunctions()->geturlnotify(id(), url.c_str(), "_self", + reinterpret_cast<void*>(SELF_URL_STREAM_ID)); + test_started_ = true; + } + return NPERR_NO_ERROR; +} + +NPError ExecuteGetJavascriptUrl2Test::NewStream(NPMIMEType type, NPStream* stream, + NPBool seekable, uint16* stype) { + if (stream == NULL) { + SetError("NewStream got null stream"); + return NPERR_INVALID_PARAM; + } + + COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData), + cast_validity_check); + unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); + switch (stream_id) { + case SELF_URL_STREAM_ID: + break; + default: + SetError("Unexpected NewStream callback"); + break; + } + return NPERR_NO_ERROR; +} + +int32 ExecuteGetJavascriptUrl2Test::WriteReady(NPStream *stream) { + return STREAM_CHUNK; +} + +int32 ExecuteGetJavascriptUrl2Test::Write(NPStream *stream, int32 offset, int32 len, + void *buffer) { + if (stream == NULL) { + SetError("Write got null stream"); + return -1; + } + if (len < 0 || len > STREAM_CHUNK) { + SetError("Write got bogus stream chunk size"); + return -1; + } + + COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData), + cast_validity_check); + unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); + switch (stream_id) { + case SELF_URL_STREAM_ID: + self_url_.append(static_cast<char*>(buffer), len); + break; + default: + SetError("Unexpected write callback"); + break; + } + // Pretend that we took all the data. + return len; +} + + +NPError ExecuteGetJavascriptUrl2Test::DestroyStream(NPStream *stream, NPError reason) { + if (stream == NULL) { + SetError("NewStream got null stream"); + return NPERR_INVALID_PARAM; + } + + COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData), + cast_validity_check); + unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); + switch (stream_id) { + case SELF_URL_STREAM_ID: + // don't care + break; + default: + SetError("Unexpected NewStream callback"); + break; + } + return NPERR_NO_ERROR; +} + +void ExecuteGetJavascriptUrl2Test::URLNotify(const char* url, NPReason reason, void* data) { + COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(data), + cast_validity_check); + + unsigned long stream_id = reinterpret_cast<unsigned long>(data); + switch (stream_id) { + case SELF_URL_STREAM_ID: + if (strcmp(url, SELF_URL) != 0) + SetError("URLNotify reported incorrect url for SELF_URL"); + if (self_url_.empty()) + SetError("Failed to obtain window location."); + SignalTestCompleted(); + break; + default: + SetError("Unexpected NewStream callback"); + break; + } +} + +} // namespace NPAPIClient diff --git a/webkit/glue/plugins/test/plugin_get_javascript_url2_test.h b/webkit/glue/plugins/test/plugin_get_javascript_url2_test.h new file mode 100644 index 0000000..557da76 --- /dev/null +++ b/webkit/glue/plugins/test/plugin_get_javascript_url2_test.h @@ -0,0 +1,38 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_GLUE_PLUGINS_TEST_PLUGIN_GET_JAVASCRIPT_URL2_H +#define WEBKIT_GLUE_PLUGINS_TEST_PLUGIN_GET_JAVASCRIPT_URL2_H + +#include "webkit/glue/plugins/test/plugin_test.h" + +namespace NPAPIClient { + +// This class tests NPP_GetURLNotify for a javascript URL with _top +// as the target frame. +class ExecuteGetJavascriptUrl2Test : public PluginTest { + public: + // Constructor. + ExecuteGetJavascriptUrl2Test(NPP id, NPNetscapeFuncs *host_functions); + + // + // NPAPI functions + // + virtual NPError SetWindow(NPWindow* pNPWindow); + virtual NPError NewStream(NPMIMEType type, NPStream* stream, + NPBool seekable, uint16* stype); + virtual int32 WriteReady(NPStream *stream); + virtual int32 Write(NPStream *stream, int32 offset, int32 len, + void *buffer); + virtual NPError DestroyStream(NPStream *stream, NPError reason); + virtual void URLNotify(const char* url, NPReason reason, void* data); + + private: + bool test_started_; + std::string self_url_; +}; + +} // namespace NPAPIClient + +#endif // WEBKIT_GLUE_PLUGINS_TEST_PLUGIN_GET_JAVASCRIPT_URL2_H |