javascript - Can I compare the source window from postMessage to my window.frames? -



javascript - Can I compare the source window from postMessage to my window.frames? -

i want bubble info frame parent object (information isn't accessible due xss).

can compare source window sent via postmessage values of window.frames?

mdn (in link above) says message can used postmessage doesn't refer testing equality.

this works correctly on ie9 ff5 , chrome12 want know if dependable (i.e. in standard).

test code:

postmessageouter.html

<!doctype html> <html> <head> <title>outer page</title> <script type="text/javascript"> window.addeventlistener("message", function (event) { (var = 0; < frames.length; ++i) if (event.source == frames[i]) alert(i); }, false); </script> </head> <body> <iframe src="postmessageinner.html"></iframe> <iframe src="postmessageinner.html"></iframe> <iframe src="postmessageinner.html"></iframe> </body> </html>

postmessageinner.html

<!doctype html> <html> <head> <title>inner page</title> <script type="text/javascript"> function foo() { window.parent.postmessage("hello", "*"); } </script> </head> <body> <input type="button" value="x" onclick="foo()" /> </body> </html>

postmessage part of html5 draft , supported in newest browsers.

the spec says

the source attribute must set script's global object's windowproxy object

this windowproxy value of window.frame enumeration, too.

http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossdocumentmessages

javascript html5 xss postmessage

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -