Skip to content
Browse files

new features

  • Loading branch information...
1 parent 401a587 commit 955319b2179c183754eb69a972149ca14b63a3cb @alejandrolechuga committed Apr 22, 2012
Showing with 14 additions and 7 deletions.
  1. +13 −6 redCross.1.0.js
  2. +1 −1 tests/index.html
View
19 redCross.1.0.js
@@ -7,7 +7,7 @@
// @todo add support for browsers without postMessage functionality
// @todo set of tests
// @todo test on different browser versions
-// @todo add wildcard for domain restrictions
+// @todo add subdomain wildcard
(function (global) {
"use strict";
@@ -140,7 +140,6 @@
RedCross.message = function (client, message) {
var packet = RedCross.pack(client, message);
if (postMessage) {
- //console.log(packet);
client.window.contentWindow.postMessage(packet, "*");
}
};
@@ -158,7 +157,10 @@
if (postMessage) {
RedCross.listenPostMessageFromServer(args);
}
- server.policy = args.policy;
+
+ if (args.policy) {
+ server.policy = args.policy;
+ }
server.key = RedCross.generateKey("server");
serverStack.push(server);
return server;
@@ -175,10 +177,9 @@
RedCross.listenPostMessageFromServer = function (params) {
RedCross.onMessageListener(function (event) {
var data;
-
if (!RedCross.validatePolicy(params.policy, event.origin)) {
return;
- }
+ }
data = JSON.parse(event.data);
if (params.onMessage) {
@@ -199,7 +200,13 @@
// @param String origin
// @return Boolean
RedCross.validatePolicy = function (policies, origin) {
- var i = policies.length;
+ var i;
+ //Wildcard
+ if (policies === "*") {
+ return true;
+ }
+
+ i = policies.length;
while (i--) {
var restrictedDomain = RedCross.getDomainFromURL(policies[i]);
origin = RedCross.getDomainFromURL(origin);
View
2 tests/index.html
@@ -9,7 +9,7 @@
var client = RedCross.client({
url : "http://labs.ramonlechuga.com/redCrossTest/index.html",
ready : function () {
- console.log(client.message("Hello world"));
+ console.log(client.message("Hello world"));
},
onResponse : function (response) {
console.log("respuesta");

0 comments on commit 955319b

Please sign in to comment.
Something went wrong with that request. Please try again.