Initial test suite for plugins
Change-Id: Ibc5c52ea1fd69481e02486db2ff7fb4c5afa8b99
diff --git a/dev/js/src/plugin/client.js b/dev/js/src/plugin/client.js
index 64f0bc4..4e7e337 100644
--- a/dev/js/src/plugin/client.js
+++ b/dev/js/src/plugin/client.js
@@ -50,8 +50,6 @@
// Send a message
_sendMsg : function (data) {
data["originID"] = this.widgetID;
-
- // TODO: This should send a correct origin
window.parent.postMessage(data, this.server);
},
diff --git a/dev/js/src/plugin/server.js b/dev/js/src/plugin/server.js
index 7dd0fce..82a4193 100644
--- a/dev/js/src/plugin/server.js
+++ b/dev/js/src/plugin/server.js
@@ -48,9 +48,8 @@
// only in case there is a widget
var that = this;
- window.addEventListener("message", function (e) {
- that._receiveMsg(e);
- });
+ this._listener = this._receiveMsg.bind(that);
+ window.addEventListener("message", this._listener);
// Every second increase the limits of all registered widgets
var myTimer = setInterval(function () {
@@ -82,6 +81,8 @@
element.appendChild(
widget.element()
);
+
+ return id;
},
// Receive a call from an embedded iframe.
@@ -140,6 +141,13 @@
// Get a random identifier
_randomID : function () {
return randomID(20);
+ },
+
+ // Destructor, just for testing scenarios
+ destroy : function () {
+ limits = {};
+ widgets = {};
+ window.removeEventListener("message", this._listener);
}
}
});