| Index: webkit/glue/plugins/test/plugin_geturl_test.cc
|
| ===================================================================
|
| --- webkit/glue/plugins/test/plugin_geturl_test.cc (revision 24564)
|
| +++ webkit/glue/plugins/test/plugin_geturl_test.cc (working copy)
|
| @@ -34,15 +34,34 @@
|
| : PluginTest(id, host_functions),
|
| tests_started_(false),
|
| tests_in_progress_(0),
|
| - test_file_(NULL) {
|
| + test_file_(NULL),
|
| + expect_404_response_(false),
|
| + npn_evaluate_context_(false) {
|
| }
|
|
|
| +NPError PluginGetURLTest::New(uint16 mode, int16 argc, const char* argn[],
|
| + const char* argv[], NPSavedData* saved) {
|
| + const char* page_not_found_url = GetArgValue("page_not_found_url", argc,
|
| + argn, argv);
|
| + if (page_not_found_url) {
|
| + page_not_found_url_ = page_not_found_url;
|
| + expect_404_response_ = true;
|
| + }
|
| +
|
| + return PluginTest::New(mode, argc, argn, argv, saved);
|
| +}
|
| +
|
| NPError PluginGetURLTest::SetWindow(NPWindow* pNPWindow) {
|
| if (!tests_started_) {
|
| tests_started_ = true;
|
|
|
| tests_in_progress_++;
|
|
|
| + if (expect_404_response_) {
|
| + HostFunctions()->geturl(id(), page_not_found_url_.c_str(), NULL);
|
| + return NPERR_NO_ERROR;
|
| + }
|
| +
|
| std::string url = SELF_URL;
|
| HostFunctions()->geturlnotify(id(), url.c_str(), NULL,
|
| reinterpret_cast<void*>(SELF_URL_STREAM_ID));
|
| @@ -60,10 +79,37 @@
|
| if (stream == NULL)
|
| SetError("NewStream got null stream");
|
|
|
| + if (test_completed()) {
|
| + return PluginTest::NewStream(type, stream, seekable, stype);
|
| + }
|
| +
|
| COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData),
|
| cast_validity_check);
|
| +
|
| + if (expect_404_response_) {
|
| + NPObject *window_obj = NULL;
|
| + HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window_obj);
|
| + if (!window_obj) {
|
| + SetError("Failed to get NPObject for plugin instance2");
|
| + SignalTestCompleted();
|
| + return NPERR_NO_ERROR;
|
| + }
|
| +
|
| + std::string script = "javascript:alert('Hi there from plugin');";
|
| + NPString script_string;
|
| + script_string.UTF8Characters = script.c_str();
|
| + script_string.UTF8Length = static_cast<unsigned int>(script.length());
|
| + NPVariant result_var;
|
| +
|
| + npn_evaluate_context_ = true;
|
| + HostFunctions()->evaluate(id(), window_obj, &script_string, &result_var);
|
| + npn_evaluate_context_ = false;
|
| + return NPERR_NO_ERROR;
|
| + }
|
| +
|
| unsigned long stream_id = reinterpret_cast<unsigned long>(
|
| stream->notifyData);
|
| +
|
| switch (stream_id) {
|
| case SELF_URL_STREAM_ID:
|
| break;
|
| @@ -94,6 +140,10 @@
|
| }
|
|
|
| int32 PluginGetURLTest::WriteReady(NPStream *stream) {
|
| + if (test_completed()) {
|
| + return PluginTest::WriteReady(stream);
|
| + }
|
| +
|
| COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData),
|
| cast_validity_check);
|
| unsigned long stream_id = reinterpret_cast<unsigned long>(
|
| @@ -106,6 +156,10 @@
|
|
|
| int32 PluginGetURLTest::Write(NPStream *stream, int32 offset, int32 len,
|
| void *buffer) {
|
| + if (test_completed()) {
|
| + return PluginTest::Write(stream, offset, len, buffer);
|
| + }
|
| +
|
| if (stream == NULL)
|
| SetError("Write got null stream");
|
| if (len < 0 || len > STREAM_CHUNK)
|
| @@ -144,11 +198,25 @@
|
|
|
|
|
| NPError PluginGetURLTest::DestroyStream(NPStream *stream, NPError reason) {
|
| + if (test_completed()) {
|
| + return PluginTest::DestroyStream(stream, reason);
|
| + }
|
| +
|
| if (stream == NULL)
|
| SetError("NewStream got null stream");
|
|
|
| COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData),
|
| cast_validity_check);
|
| +
|
| + if (expect_404_response_) {
|
| + if (npn_evaluate_context_) {
|
| + SetError("Received destroyStream in the context of NPN_Evaluate.");
|
| + }
|
| +
|
| + SignalTestCompleted();
|
| + return NPERR_NO_ERROR;
|
| + }
|
| +
|
| unsigned long stream_id =
|
| reinterpret_cast<unsigned long>(stream->notifyData);
|
| switch (stream_id) {
|
|
|