2008-05-03 Sam Weinig <sam@webkit.org>
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 May 2008 00:36:06 +0000 (00:36 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 May 2008 00:36:06 +0000 (00:36 +0000)
        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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Window/closure-access-after-navigation-iframe-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Window/closure-access-after-navigation-iframe.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/closure-access-after-navigation-window-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Window/closure-access-after-navigation-window.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/dom-access-from-closure-iframe-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Window/dom-access-from-closure-iframe.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/dom-access-from-closure-window-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Window/dom-access-from-closure-window.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-iframe-child-1.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-iframe-child-2.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-window-child-1.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-window-child-2.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/resources/dom-access-from-closure-iframe-child.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/resources/dom-access-from-closure-window-child.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/resources/notify-opener-done.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/resources/notify-parent-done.html [new file with mode: 0644]

index c292ad1..1381a85 100644 (file)
@@ -1,3 +1,29 @@
+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.
diff --git a/LayoutTests/fast/dom/Window/closure-access-after-navigation-iframe-expected.txt b/LayoutTests/fast/dom/Window/closure-access-after-navigation-iframe-expected.txt
new file mode 100644 (file)
index 0000000..53ee75a
--- /dev/null
@@ -0,0 +1,15 @@
+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
+
diff --git a/LayoutTests/fast/dom/Window/closure-access-after-navigation-iframe.html b/LayoutTests/fast/dom/Window/closure-access-after-navigation-iframe.html
new file mode 100644 (file)
index 0000000..1df4973
--- /dev/null
@@ -0,0 +1,50 @@
+<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>
diff --git a/LayoutTests/fast/dom/Window/closure-access-after-navigation-window-expected.txt b/LayoutTests/fast/dom/Window/closure-access-after-navigation-window-expected.txt
new file mode 100644 (file)
index 0000000..53ee75a
--- /dev/null
@@ -0,0 +1,15 @@
+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
+
diff --git a/LayoutTests/fast/dom/Window/closure-access-after-navigation-window.html b/LayoutTests/fast/dom/Window/closure-access-after-navigation-window.html
new file mode 100644 (file)
index 0000000..3dd9b1e
--- /dev/null
@@ -0,0 +1,54 @@
+<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>
diff --git a/LayoutTests/fast/dom/Window/dom-access-from-closure-iframe-expected.txt b/LayoutTests/fast/dom/Window/dom-access-from-closure-iframe-expected.txt
new file mode 100644 (file)
index 0000000..00841e9
--- /dev/null
@@ -0,0 +1,5 @@
+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
+
diff --git a/LayoutTests/fast/dom/Window/dom-access-from-closure-iframe.html b/LayoutTests/fast/dom/Window/dom-access-from-closure-iframe.html
new file mode 100644 (file)
index 0000000..2319ab8
--- /dev/null
@@ -0,0 +1,22 @@
+<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>
diff --git a/LayoutTests/fast/dom/Window/dom-access-from-closure-window-expected.txt b/LayoutTests/fast/dom/Window/dom-access-from-closure-window-expected.txt
new file mode 100644 (file)
index 0000000..c82af37
--- /dev/null
@@ -0,0 +1,5 @@
+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
+
diff --git a/LayoutTests/fast/dom/Window/dom-access-from-closure-window.html b/LayoutTests/fast/dom/Window/dom-access-from-closure-window.html
new file mode 100644 (file)
index 0000000..be34085
--- /dev/null
@@ -0,0 +1,25 @@
+<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>
diff --git a/LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-iframe-child-1.html b/LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-iframe-child-1.html
new file mode 100644 (file)
index 0000000..83482d4
--- /dev/null
@@ -0,0 +1,26 @@
+<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
diff --git a/LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-iframe-child-2.html b/LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-iframe-child-2.html
new file mode 100644 (file)
index 0000000..e9c301d
--- /dev/null
@@ -0,0 +1,35 @@
+<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
diff --git a/LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-window-child-1.html b/LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-window-child-1.html
new file mode 100644 (file)
index 0000000..0b867a9
--- /dev/null
@@ -0,0 +1,29 @@
+<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
diff --git a/LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-window-child-2.html b/LayoutTests/fast/dom/Window/resources/closure-access-after-navigation-window-child-2.html
new file mode 100644 (file)
index 0000000..bdfb9f8
--- /dev/null
@@ -0,0 +1,35 @@
+<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
diff --git a/LayoutTests/fast/dom/Window/resources/dom-access-from-closure-iframe-child.html b/LayoutTests/fast/dom/Window/resources/dom-access-from-closure-iframe-child.html
new file mode 100644 (file)
index 0000000..e2aa799
--- /dev/null
@@ -0,0 +1,15 @@
+<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>
diff --git a/LayoutTests/fast/dom/Window/resources/dom-access-from-closure-window-child.html b/LayoutTests/fast/dom/Window/resources/dom-access-from-closure-window-child.html
new file mode 100644 (file)
index 0000000..66fbe26
--- /dev/null
@@ -0,0 +1,15 @@
+<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>
diff --git a/LayoutTests/fast/dom/Window/resources/notify-opener-done.html b/LayoutTests/fast/dom/Window/resources/notify-opener-done.html
new file mode 100644 (file)
index 0000000..69f3116
--- /dev/null
@@ -0,0 +1,6 @@
+<script>
+    onload = function()
+    {
+        opener.done();
+    }
+</script>
diff --git a/LayoutTests/fast/dom/Window/resources/notify-parent-done.html b/LayoutTests/fast/dom/Window/resources/notify-parent-done.html
new file mode 100644 (file)
index 0000000..af240a9
--- /dev/null
@@ -0,0 +1,6 @@
+<script>
+    onload = function()
+    {
+        parent.done();
+    }
+</script>