Reviewed by Dan Bernstein.
Add tests that show our behavior when using closures from a global object
whose frame has been navigated.
Related to https://bugs.webkit.org/show_bug.cgi?id=17249.
* fast/dom/Window/closure-access-after-navigation-iframe-expected.txt: Added.
* fast/dom/Window/closure-access-after-navigation-iframe.html: Added.
* fast/dom/Window/closure-access-after-navigation-window-expected.txt: Added.
* fast/dom/Window/closure-access-after-navigation-window.html: Added.
* fast/dom/Window/dom-access-from-closure-iframe-expected.txt: Added.
* fast/dom/Window/dom-access-from-closure-iframe.html: Added.
* fast/dom/Window/dom-access-from-closure-window-expected.txt: Added.
* fast/dom/Window/dom-access-from-closure-window.html: Added.
* fast/dom/Window/resources/closure-access-after-navigation-iframe-child-1.html: Added.
* fast/dom/Window/resources/closure-access-after-navigation-iframe-child-2.html: Added.
* fast/dom/Window/resources/closure-access-after-navigation-window-child-1.html: Added.
* fast/dom/Window/resources/closure-access-after-navigation-window-child-2.html: Added.
* fast/dom/Window/resources/dom-access-from-closure-iframe-child.html: Added.
* fast/dom/Window/resources/dom-access-from-closure-window-child.html: Added.
* fast/dom/Window/resources/notify-opener-done.html: Added.
* fast/dom/Window/resources/notify-parent-done.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@32845
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-05-03 Sam Weinig <sam@webkit.org>
+
+ Reviewed by Dan Bernstein.
+
+ Add tests that show our behavior when using closures from a global object
+ whose frame has been navigated.
+
+ Related to https://bugs.webkit.org/show_bug.cgi?id=17249.
+
+ * fast/dom/Window/closure-access-after-navigation-iframe-expected.txt: Added.
+ * fast/dom/Window/closure-access-after-navigation-iframe.html: Added.
+ * fast/dom/Window/closure-access-after-navigation-window-expected.txt: Added.
+ * fast/dom/Window/closure-access-after-navigation-window.html: Added.
+ * fast/dom/Window/dom-access-from-closure-iframe-expected.txt: Added.
+ * fast/dom/Window/dom-access-from-closure-iframe.html: Added.
+ * fast/dom/Window/dom-access-from-closure-window-expected.txt: Added.
+ * fast/dom/Window/dom-access-from-closure-window.html: Added.
+ * fast/dom/Window/resources/closure-access-after-navigation-iframe-child-1.html: Added.
+ * fast/dom/Window/resources/closure-access-after-navigation-iframe-child-2.html: Added.
+ * fast/dom/Window/resources/closure-access-after-navigation-window-child-1.html: Added.
+ * fast/dom/Window/resources/closure-access-after-navigation-window-child-2.html: Added.
+ * fast/dom/Window/resources/dom-access-from-closure-iframe-child.html: Added.
+ * fast/dom/Window/resources/dom-access-from-closure-window-child.html: Added.
+ * fast/dom/Window/resources/notify-opener-done.html: Added.
+ * fast/dom/Window/resources/notify-parent-done.html: Added.
+
2008-05-01 Rob Buis <buis@kde.org>
Reviewed by Eric.
--- /dev/null
+Child 1 loaded.
+Child 1 objects set.
+getObjectOfChild1().myVal = child1
+getGlobalOfChild1().myGlobalVal = child1
+Child 2 loaded.
+getObjectOfChild1().myVal = child1
+getGlobalOfChild1().myGlobalVal = child1
+Child 2 objects set.
+getObjectOfChild1().myVal = child1
+getGlobalOfChild1().myGlobalVal = child1
+getObjectOfChild2().myVal = child2
+getGlobalOfChild2().myGlobalVal = child2
+getObjectOfParent().myVal = parent
+getGlobalOfParent().myGlobalVal = parent
+
--- /dev/null
+<pre id="console"></pre>
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ var logString = "";
+ function log(s)
+ {
+ logString += s + "<br />";
+ }
+
+ function logTitle(s)
+ {
+ log("<b>" + s + "<b>");
+ }
+
+ function done()
+ {
+ document.getElementById("console").innerHTML = logString;
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+
+ Object.prototype.myVal = "parent";
+ var myGlobal = {
+ myGlobalVal: "parent"
+ };
+
+ getObjectOfParent = function()
+ {
+ return {};
+ };
+
+ getGlobalOfParent = function()
+ {
+ return myGlobal;
+ };
+
+ test = function(p, val)
+ {
+ try {
+ log(p + "()." + val + " = " + window[p]()[val]);
+ } catch(e) {
+ log(e.message);
+ }
+ };
+</script>
+<iframe src="resources/closure-access-after-navigation-iframe-child-1.html"></iframe>
--- /dev/null
+Child 1 loaded.
+Child 1 objects set.
+getObjectOfChild1().myVal = child1
+getGlobalOfChild1().myGlobalVal = child1
+Child 2 loaded.
+getObjectOfChild1().myVal = child1
+getGlobalOfChild1().myGlobalVal = child1
+Child 2 objects set.
+getObjectOfChild1().myVal = child1
+getGlobalOfChild1().myGlobalVal = child1
+getObjectOfChild2().myVal = child2
+getGlobalOfChild2().myGlobalVal = child2
+getObjectOfParent().myVal = parent
+getGlobalOfParent().myGlobalVal = parent
+
--- /dev/null
+<pre id="console"></pre>
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCanOpenWindows();
+ layoutTestController.setCloseRemainingWindowsWhenComplete();
+ layoutTestController.waitUntilDone();
+ }
+
+ var logString = "";
+ function log(s)
+ {
+ logString += s + "<br />";
+ }
+
+ function logTitle(s)
+ {
+ log("<b>" + s + "<b>");
+ }
+
+ // Open test window
+ var win = window.open("resources/closure-access-after-navigation-window-child-1.html");
+
+ function done()
+ {
+ document.getElementById("console").innerHTML = logString;
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+
+ Object.prototype.myVal = "parent";
+ var myGlobal = {
+ myGlobalVal: "parent"
+ };
+
+ getObjectOfParent = function()
+ {
+ return {};
+ };
+
+ getGlobalOfParent = function()
+ {
+ return myGlobal;
+ };
+
+ test = function(p, val)
+ {
+ try {
+ log(p + "()." + val + " = " + window[p]()[val]);
+ } catch(e) {
+ log(e.message);
+ }
+ };
+</script>
--- /dev/null
+document.URL: file:///Users/weinig/Code/webkit/OpenSource/LayoutTests/fast/dom/Window/resources/notify-parent-done.html
+window.document.URL: file:///Users/weinig/Code/webkit/OpenSource/LayoutTests/fast/dom/Window/resources/notify-parent-done.html
+name: child
+window.name: child
+
--- /dev/null
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ function log(s)
+ {
+ document.getElementById('console').appendChild(document.createTextNode(s + "\n"));
+ }
+
+ function done()
+ {
+ // Call the method injected by resources/dom-access-from-closure-iframe-child.html
+ accessFrame();
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+</script>
+<pre id="console"></pre>
+<iframe src="resources/dom-access-from-closure-iframe-child.html" name="child"></iframe>
--- /dev/null
+document.URL: file:///Users/weinig/Code/webkit/OpenSource/LayoutTests/fast/dom/Window/resources/notify-opener-done.html
+window.document.URL: file:///Users/weinig/Code/webkit/OpenSource/LayoutTests/fast/dom/Window/resources/notify-opener-done.html
+name: child
+window.name: child
+
--- /dev/null
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCanOpenWindows();
+ layoutTestController.setCloseRemainingWindowsWhenComplete();
+ layoutTestController.waitUntilDone();
+ }
+
+ var win = window.open("resources/dom-access-from-closure-window-child.html", "child");
+
+ function log(s)
+ {
+ document.getElementById('console').appendChild(document.createTextNode(s + "\n"));
+ }
+
+ function done()
+ {
+ // Call the method injected by resources/dom-access-from-closure-window-child.html
+ accessFrame();
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+</script>
+<pre id="console"></pre>
--- /dev/null
+<script>
+ parent.logTitle("Child 1 loaded.");
+
+ Object.prototype.myVal = "child1";
+ var myGlobal = {
+ myGlobalVal: "child1"
+ };
+
+ parent.logTitle("Child 1 objects set.");
+
+ parent.getObjectOfChild1 = function()
+ {
+ return {};
+ };
+
+ parent.getGlobalOfChild1 = function()
+ {
+ return myGlobal;
+ };
+
+ parent.test("getObjectOfChild1", "myVal");
+ parent.test("getGlobalOfChild1", "myGlobalVal");
+
+ window.location = "closure-access-after-navigation-iframe-child-2.html"
+</script>
+Child 1
--- /dev/null
+<script>
+ parent.logTitle("Child 2 loaded.");
+ parent.test("getObjectOfChild1", "myVal");
+ parent.test("getGlobalOfChild1", "myGlobalVal");
+
+ Object.prototype.myVal = "child2";
+ var myGlobal = {
+ myGlobalVal: "child2"
+ };
+
+ parent.logTitle("Child 2 objects set.");
+
+ parent.getObjectOfChild2 = function()
+ {
+ return {};
+ };
+
+ parent.getGlobalOfChild2 = function()
+ {
+ return myGlobal;
+ };
+
+ parent.test("getObjectOfChild1", "myVal");
+ parent.test("getGlobalOfChild1", "myGlobalVal");
+ parent.test("getObjectOfChild2", "myVal");
+ parent.test("getGlobalOfChild2", "myGlobalVal");
+ parent.test("getObjectOfParent", "myVal");
+ parent.test("getGlobalOfParent", "myGlobalVal");
+
+ onload = function()
+ {
+ parent.done();
+ }
+</script>
+Child 2
--- /dev/null
+<script>
+ onload = function()
+ {
+ opener.logTitle("Child 1 loaded.");
+
+ Object.prototype.myVal = "child1";
+ var myGlobal = {
+ myGlobalVal: "child1"
+ };
+
+ opener.logTitle("Child 1 objects set.");
+
+ opener.getObjectOfChild1 = function()
+ {
+ return {};
+ };
+
+ opener.getGlobalOfChild1 = function()
+ {
+ return myGlobal;
+ };
+
+ opener.test("getObjectOfChild1", "myVal");
+ opener.test("getGlobalOfChild1", "myGlobalVal");
+
+ window.location = "closure-access-after-navigation-window-child-2.html"
+ }
+</script>
+Child 1
--- /dev/null
+<script>
+ opener.logTitle("Child 2 loaded.");
+ opener.test("getObjectOfChild1", "myVal");
+ opener.test("getGlobalOfChild1", "myGlobalVal");
+
+ Object.prototype.myVal = "child2";
+ var myGlobal = {
+ myGlobalVal: "child2"
+ };
+
+ opener.logTitle("Child 2 objects set.");
+
+ opener.getObjectOfChild2 = function()
+ {
+ return {};
+ };
+
+ opener.getGlobalOfChild2 = function()
+ {
+ return myGlobal;
+ };
+
+ opener.test("getObjectOfChild1", "myVal");
+ opener.test("getGlobalOfChild1", "myGlobalVal");
+ opener.test("getObjectOfChild2", "myVal");
+ opener.test("getGlobalOfChild2", "myGlobalVal");
+ opener.test("getObjectOfParent", "myVal");
+ opener.test("getGlobalOfParent", "myGlobalVal");
+
+ onload = function()
+ {
+ opener.done();
+ }
+</script>
+Child 2
--- /dev/null
+<script>
+ parent.accessFrame = function()
+ {
+ try {
+ parent.log("document.URL: " + document.URL);
+ parent.log("window.document.URL: " + window.document.URL);
+ parent.log("name: " + name);
+ parent.log("window.name: " + window.name);
+ } catch (e) {
+ parent.log("An exception was thrown: " + e.message);
+ }
+ }
+
+ window.location = "notify-parent-done.html";
+</script>
--- /dev/null
+<script>
+ opener.accessFrame = function()
+ {
+ try {
+ opener.log("document.URL: " + document.URL);
+ opener.log("window.document.URL: " + window.document.URL);
+ opener.log("name: " + name);
+ opener.log("window.name: " + window.name);
+ } catch (e) {
+ opener.log("An exception was thrown: " + e.message);
+ }
+ }
+
+ window.location = "notify-opener-done.html";
+</script>
--- /dev/null
+<script>
+ onload = function()
+ {
+ opener.done();
+ }
+</script>
--- /dev/null
+<script>
+ onload = function()
+ {
+ parent.done();
+ }
+</script>