[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10463: Fixes to LocalConnection AS
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10463: Fixes to LocalConnection AS behaviour. |
Date: |
Thu, 18 Dec 2008 13:11:53 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10463
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 13:11:53 +0100
message:
Fixes to LocalConnection AS behaviour.
modified:
libbase/NetworkAdapter.h
libbase/curl_adapter.cpp
libcore/StringPredicates.h
libcore/TextField.cpp
libcore/as_environment.h
libcore/asobj/LocalConnection.cpp
libcore/asobj/LocalConnection.h
libcore/asobj/XML_as.h
libcore/parser/SWFMovieDefinition.h
libcore/parser/sprite_definition.h
testsuite/actionscript.all/LocalConnection.as
------------------------------------------------------------
revno: 10460.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Thu 2008-12-18 11:04:43 +0100
message:
Don't use _name for domain, as they are different things.
modified:
libcore/asobj/LocalConnection.cpp
libcore/asobj/LocalConnection.h
------------------------------------------------------------
revno: 10460.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Thu 2008-12-18 12:25:16 +0100
message:
Rename StringNoCaseLessThen to StringNoCaseLessThan (it has annoyed me for
years).
Add a result_type typedef to StringNoCaseEqual so that it can be used
easily
with boost::bind.
Test LocalConnection.send() and LocalConnection.connect() and correct
AS implementation (still doesn't really do anything).
modified:
libbase/NetworkAdapter.h
libbase/curl_adapter.cpp
libcore/StringPredicates.h
libcore/TextField.cpp
libcore/as_environment.h
libcore/asobj/LocalConnection.cpp
libcore/asobj/LocalConnection.h
libcore/asobj/XML_as.h
libcore/parser/SWFMovieDefinition.h
libcore/parser/sprite_definition.h
testsuite/actionscript.all/LocalConnection.as
=== modified file 'libbase/NetworkAdapter.h'
--- a/libbase/NetworkAdapter.h 2008-09-17 09:04:11 +0000
+++ b/libbase/NetworkAdapter.h 2008-12-18 11:25:16 +0000
@@ -38,7 +38,7 @@
/// Custom headers for addRequestHeader. These are case insensitive, and
/// subsequent addition of a header already there replaces any previous
one.
/// Some values are not allowed.
- typedef std::map<std::string, std::string, StringNoCaseLessThen>
RequestHeaders;
+ typedef std::map<std::string, std::string, StringNoCaseLessThan>
RequestHeaders;
/// \brief
/// Returns a read-only IOChannel that fetches data
@@ -82,7 +82,7 @@
private:
- static std::set<std::string, StringNoCaseLessThen> _reservedNames;
+ static std::set<std::string, StringNoCaseLessThan> _reservedNames;
};
=== modified file 'libbase/curl_adapter.cpp'
--- a/libbase/curl_adapter.cpp 2008-12-14 14:15:04 +0000
+++ b/libbase/curl_adapter.cpp 2008-12-18 11:25:16 +0000
@@ -1333,7 +1333,7 @@
}
/// Define static member.
-std::set<std::string, StringNoCaseLessThen>
+std::set<std::string, StringNoCaseLessThan>
NetworkAdapter::_reservedNames = boost::assign::list_of
("Accept-Ranges")
("Age")
=== modified file 'libcore/StringPredicates.h'
--- a/libcore/StringPredicates.h 2008-04-25 14:28:52 +0000
+++ b/libcore/StringPredicates.h 2008-12-18 11:25:16 +0000
@@ -27,7 +27,7 @@
namespace gnash {
/// A case-insensitive string comparator
-class StringNoCaseLessThen {
+class StringNoCaseLessThan {
public:
bool operator() (const std::string& a, const std::string& b) const
{
@@ -58,6 +58,9 @@
/// A case-insensitive string equality operator
class StringNoCaseEqual {
public:
+
+ typedef bool result_type;
+
bool operator() (const std::string& a, const std::string& b) const
{
return boost::iequals(a, b);
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2008-12-05 12:37:17 +0000
+++ b/libcore/TextField.cpp 2008-12-18 11:25:16 +0000
@@ -1830,7 +1830,7 @@
TextField::TypeValue
TextField::parseTypeValue(const std::string& val)
{
- StringNoCaseLessThen cmp;
+ StringNoCaseLessThan cmp;
if ( ! cmp(val, "input") )
{
=== modified file 'libcore/as_environment.h'
--- a/libcore/as_environment.h 2008-12-16 12:20:22 +0000
+++ b/libcore/as_environment.h 2008-12-18 11:25:16 +0000
@@ -47,7 +47,7 @@
typedef std::vector< boost::intrusive_ptr<as_object> > ScopeStack;
/// The variables container (case-insensitive)
- typedef std::map<std::string, as_value, StringNoCaseLessThen> Variables;
+ typedef std::map<std::string, as_value, StringNoCaseLessThan> Variables;
typedef std::vector<as_value> Registers;
=== modified file 'libcore/asobj/LocalConnection.cpp'
--- a/libcore/asobj/LocalConnection.cpp 2008-12-17 11:32:50 +0000
+++ b/libcore/asobj/LocalConnection.cpp 2008-12-18 11:25:16 +0000
@@ -25,6 +25,7 @@
#include <cerrno>
#include <cstring>
#include <boost/cstdint.hpp> // for boost::?int??_t
+#include <boost/assign/list_of.hpp>
#include "VM.h"
#include "URLAccessManager.h"
@@ -38,6 +39,7 @@
#include "lcshm.h"
#include "Object.h" // for getObjectInterface
#include "namedStrings.h"
+#include "StringPredicates.h"
using namespace amf;
@@ -78,139 +80,15 @@
namespace gnash {
-
-// Anonymous namespace for module-statics
namespace {
-
-/// Instantiate a new LocalConnection object within a flash movie
-as_value
-localconnection_new(const fn_call& /* fn */)
-{
- LocalConnection *localconnection_obj = new LocalConnection;
-
- return as_value(localconnection_obj);
-}
-
-/// The callback for LocalConnection::close()
-as_value
-localconnection_close(const fn_call& fn)
-{
-
- boost::intrusive_ptr<LocalConnection> ptr =
ensureType<LocalConnection>(fn.this_ptr);
-
- ptr->close();
- return as_value();
-}
-
-/// The callback for LocalConnection::connect()
-as_value
-localconnection_connect(const fn_call& fn)
-{
-// log_debug("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
- boost::intrusive_ptr<LocalConnection> ptr =
ensureType<LocalConnection>(fn.this_ptr);
-
- std::string name = fn.arg(0).to_string();
- bool ret;
-
- if (fn.nargs != 0) {
- ret = ptr->connect(name);
- name = "localhost";
- } else {
- log_error(_("No connection name specified to
LocalConnection.connect()"));
- ret = ptr->connect(name); // FIXME: This should probably
- // fail instead
- }
- return as_value(ret);
-}
-
-/// The callback for LocalConnection::domain()
-as_value
-localconnection_domain(const fn_call& fn)
-{
- boost::intrusive_ptr<LocalConnection> ptr =
ensureType<LocalConnection>(fn.this_ptr);
-
- VM& vm = ptr->getVM();
- const int swfVersion = vm.getSWFVersion();
-
- return as_value(ptr->domain(swfVersion));
-}
-
-/// The callback for LocalConnection::send()
-as_value
-localconnection_send(const fn_call& fn)
-{
- boost::intrusive_ptr<LocalConnection> ptr =
ensureType<LocalConnection>(fn.this_ptr);
-
- std::ostringstream os;
- fn.dump_args(os);
-
- // It is useful to see what's supposed being sent, so we log
- // this every time.
- log_unimpl(_("LocalConnection.send unimplemented %s"), os.str());
-
- if (!ptr->connected()) {
- ptr->connect();
- }
-
- if (rcfile.getLocalConnection() ) {
- log_security("Attempting to write to disabled LocalConnection!");
- return as_value(false);
- }
-
- // FIXME: send something
- return as_value();
-}
-
-
-void
-attachLocalConnectionInterface(as_object& o)
-{
-
- o.init_member("close", new builtin_function(localconnection_close));
- o.init_member("connect", new builtin_function(localconnection_connect));
- o.init_member("domain", new builtin_function(localconnection_domain));
- o.init_member("send", new builtin_function(localconnection_send));
-}
-
-as_object*
-getLocalConnectionInterface()
-{
-
- static boost::intrusive_ptr<as_object> o;
-
- if ( o == NULL )
- {
- o = new as_object(getObjectInterface());
- VM::get().addStatic(o.get());
-
- attachLocalConnectionInterface(*o);
- }
-
- return o.get();
-}
-
-builtin_function*
-getLocalConnectionConstructor()
-{
- // This is going to be the global Number "class"/"function"
- static builtin_function* cl=NULL;
-
- if ( cl == NULL )
- {
- cl=new builtin_function(&localconnection_new,
getLocalConnectionInterface());
- //attachLocalConnectionStaticInterface(*cl);
- VM::get().addStatic(cl); // FIXME: why do we need to register
ourself here ?
- }
-
- return cl;
-}
-
-} // anonymous namespace
-
-// This doesn't exist on all systems, but here's the vaue used on Unix.
-#ifndef MAXHOSTNAMELEN
-# define MAXHOSTNAMELEN 64
-#endif
+ as_value localconnection_connect(const fn_call& fn);
+ as_value localconnection_domain(const fn_call& fn);
+
+ bool validFunctionName(const std::string& func);
+
+ builtin_function* getLocalConnectionConstructor();
+ as_object* getLocalConnectionInterface();
+}
// \class LocalConnection
/// \brief Open a connection between two SWF movies so they can send
@@ -219,8 +97,10 @@
LocalConnection::LocalConnection()
:
as_object(getLocalConnectionInterface()),
- _connected(false)
+ _connected(false),
+ _domain(getDomain())
{
+ log_debug("The domain for this host is: %s", _domain);
}
LocalConnection::~LocalConnection()
@@ -242,84 +122,81 @@
/// The name is a symbolic name like "lc_name", that is used by the
/// send() command to signify which local connection to send the
/// object to.
-bool
-LocalConnection::connect()
-{
- return connect("");
-}
-
-bool
+void
LocalConnection::connect(const std::string& name)
{
if (name.empty()) {
_name = "none, sysv segment type";
- } else {
+ }
+ else {
_name = name;
}
log_debug("trying to open shared memory segment: \"%s\"", _name);
if (Shm::attach(_name.c_str(), true) == false) {
- return false;
+ return;
}
if (Shm::getAddr() <= 0) {
log_error("Failed to open shared memory segment: \"%s\"", _name);
- return false;
+ return;
}
_connected = true;
- return true;
+ return;
}
/// \brief Returns a string representing the superdomain of the
/// location of the current SWF file.
-///
+//
+/// This is set on construction, as it should be constant.
/// The domain is either the "localhost", or the hostname from the
/// network connection. This behaviour changed for SWF v7. Prior to v7
/// only the domain was returned, ie dropping off node names like
/// "www". As of v7, the behaviour is to return the full host
/// name. Gnash supports both behaviours based on the version.
std::string
-LocalConnection::domain(int version)
+LocalConnection::getDomain()
{
- // We already figured out the name
- if (_name.size()) {
- return _name;
- }
URL url(_vm.getRoot().getOriginalURL());
-// log_debug(_("ORIG URL=%s (%s)"), url.str(), url.hostname());
+
if (url.hostname().empty()) {
- _name = "localhost";
- } else {
- _name = url.hostname();
+ return "localhost";
}
// Adjust the name based on the swf version. Prior to v7, the nodename part
- // was removed. For v7 or later. the full hostname is returned. The
localhost
- // is always just the localhost.
- if (version <= 6) {
- std::string::size_type pos;
- pos = _name.rfind(".", _name.size());
- if (pos != std::string::npos) {
- pos = _name.rfind(".", pos-1);
- if (pos != std::string::npos) {
- _name = _name.substr(pos+1, _name.size());
- }
- }
- }
-
- // If unset, pick the default. Yes, we're paranoid.
- if (_name.empty()) {
- _name = "localhost";
- }
+ // was removed. For v7 or later. the full hostname is returned. The
+ // localhost is always just the localhost.
+ if (_vm.getSWFVersion() > 6) {
+ return url.hostname();
+ }
+
+ const std::string& domain = url.hostname();
+
+ std::string::size_type pos;
+ pos = domain.rfind('.');
+
+ // If there is no '.', return the whole thing.
+ if (pos == std::string::npos) {
+ return domain;
+ }
+
+ // If there is no second '.', return the whole thing.
+ pos = domain.rfind(".", pos - 1);
- log_debug("The domain for this host is: %s", _name);
-
- return _name;
+ // Return everything after the second-to-last '.'
+ // FIXME: this must be wrong, or it would return 'org.uk' for many
+ // UK websites, and not even Adobe is that stupid.
+ if (pos == std::string::npos) {
+ return domain;
+ }
+
+ return domain.substr(pos + 1);
+
}
void
@@ -327,8 +204,211 @@
{
builtin_function* ctor=getLocalConnectionConstructor();
- int swf6flags =
as_prop_flags::dontEnum|as_prop_flags::dontDelete|as_prop_flags::onlySWF6Up;
+ int swf6flags = as_prop_flags::dontEnum |
+ as_prop_flags::dontDelete |
+ as_prop_flags::onlySWF6Up;
+
glob.init_member(NSV::CLASS_LOCAL_CONNECTION, ctor, swf6flags);
}
+
+// Anonymous namespace for module-statics
+namespace {
+
+/// Instantiate a new LocalConnection object within a flash movie
+as_value
+localconnection_new(const fn_call& /* fn */)
+{
+ LocalConnection *obj = new LocalConnection;
+
+ return as_value(obj);
+}
+
+/// The callback for LocalConnection::close()
+as_value
+localconnection_close(const fn_call& fn)
+{
+
+ boost::intrusive_ptr<LocalConnection> ptr =
+ ensureType<LocalConnection>(fn.this_ptr);
+
+ ptr->close();
+ return as_value();
+}
+
+/// The callback for LocalConnection::connect()
+as_value
+localconnection_connect(const fn_call& fn)
+{
+ boost::intrusive_ptr<LocalConnection> ptr =
+ ensureType<LocalConnection>(fn.this_ptr);
+
+ if (!fn.nargs) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("LocalConnection.connect() expects exactly "
+ "1 argument"));
+ );
+ return as_value(false);
+ }
+
+ if (!fn.arg(0).is_string()) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("LocalConnection.connect(): first argument must "
+ "be a string"));
+ );
+ return as_value(false);
+ }
+
+ std::string name = fn.arg(0).to_string();
+
+ ptr->connect(name);
+
+ // We don't care whether connected or not.
+ return as_value(true);
+}
+
+/// The callback for LocalConnection::domain()
+as_value
+localconnection_domain(const fn_call& fn)
+{
+ boost::intrusive_ptr<LocalConnection> ptr =
+ ensureType<LocalConnection>(fn.this_ptr);
+
+ return as_value(ptr->domain());
+}
+
+/// LocalConnection.send()
+//
+/// Returns false only if the call was syntactically incorrect.
+as_value
+localconnection_send(const fn_call& fn)
+{
+ boost::intrusive_ptr<LocalConnection> ptr =
+ ensureType<LocalConnection>(fn.this_ptr);
+
+ // At least 2 args (connection name, function) required.
+ if (fn.nargs < 2) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::ostringstream os;
+ fn.dump_args(os);
+ log_aserror(_("LocalConnection.send(%s): requires at least 2 "
+ "arguments"), os.str());
+ );
+ return as_value(false);
+ }
+
+ // Both the first two arguments must be a string
+ if (!fn.arg(0).is_string() || !fn.arg(1).is_string()) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::ostringstream os;
+ fn.dump_args(os);
+ log_aserror(_("LocalConnection.send(%s): requires at least 2 "
+ "arguments"), os.str());
+ );
+ return as_value(false);
+ }
+
+ const std::string& func = fn.arg(1).to_string();
+
+ if (!validFunctionName(func)) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::ostringstream os;
+ fn.dump_args(os);
+ log_aserror(_("LocalConnection.send(%s): requires at least 2 "
+ "arguments"), os.str());
+ );
+ return as_value(false);
+ }
+
+
+ // Now we have a valid call.
+
+ // It is useful to see what's supposed being sent, so we log
+ // this every time until implemented.
+ std::ostringstream os;
+ fn.dump_args(os);
+ log_unimpl(_("LocalConnection.send unimplemented %s"), os.str());
+
+ // We'll return true if the LocalConnection is disabled too, as
+ // the return value doesn't indicate success of the connection.
+ if (rcfile.getLocalConnection() ) {
+ log_security("Attempting to write to disabled LocalConnection!");
+ return as_value(true);
+ }
+
+ return as_value(true);
+}
+
+
+void
+attachLocalConnectionInterface(as_object& o)
+{
+
+ o.init_member("close", new builtin_function(localconnection_close));
+ o.init_member("connect", new builtin_function(localconnection_connect));
+ o.init_member("domain", new builtin_function(localconnection_domain));
+ o.init_member("send", new builtin_function(localconnection_send));
+}
+
+as_object*
+getLocalConnectionInterface()
+{
+
+ static boost::intrusive_ptr<as_object> o;
+
+ if ( o == NULL )
+ {
+ o = new as_object(getObjectInterface());
+ VM::get().addStatic(o.get());
+
+ attachLocalConnectionInterface(*o);
+ }
+
+ return o.get();
+}
+
+builtin_function*
+getLocalConnectionConstructor()
+{
+ // This is going to be the global Number "class"/"function"
+ static builtin_function* cl=NULL;
+
+ if ( cl == NULL )
+ {
+ cl = new builtin_function(&localconnection_new,
+ getLocalConnectionInterface());
+
+ // FIXME: why do we need to register ourself here ?
+ VM::get().addStatic(cl);
+ }
+
+ return cl;
+}
+
+/// These names are invalid as a function name.
+bool
+validFunctionName(const std::string& func)
+{
+
+ if (func.empty()) return false;
+
+ typedef std::vector<std::string> ReservedNames;
+
+ static const ReservedNames reserved = boost::assign::list_of
+ ("send")
+ ("onStatus")
+ ("close")
+ ("connect")
+ ("domain")
+ ("allowDomain");
+
+ const ReservedNames::const_iterator it =
+ std::find_if(reserved.begin(), reserved.end(),
+ boost::bind(StringNoCaseEqual(), _1, func));
+
+ return (it == reserved.end());
+}
+
+} // anonymous namespace
+
} // end of gnash namespace
=== modified file 'libcore/asobj/LocalConnection.h'
--- a/libcore/asobj/LocalConnection.h 2008-12-18 00:59:49 +0000
+++ b/libcore/asobj/LocalConnection.h 2008-12-18 11:25:16 +0000
@@ -15,12 +15,12 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#ifndef __LOCALCONNECTION_H__
-#define __LOCALCONNECTION_H__
+#ifndef GNASH_ASOBJ_LOCALCONNECTION_H
+#define GNASH_ASOBJ_LOCALCONNECTION_H
#include <string>
#include <map>
-#include <boost/cstdint.hpp> // for boost::?int??_t
+#include <boost/cstdint.hpp>
#include "as_object.h" // for inheritance
#include "fn_call.h"
@@ -28,33 +28,50 @@
namespace gnash {
- class LocalConnection : public as_object, amf::LcShm {
+class LocalConnection : public as_object, amf::LcShm
+{
+
public:
+
LocalConnection();
~LocalConnection();
- void close(void);
- bool connect();
- bool connect(const std::string& name);
- std::string domain(int version);
+
+ void close();
+
+ void connect(const std::string& name);
+
+ const std::string& domain() {
+ return _domain;
+ }
+
void send();
+
std::string &getName() { return _name; };
+
bool connected() { return _connected; };
-// FIXME: these should be callbacks
-// bool _allowDomain;
-// bool _allowInsecureDomain;
-// bool _onStatus;
private:
+
+ /// Work out the domain.
+ //
+ /// Called once on construction to set _domain, though it will do
+ /// no harm to call it again.
+ std::string getDomain();
+
bool _connected;
std::string _name;
std::map<const char *, short> _allocated;
+
+ // The immutable domain of this LocalConnection, based on the
+ // originating SWF's domain.
+ const std::string _domain;
+
};
void localconnection_class_init(as_object& glob);
} // end of gnash namespace
-// __LOCALCONNECTION_H__
#endif
// local Variables:
=== modified file 'libcore/asobj/XML_as.h'
--- a/libcore/asobj/XML_as.h 2008-12-08 07:59:26 +0000
+++ b/libcore/asobj/XML_as.h 2008-12-18 11:25:16 +0000
@@ -136,7 +136,7 @@
static const Entities& getEntities();
- typedef std::map<std::string, std::string, StringNoCaseLessThen>
Attributes;
+ typedef std::map<std::string, std::string, StringNoCaseLessThan>
Attributes;
void parseTag(XMLNode_as*& node, const std::string& xml,
std::string::const_iterator& it);
=== modified file 'libcore/parser/SWFMovieDefinition.h'
--- a/libcore/parser/SWFMovieDefinition.h 2008-12-16 15:15:55 +0000
+++ b/libcore/parser/SWFMovieDefinition.h 2008-12-18 11:25:16 +0000
@@ -444,14 +444,14 @@
PlayListMap m_playlist;
/// 0-based frame #'s
- typedef std::map<std::string, size_t, StringNoCaseLessThen>
NamedFrameMap;
+ typedef std::map<std::string, size_t, StringNoCaseLessThan>
NamedFrameMap;
NamedFrameMap _namedFrames;
// Mutex protecting access to _namedFrames
mutable boost::mutex _namedFramesMutex;
typedef std::map<std::string, boost::intrusive_ptr<ExportableResource>,
- StringNoCaseLessThen > ExportMap;
+ StringNoCaseLessThan > ExportMap;
ExportMap _exportedResources;
// Mutex protecting access to _exportedResources
=== modified file 'libcore/parser/sprite_definition.h'
--- a/libcore/parser/sprite_definition.h 2008-12-16 15:15:55 +0000
+++ b/libcore/parser/sprite_definition.h 2008-12-18 11:25:16 +0000
@@ -27,7 +27,7 @@
#include "movie_definition.h" // for inheritance
#include "log.h"
#include "rect.h"
-#include "StringPredicates.h" // StringNoCaseLessThen
+#include "StringPredicates.h" // StringNoCaseLessThan
#include "TagLoadersTable.h"
// Forward declarations
@@ -266,7 +266,7 @@
PlayListMap m_playlist;
// stores 0-based frame #'s
- typedef std::map<std::string, size_t, StringNoCaseLessThen>
NamedFrameMap;
+ typedef std::map<std::string, size_t, StringNoCaseLessThan>
NamedFrameMap;
NamedFrameMap _namedFrames;
size_t m_frame_count;
=== modified file 'testsuite/actionscript.all/LocalConnection.as'
--- a/testsuite/actionscript.all/LocalConnection.as 2008-12-01 12:21:59
+0000
+++ b/testsuite/actionscript.all/LocalConnection.as 2008-12-18 11:25:16
+0000
@@ -26,6 +26,8 @@
rcsid="$Id: LocalConnection.as,v 1.21 2008/05/05 15:26:38 bwy Exp $";
#include "check.as"
+snd = new LocalConnection();
+
#if OUTPUT_VERSION < 6
check_equals(LocalConnection, undefined);
@@ -63,8 +65,7 @@
// test the LocalConnection::send method
check_equals (typeof(rec.send), 'function');
-// Get the domain. By default this should be "localhost" because we
-// haven't made any connections yet,
+// Get the domain. This should be based on the domain of the SWF.
var domain = rec.domain();
check_equals (domain, "localhost");
@@ -74,41 +75,112 @@
// could always (in a normal application) check later for incoming
// connections.
+// Test connect. Return based on argument, not result of connection.
+// Anything but a string returns false. The onStatus function is not called.
+statuses = new Array;
+
+rec.onStatus = function(obj) {
+ statuses.push(obj.code);
+};
+
+ret = rec.connect();
+check_equals(ret, false);
+check_equals(statuses.length, 0);
+
+ret = rec.connect(3);
+check_equals(ret, false);
+check_equals(statuses.length, 0);
+
+ret = rec.connect(undefined);
+check_equals(ret, false);
+check_equals(statuses.length, 0);
+
+ret = rec.connect("string");
+check_equals(ret, true);
+check_equals(statuses.length, 0);
+
rec.close();
result = rec.connect("lc_test");
-xcheck_equals (rec.domain(), "localhost");
+check_equals (rec.domain(), "localhost");
// NOTE: This test will fail if a shared memory segment of the same
// name exists. So the first time it'll pass, then it'll fail.
check_equals (result, true);
// Checks only for syntactical correctness, not success
+
+result = snd.send();
+check_equals (result, false);
+
+result = snd.send(3);
+check_equals (result, false);
+
+result = snd.send("string", "string", "string", "string");
+check_equals (result, true);
+
+
+
result = snd.send("lc_test", "testfunc", "val");
-xcheck_equals (result, true);
+check_equals (result, true);
// The function name may not be send or any other LC property.
result = snd.send("lc_test", "send");
-xcheck_equals (result, false);
+check_equals (result, false);
result = snd.send("lc_test", "onStatus");
-xcheck_equals (result, false);
+check_equals (result, false);
// Numbers are also bad
result = snd.send("lc_test", 1);
-xcheck_equals (result, false);
+check_equals (result, false);
// undefined
result = snd.send("lc_test", funcname);
-xcheck_equals (result, false);
-
+check_equals (result, false);
+
+result = snd.send("lc_test", "Send");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "DOMAIn");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "close");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "conNeCt");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "onStatus");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "ALLOWDOMAIN");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "");
+ check_equals(result, false);
// But anything else is fine.
+result = snd.send("lc_test", "8");
+ check_equals(result, true);
+
+result = snd.send("lc_test", "ß");
+ check_equals(result, true);
+
+result = snd.send("lc_test", "&");
+ check_equals(result, true);
+
+result = snd.send("lc_test", ".");
+ check_equals(result, true);
+
+result = snd.send("lc_test", "g.");
+ check_equals(result, true);
+
result = snd.send("lc_test", "getSeconds");
-xcheck_equals (result, true);
+check_equals (result, true);
funcname = "onFullScreen";
result = snd.send("lc_test", funcname);
-xcheck_equals (result, true);
+check_equals (result, true);
rec.close();
-totals(23);
+totals(46);
#endif // OUTPUT_VERSION >= 6
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10463: Fixes to LocalConnection AS behaviour.,
Benjamin Wolsey <=