[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10458: Add test for onStatus respon
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10458: Add test for onStatus responses, and have gnash support those. |
Date: |
Thu, 18 Dec 2008 01:54:23 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10458
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 01:54:23 +0100
message:
Add test for onStatus responses, and have gnash support those.
modified:
libcore/asobj/NetConnection_as.cpp
testsuite/misc-ming.all/remoting.as
testsuite/misc-ming.all/remoting.php
=== modified file 'libcore/asobj/NetConnection_as.cpp'
--- a/libcore/asobj/NetConnection_as.cpp 2008-12-17 20:55:37 +0000
+++ b/libcore/asobj/NetConnection_as.cpp 2008-12-18 00:54:23 +0000
@@ -319,14 +319,25 @@
while(b < end) {
if(b + 2 > end) break;
si = readNetworkShort(b); b += 2; // reply
length
- if(si < 11) {
+ if(si < 4) { // shorted valid response is
'/1/a'
log_error("NetConnection::call(): reply
message name too short");
break;
}
if(b + si > end) break;
- // TODO check that the last 9 bytes are
"/onResult"
- // this should either split on the 2nd / or
require onResult or onStatus
- std::string id(reinterpret_cast<char*>(b), si
- 9);
+
+ // Reply message is: '/id/methodName'
+
+ int ns = 1; // next slash position
+ while (ns<si-1 && *(b+ns) != '/') ++ns;
+ if ( ns >= si-1 ) {
+ std::string
msg(reinterpret_cast<char*>(b), si);
+ log_error("NetConnection::call(): invalid
reply message name (%s)", msg);
+ break;
+ }
+
+ std::string id(reinterpret_cast<char*>(b), ns);
+ std::string
methodName(reinterpret_cast<char*>(b+ns+1), si-ns-1);
+
b += si;
// parse past unused string in header
@@ -369,18 +380,30 @@
// if actionscript specified a callback
object, call it
boost::intrusive_ptr<as_object> callback =
pop_callback(id);
if(callback) {
+
+ string_table::key methodKey;
+ if ( methodName == "onResult" ) {
+ methodKey = NSV::PROP_ON_RESULT;
+ } else if ( methodName == "onStatus" ) {
+ methodKey = NSV::PROP_ON_STATUS;
+ } else {
+ // NOTE: the pp is known to actually
invoke the custom
+ // method, but with 7 undefined
arguments (?)
+ //methodKey =
_nc.getVM().getStringTable().find(methodName);
+ log_error("Unsupported HTTP Remoting
response callback: '%s' (size %d)", methodName, methodName.size());
+ continue;
+ }
+
#ifdef GNASH_DEBUG_REMOTING
log_debug("calling onResult callback");
#endif
// FIXME check if above line can fail and
we have to react
- callback->callMethod(NSV::PROP_ON_RESULT,
reply_as_value);
+ callback->callMethod(methodKey,
reply_as_value);
#ifdef GNASH_DEBUG_REMOTING
log_debug("callback called");
#endif
} else {
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("couldn't find callback object");
-#endif
+ log_error("Unknown HTTP Remoting response
identifier '%s'", id);
}
}
}
=== modified file 'testsuite/misc-ming.all/remoting.as'
--- a/testsuite/misc-ming.all/remoting.as 2008-12-17 22:37:05 +0000
+++ b/testsuite/misc-ming.all/remoting.as 2008-12-18 00:54:23 +0000
@@ -24,7 +24,7 @@
endOfTest = function()
{
//note("END OF TEST");
- check_totals(104);
+ check_totals(109);
play();
};
@@ -52,8 +52,9 @@
};
this.onCustom = function(result) {
note('default onCustom called with args: '+dumpObject(arguments));
- //this.onResult(arguments[0]);
- //this.customResult = arguments;
+ };
+ this.onDebugEvents = function(result) {
+ note('default onDebugEvents called with args: '+dumpObject(arguments));
};
this.onStatus = function(result) {
note("default onStatus called with args: "+dumpObject(arguments));
@@ -371,6 +372,20 @@
check_equals(res.message, 'toString');
check_equals(res.arg_count, '0');
check_equals(res.hex, '0a:00:00:00:00');
+ };
+
+ o=new ResultHandler();
+ nc.call('fail', o);
+ o.onResult = function(res) {
+ fail("onResult unexpectedly called");
+ test17();
+ };
+ o.onStatus = function(res) {
+ check_equals(res.remote_port, connectionPort);
+ check_equals(res.request_id, '/8');
+ check_equals(res.message, 'fail');
+ check_equals(res.arg_count, '0');
+ check_equals(res.hex, '0a:00:00:00:00');
test17();
};
}
=== modified file 'testsuite/misc-ming.all/remoting.php'
--- a/testsuite/misc-ming.all/remoting.php 2008-12-16 16:32:05 +0000
+++ b/testsuite/misc-ming.all/remoting.php 2008-12-18 00:54:23 +0000
@@ -172,9 +172,13 @@
$unsent[] = raw($answer);
} else {
$num_replies += 1;
- $reply .= make_string($request_id . '/onResult');
- $reply .= make_string('null');
- $reply .= "\377\377\377\377"; # should be size of reply
in bytes, but this works
+ if ( $message_name == 'fail' ) {
+ $reply .= make_string($request_id .
'/onStatus');
+ } else {
+ $reply .= make_string($request_id .
'/onResult');
+ }
+ $reply .= make_string('null'); # any string works here,
even the empty one
+ $reply .= "\377\377\377\377"; # should be size of
reply in bytes, but this works. all zeros also work.
$reply .= $answer;
}
- [Gnash-commit] /srv/bzr/gnash/trunk r10458: Add test for onStatus responses, and have gnash support those.,
Sandro Santilli <=