Modified: trunk/LayoutTests/ChangeLog (106515 => 106516)
--- trunk/LayoutTests/ChangeLog 2012-02-02 00:20:36 UTC (rev 106515)
+++ trunk/LayoutTests/ChangeLog 2012-02-02 01:39:55 UTC (rev 106516)
@@ -1,3 +1,13 @@
+2012-02-01 Pablo Flouret <pab...@motorola.com>
+
+ Support targetOrigin = "/" in postMessage for sending messages to same origin as source document.
+ https://bugs.webkit.org/show_bug.cgi?id=77580
+
+ Reviewed by Adam Barth.
+
+ * http/tests/security/postMessage/target-origin-expected.txt:
+ * http/tests/security/postMessage/target-origin.html:
+
2012-02-01 Gavin Barraclough <barraclo...@apple.com>
calling function on catch block scope containing an eval result in wrong this value being passed
Modified: trunk/LayoutTests/http/tests/security/postMessage/target-origin-expected.txt (106515 => 106516)
--- trunk/LayoutTests/http/tests/security/postMessage/target-origin-expected.txt 2012-02-02 00:20:36 UTC (rev 106515)
+++ trunk/LayoutTests/http/tests/security/postMessage/target-origin-expected.txt 2012-02-02 01:39:55 UTC (rev 106516)
@@ -1,3 +1,5 @@
+CONSOLE MESSAGE: Unable to post message to http://127.0.0.1:8000. Recipient has origin http://localhost:8000.
+
CONSOLE MESSAGE: Unable to post message to http://localhost:9090. Recipient has origin http://localhost:8000.
CONSOLE MESSAGE: Unable to post message to http://localhost. Recipient has origin http://localhost:8000.
@@ -13,6 +15,7 @@
waiting...
Error sending message to null. Error: SYNTAX_ERR: DOM Exception 12
Error sending message to undefined. Error: SYNTAX_ERR: DOM Exception 12
+Error sending message to //. Error: SYNTAX_ERR: DOM Exception 12
Received message: data="" message: data="" origin=http://localhost:8000" origin="http://127.0.0.1:8000"" origin="http://localhost:8000"
Received message: data="" message: data="" origin=http://localhost:8000/" origin="http://127.0.0.1:8000"" origin="http://localhost:8000"
Received message: data="" message: data="" origin=http://localhost:8000/foo" origin="http://127.0.0.1:8000"" origin="http://localhost:8000"
@@ -20,4 +23,5 @@
Received message: data="" message: data="" origin=http://localhost:8000/foo?bar#baz" origin="http://127.0.0.1:8000"" origin="http://localhost:8000"
Received message: data="" message: data="" origin=http://user:pass@localhost:8000/foo?bar#baz" origin="http://127.0.0.1:8000"" origin="http://localhost:8000"
Received message: data="" message: data="" origin=*" origin="http://127.0.0.1:8000"" origin="http://localhost:8000"
+Received message: data="" message: data="" origin=/" origin="http://127.0.0.1:8000"" origin="http://127.0.0.1:8000"
Received message: data="" message: data="" origin="http://127.0.0.1:8000"" origin="http://localhost:8000"
Modified: trunk/LayoutTests/http/tests/security/postMessage/target-origin.html (106515 => 106516)
--- trunk/LayoutTests/http/tests/security/postMessage/target-origin.html 2012-02-02 00:20:36 UTC (rev 106515)
+++ trunk/LayoutTests/http/tests/security/postMessage/target-origin.html 2012-02-02 01:39:55 UTC (rev 106516)
@@ -19,37 +19,41 @@
}
function test() {
- var iframe = document.getElementById('child');
- var win = iframe.contentWindow;
+ var winLocalhost = document.getElementById('iframe-localhost').contentWindow;
+ var win127= document.getElementById('iframe-127').contentWindow;
// Should succeed:
- tryPostMessage(win, "http://localhost:8000");
- tryPostMessage(win, "http://localhost:8000/");
- tryPostMessage(win, "http://localhost:8000/foo");
- tryPostMessage(win, "http://localhost:8000/foo?bar");
- tryPostMessage(win, "http://localhost:8000/foo?bar#baz");
- tryPostMessage(win, "http://user:pass@localhost:8000/foo?bar#baz");
- tryPostMessage(win, "*");
+ tryPostMessage(winLocalhost, "http://localhost:8000");
+ tryPostMessage(winLocalhost, "http://localhost:8000/");
+ tryPostMessage(winLocalhost, "http://localhost:8000/foo");
+ tryPostMessage(winLocalhost, "http://localhost:8000/foo?bar");
+ tryPostMessage(winLocalhost, "http://localhost:8000/foo?bar#baz");
+ tryPostMessage(winLocalhost, "http://user:pass@localhost:8000/foo?bar#baz");
+ tryPostMessage(winLocalhost, "*");
+ tryPostMessage(win127, "/");
// Should fail:
- tryPostMessage(win, "http://localhost:9090");
- tryPostMessage(win, "http://localhost");
- tryPostMessage(win, "https://localhost");
- tryPostMessage(win, "https://localhost:8000");
- tryPostMessage(win, "http://www.example.com");
+ tryPostMessage(winLocalhost, "/");
+ tryPostMessage(winLocalhost, "http://localhost:9090");
+ tryPostMessage(winLocalhost, "http://localhost");
+ tryPostMessage(winLocalhost, "https://localhost");
+ tryPostMessage(winLocalhost, "https://localhost:8000");
+ tryPostMessage(winLocalhost, "http://www.example.com");
// Should throw syntax error:
- tryPostMessage(win, null);
- tryPostMessage(win, undefined);
+ tryPostMessage(winLocalhost, null);
+ tryPostMessage(winLocalhost, undefined);
+ tryPostMessage(win127, "//");
- win.postMessage('done', '*');
+ winLocalhost.postMessage('done', '*');
}
</script>
<body _onload_="test()">
<div>window.location.href = ""
<div><iframe src=""
- id="child" width="800" height="300" style="border: 1px solid black;">
-</iframe></div>
+ id="iframe-localhost" width="800" height="300" style="border: 1px solid black;">
+</iframe><iframe src=""
+ id="iframe-127" width="800" height="300" style="border: 1px solid black;"></iframe>
<div id="result">waiting...</div>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (106515 => 106516)
--- trunk/Source/WebCore/ChangeLog 2012-02-02 00:20:36 UTC (rev 106515)
+++ trunk/Source/WebCore/ChangeLog 2012-02-02 01:39:55 UTC (rev 106516)
@@ -1,3 +1,16 @@
+2012-02-01 Pablo Flouret <pab...@motorola.com>
+
+ Support targetOrigin = "/" in postMessage for sending messages to same origin as source document.
+ https://bugs.webkit.org/show_bug.cgi?id=77580
+
+ Reviewed by Adam Barth.
+
+ No new tests. Modified http/tests/security/postMessage/target-origin.html
+ to test this case as well.
+
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::postMessage):
+
2012-02-01 Caio Marcelo de Oliveira Filho <caio.olive...@openbossa.org>
Avoid creating NamedNodeMap unnecessarily
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (106515 => 106516)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2012-02-02 00:20:36 UTC (rev 106515)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2012-02-02 01:39:55 UTC (rev 106516)
@@ -826,10 +826,16 @@
if (!isCurrentlyDisplayedInFrame())
return;
+ Document* sourceDocument = source->document();
+
// Compute the target origin. We need to do this synchronously in order
// to generate the SYNTAX_ERR exception correctly.
RefPtr<SecurityOrigin> target;
- if (targetOrigin != "*") {
+ if (targetOrigin == "/") {
+ if (!sourceDocument)
+ return;
+ target = sourceDocument->securityOrigin();
+ } else if (targetOrigin != "*") {
target = SecurityOrigin::createFromString(targetOrigin);
// It doesn't make sense target a postMessage at a unique origin
// because there's no way to represent a unique origin in a string.
@@ -845,7 +851,6 @@
// Capture the source of the message. We need to do this synchronously
// in order to capture the source of the message correctly.
- Document* sourceDocument = source->document();
if (!sourceDocument)
return;
String sourceOrigin = sourceDocument->securityOrigin()->toString();