+2008-01-30 Samuel Weinig <sam@webkit.org>
+
+ Reviewed by Darin Adler.
+
+ Tests for <rdar://problem/5708993> Mutability of the History object
+
+ * http/tests/security/cross-frame-access-enumeration-expected.txt:
+ * http/tests/security/cross-frame-access-enumeration.html:
+ * http/tests/security/cross-frame-access-history-expected.txt: Removed.
+ * http/tests/security/cross-frame-access-history-get-expected.txt: Renamed from LayoutTests/http/tests/security/cross-frame-access-history-expected.txt.
+ * http/tests/security/cross-frame-access-history-get-override-expected.txt: Added.
+ * http/tests/security/cross-frame-access-history-get-override.html: Added.
+ * http/tests/security/cross-frame-access-history-get.html: Renamed from LayoutTests/http/tests/security/cross-frame-access-history.html.
+ * http/tests/security/cross-frame-access-history-put-expected.txt: Added.
+ * http/tests/security/cross-frame-access-history-put.html: Added.
+ * http/tests/security/cross-frame-access-history.html: Removed.
+ * http/tests/security/resources/cross-frame-access.js:
+ * http/tests/security/resources/cross-frame-iframe-for-enumeration-test.html:
+ * http/tests/security/resources/cross-frame-iframe-for-history-get-override-test.html: Added.
+ * http/tests/security/resources/cross-frame-iframe-for-history-get-test.html: Added.
+ * http/tests/security/resources/cross-frame-iframe-for-history-put-test.html: Added.
+
2008-01-31 Dan Bernstein <mitz@apple.com>
Reviewed by Dave Hyatt.
CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-enumeration-test from frame with URL http://127.0.0.1:8000/security/cross-frame-access-enumeration.html. Domains, protocols and ports must match.
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-enumeration-test from frame with URL http://127.0.0.1:8000/security/cross-frame-access-enumeration.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-enumeration-test from frame with URL http://127.0.0.1:8000/security/cross-frame-access-enumeration.html. Domains, protocols and ports must match.
+
This tests that variable names can't be enumerated cross domain (see http://bugs.webkit.org/show_bug.cgi?id=16387)
PASS: Cross frame access by enumerating the window object was denied.
+PASS: Cross frame access by enumerating the History object was denied.
+PASS: Cross frame access by enumerating the Location object was denied.
runTest = function()
{
+ // Test enumerating the Window object
var b_win = document.getElementsByTagName("iframe")[0].contentWindow;
try {
for (var k in b_win) {
- if (k == "customProperty") {
+ if (k == "customWindowProperty") {
log("FAIL: Cross frame access by enumerating the window object was allowed.");
return;
}
} catch (e) {
}
log("PASS: Cross frame access by enumerating the window object was denied.");
+
+ // Test enumerating the History object
+ var b_win_history = b_win.history;
+ try {
+ for (var k in b_win_history) {
+ if (k == "customHistoryProperty") {
+ log("FAIL: Cross frame access by enumerating the History object was allowed.");
+ return;
+ }
+ }
+ } catch (e) {
+ }
+ log("PASS: Cross frame access by enumerating the History object was denied.");
+
+ // Test enumerating the Location object
+ var b_win_location = b_win.location;
+ try {
+ for (var k in b_win_location) {
+ if (k == "customLocationProperty") {
+ log("FAIL: Cross frame access by enumerating the Location object was allowed.");
+ return;
+ }
+ }
+ } catch (e) {
+ }
+ log("PASS: Cross frame access by enumerating the Location object was denied.");
}
</script>
</head>
+++ /dev/null
-
-
------ tests for getting/setting window.history and its properties -----
-
-Firefox prohibits getting 'history.length' but that seems unnecessarily strict since you're allowed to use the 'history' object.
-PASS: canGet('targetWindow.history.length') should be 'true' and is.
-PASS: canGet('targetWindow.history.back') should be 'true' and is.
-PASS: canGet('targetWindow.history.forward') should be 'true' and is.
-PASS: canGet('targetWindow.history.go') should be 'true' and is.
-PASS: canGet('targetWindow.history.toString') should be 'true' and is.
-PASS: toString('targetWindow.history') should be '[object History]' and is.
-
--- /dev/null
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-get.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-get.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-get.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-get.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-get.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-get.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-get.html. Domains, protocols and ports must match.
+
+
+
+----- tests for getting window.history and its properties -----
+
+PASS: canGet('targetWindow.history.length') should be 'false' and is.
+PASS: canGet('targetWindow.history.back') should be 'true' and is.
+PASS: canGet('targetWindow.history.forward') should be 'true' and is.
+PASS: canGet('targetWindow.history.go') should be 'true' and is.
+PASS: canGet('targetWindow.history.toString') should be 'true' and is.
+PASS: toString('targetWindow.history') should be '[object History]' and is.
+PASS: canGet('targetWindow.__proto__') should be 'false' and is.
+PASS: canGet('targetWindow.constructor') should be 'false' and is.
+PASS: canGet('targetWindow.history.existingCustomProperty') should be 'false' and is.
+PASS: canGet('targetWindow.history.__proto__.prototypeCustomProperty') should be 'false' and is.
+PASS: canCall('targetWindow.history.existingCustomFunction') should be 'false' and is.
+PASS: canCall('targetWindow.history.prototypeCustomFunction') should be 'false' and is.
+
--- /dev/null
+
+----- tests for getting custorm overrides of window.history's functions -----
+
+PASS: canGet('targetWindow.history.back') should be 'true' and is.
+PASS: toString('targetWindow.history.back') should be 'function () { return "new back";}' and is.
+PASS: canGet('targetWindow.history.forward') should be 'true' and is.
+PASS: toString('targetWindow.history.forward') should be 'function () { return "new forward";}' and is.
+PASS: canGet('targetWindow.history.go') should be 'true' and is.
+PASS: toString('targetWindow.history.go') should be 'new go' and is.
+
--- /dev/null
+<html>
+<head>
+ <script src="resources/cross-frame-access.js"></script>
+ <script>
+ window.onload = function()
+ {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ if (window.layoutTestController) {
+ setTimeout(pollForTest, 1);
+ } else {
+ log("To run the test, click the button below when the opened window finishes loading.");
+ var button = document.createElement("button");
+ button.appendChild(document.createTextNode("Run Test"));
+ button.onclick = runTest;
+ document.body.appendChild(button);
+ }
+ }
+
+ pollForTest = function()
+ {
+ if (!layoutTestController.globalFlag) {
+ setTimeout(pollForTest, 1);
+ return;
+ }
+ runTest();
+ layoutTestController.notifyDone();
+ }
+
+ runTest = function()
+ {
+ window.targetWindow = frames[0];
+
+ log("----- tests for getting custorm overrides of window.history's functions -----\n");
+
+ // Overriden using window.history.back = function() { return "new back" }
+ newBack = function() { return "new back"; }
+ shouldBeTrue("canGet('targetWindow.history.back')");
+ shouldBe("toString('targetWindow.history.back')", "toString(newBack)");
+
+ // Overriden using window.history.__proto__.forward = function() { return "new forward;" }
+ newForward = function() { return "new forward"; }
+ shouldBeTrue("canGet('targetWindow.history.forward')");
+ shouldBe("toString('targetWindow.history.forward')", "toString(newForward)");
+
+ // Overriden using window.history.go = "new go"
+ shouldBeTrue("canGet('targetWindow.history.go')");
+ shouldBe("toString('targetWindow.history.go')", "'new go'");
+ }
+ </script>
+</head>
+<body>
+<iframe src="http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-override-test.html"></iframe>
+<pre id="console"></pre>
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+ <script src="resources/cross-frame-access.js"></script>
+ <script>
+ window.onload = function()
+ {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ if (window.layoutTestController) {
+ setTimeout(pollForTest, 1);
+ } else {
+ log("To run the test, click the button below when the opened window finishes loading.");
+ var button = document.createElement("button");
+ button.appendChild(document.createTextNode("Run Test"));
+ button.onclick = runTest;
+ document.body.appendChild(button);
+ }
+ }
+
+ pollForTest = function()
+ {
+ if (!layoutTestController.globalFlag) {
+ setTimeout(pollForTest, 1);
+ return;
+ }
+ runTest();
+ layoutTestController.notifyDone();
+ }
+
+ runTest = function()
+ {
+ window.targetWindow = frames[0];
+
+ log("\n----- tests for getting window.history and its properties -----\n");
+
+ // history object
+ shouldBeFalse("canGet('targetWindow.history.length')");
+
+ shouldBeTrue("canGet('targetWindow.history.back')");
+ shouldBeTrue("canGet('targetWindow.history.forward')");
+ shouldBeTrue("canGet('targetWindow.history.go')");
+
+ // FIXME: Calling these currently cause the subsequent test to include a dump of this test's render tree.
+ // (see http://bugs.webkit.org/show_bug.cgi?id=16510)
+ // shouldBeTrue("canCall('targetWindow.history.back')");
+ // shouldBeTrue("canCall('targetWindow.history.forward')");
+ // shouldBeTrue("canCall('targetWindow.history.go', '-1')");
+
+ shouldBeTrue("canGet('targetWindow.history.toString')");
+ shouldBe("toString('targetWindow.history')", "'[object History]'");
+
+ shouldBeFalse("canGet('targetWindow.__proto__')");
+ shouldBeFalse("canGet('targetWindow.constructor')");
+
+ // Check custom properties
+ shouldBeFalse("canGet('targetWindow.history.existingCustomProperty')");
+ shouldBeFalse("canGet('targetWindow.history.__proto__.prototypeCustomProperty')");
+ shouldBeFalse("canCall('targetWindow.history.existingCustomFunction')");
+ shouldBeFalse("canCall('targetWindow.history.prototypeCustomFunction')");
+ }
+ </script>
+</head>
+<body>
+<iframe src="http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-test.html"></iframe>
+<pre id="console"></pre>
+</body>
+</html>
--- /dev/null
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-put-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-put.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-put-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-put.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-put-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-put.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-put-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-put.html. Domains, protocols and ports must match.
+
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-history-put-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-history-put.html. Domains, protocols and ports must match.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
+----- tests for putting window.history and its properties -----
+
+PASS: window.history.back should be 'function back() { [native code]}' and is.
+PASS: window.history.forward should be 'function forward() { [native code]}' and is.
+PASS: window.history.go should be 'function go() { [native code]}' and is.
+PASS: window.history.toString should be 'function toString() { [native code]}' and is.
+PASS: window.history.length matched the expected value.
+
--- /dev/null
+<html>
+<head>
+ <script>
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.dumpChildFramesAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ receiver = function(e)
+ {
+ if (e.data == "storedOldValuesComplete")
+ setTest();
+ }
+ document.addEventListener('message', receiver, false);
+
+ setTest = function()
+ {
+ window.targetWindow = frames[0];
+
+ targetWindow.history.back = "FAIL!! CUSTOM back";
+ targetWindow.history.forward = "FAIL!! CUSTOM forward";
+ targetWindow.history.go = "FAIL!! CUSTOM go";
+ targetWindow.history.toString = "FAIL!! CUSTOM toString";
+ targetWindow.history.length = "FAIL!! CUSTOM length";
+
+ targetWindow.postMessage("settingValuesComplete");
+ }
+ </script>
+</head>
+<body>
+<iframe src="http://localhost:8000/security/resources/cross-frame-iframe-for-history-put-test.html"></iframe>
+</body>
+</html>
+++ /dev/null
-<html>
-<head>
- <script src="resources/cross-frame-access.js"></script>
-</head>
-<body>
-<iframe src="http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html" style=""></iframe>
-<pre id="console"></pre>
-<script>
-
-window.targetWindow = frames[0];
-
-window.onload = function()
-{
- if (window.layoutTestController)
- layoutTestController.dumpAsText();
-
- log("\n----- tests for getting/setting window.history and its properties -----\n");
-
- // history object
- log("Firefox prohibits getting 'history.length' but that seems unnecessarily strict since you're allowed to use the 'history' object.");
- shouldBeTrue("canGet('targetWindow.history.length')");
-
- shouldBeTrue("canGet('targetWindow.history.back')");
- shouldBeTrue("canGet('targetWindow.history.forward')");
- shouldBeTrue("canGet('targetWindow.history.go')");
-
- // FIXME: Calling these currently cause the subsequent test to include a dump of this test's render tree.
- // (see http://bugs.webkit.org/show_bug.cgi?id=16510)
- // shouldBeTrue("canCall('targetWindow.history.back')");
- // shouldBeTrue("canCall('targetWindow.history.forward')");
- // shouldBeTrue("canCall('targetWindow.history.go', '-1')");
-
- shouldBeTrue("canGet('targetWindow.history.toString')");
- shouldBe("toString('targetWindow.history')", "'[object History]'");
-
- // Work around DRT bug that causes subsequent tests to fail.
- window.stop();
-}
-</script>
-</body>
-</html>
document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
}
-function shouldBe(a, b)
+function shouldBe(a, b, shouldNotPrintValues)
{
var evalA, evalB;
try {
evalA = e;
}
- var message = (evalA === evalB)
- ? "PASS: " + a + " should be '" + evalB + "' and is."
- : "*** FAIL: " + a + " should be '" + evalB + "' but instead is " + evalA + ". ***";
+ var message;
+ if (evalA === evalB) {
+ message = "PASS";
+ if (!shouldNotPrintValues) {
+ message += ": " + a + " should be '" + evalB + "' and is.";
+ } else {
+ message += ": " + a + " matched the expected value.";
+ }
+ } else {
+ message = "*** FAIL: " + a + " should be '" + evalB + "' but instead is " + evalA + ". ***";
+ }
+
+ message = String(message).replace(/\n/g, "");
log(message);
}
<script>
- window.customProperty = 1;
+ window.customWindowProperty = 1;
+ window.history.customHistoryProperty = 1;
+ window.location.customLocationProperty = 1;
window.onload = function()
{
--- /dev/null
+<html>
+<head>
+ <script>
+
+ window.history.back = function() { return "new back"; }
+ window.history.__proto__.forward = function() { return "new forward"; }
+ window.history.go = "new go";
+
+ window.onload = function()
+ {
+ if (window.layoutTestController)
+ layoutTestController.globalFlag = true;
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+ <script>
+ window.history.existingCustomProperty = 1;
+ window.history.__proto__.prototypeCustomProperty = 1;
+
+ window.onload = function()
+ {
+ if (window.layoutTestController)
+ layoutTestController.globalFlag = true;
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+ <script src="cross-frame-access.js"></script>
+ <script>
+ var backOld;
+ var forwardOld;
+ var goOld;
+ var toStringOld;
+ var lengthOld;
+
+ receiver = function(e)
+ {
+ if (e.data == "settingValuesComplete")
+ setCheck();
+ }
+ document.addEventListener('message', receiver, false);
+
+ window.onload = function()
+ {
+ backOld = window.history.back;
+ forwardOld = window.history.forward;
+ goOld = window.history.go;
+ toStringOld = window.history.toString;
+ lengthOld = window.history.length;
+
+ window.parent.postMessage("storedOldValuesComplete");
+ }
+
+ setCheck = function()
+ {
+ log("\n----- tests for putting window.history and its properties -----\n");
+
+ shouldBe("window.history.back", "backOld");
+ shouldBe("window.history.forward", "forwardOld");
+ shouldBe("window.history.go", "goOld");
+ shouldBe("window.history.toString", "toStringOld");
+ shouldBe("window.history.length", "lengthOld", true);
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+ </script>
+</head>
+<body>
+ <pre id="console"></pre>
+</body>
+</html>
+2008-01-30 Samuel Weinig <sam@webkit.org>
+
+ Reviewed by Darin Adler.
+
+ Fix for <rdar://problem/5708993> Mutability of the History object
+
+ - Don't allow cross-domain get access to any of the history objects properties
+ except the back(), forward() and go() methods.
+ - Don't allow cross-domain put access to any of the history objects properties.
+ - Don't allow cross-domain enumeration of the History or Location objects.
+
+ Tests: http/tests/security/cross-frame-access-history-get-override.html
+ http/tests/security/cross-frame-access-history-get.html
+ http/tests/security/cross-frame-access-history-put.html
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSDOMWindowCustom.cpp: Remove unnessary KJS::'s
+ (WebCore::JSDOMWindow::customGetOwnPropertySlot):
+ (WebCore::JSDOMWindow::customPut):
+ (WebCore::JSDOMWindow::getPropertyNames): Moved implementation from KJS::Window now that the declaration is autogenerated
+ using the new CustomGetPropertyNames.
+ (WebCore::JSDOMWindow::postMessage):
+
+ * bindings/js/JSHistoryCustom.cpp: Added.
+ (WebCore::allowsAccessFromFrame):
+ (WebCore::JSHistory::customGetOwnPropertySlot): Only allow getting the declared functions back(), forward() and go() from cross-domain.
+ Deny all other gets.
+ (WebCore::JSHistory::customPut): Don't allow putting cross-domain.
+ (WebCore::JSHistory::getPropertyNames): Don't allow enumeration cross-domain.
+
+ * bindings/js/JSLocation.cpp:
+ (WebCore::allowsAccessFromFrame):
+ (WebCore::JSLocation::getPropertyNames): Don't allow enumeration cross-domain.
+ * bindings/js/JSLocation.h:
+
+ * bindings/js/kjs_window.cpp:
+ * bindings/js/kjs_window.h:
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ Add support for new CustomGetPropertNames extended attribute and changed the logic of CustomPutFunction
+ to create an overrided put() function even if no read-write properties exist.
+
+ * page/DOMWindow.idl: Added CustomGetPropertNames
+ * page/History.idl: Added CustomGetPropertNames
+
2008-01-30 Justin Garcia <justin.garcia@apple.com>
Reviewed by Darin Adler.
BCE0139B0C0BEF180043860A /* JSStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE013990C0BEF180043860A /* JSStyleSheet.h */; };
BCE3BEC20D222B1D007E06E4 /* TagNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE3BEC00D222B1D007E06E4 /* TagNodeList.cpp */; };
BCE3BEC30D222B1D007E06E4 /* TagNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE3BEC10D222B1D007E06E4 /* TagNodeList.h */; };
+ BCE7B1930D4E86960075A539 /* JSHistoryCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */; };
BCEA478F097CAAC80094C9E4 /* CSSComputedStyleDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA477C097CAAC80094C9E4 /* CSSComputedStyleDeclaration.cpp */; };
BCEA4790097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA477D097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h */; };
BCEA4852097D93020094C9E4 /* bidi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4813097D93020094C9E4 /* bidi.cpp */; };
BCE013990C0BEF180043860A /* JSStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSStyleSheet.h; sourceTree = "<group>"; };
BCE3BEC00D222B1D007E06E4 /* TagNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagNodeList.cpp; sourceTree = "<group>"; };
BCE3BEC10D222B1D007E06E4 /* TagNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagNodeList.h; sourceTree = "<group>"; };
+ BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHistoryCustom.cpp; sourceTree = "<group>"; };
BCEA477C097CAAC80094C9E4 /* CSSComputedStyleDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSSComputedStyleDeclaration.cpp; sourceTree = "<group>"; };
BCEA477D097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSSComputedStyleDeclaration.h; sourceTree = "<group>"; };
BCEA477E097CAAC80094C9E4 /* CSSGrammar.y */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.yacc; path = CSSGrammar.y; sourceTree = "<group>"; };
BCD9C25E0C17AA67005C90A2 /* JSDOMWindowCustom.cpp */,
BC2ED5540C6B9BD300920BFF /* JSElementCustom.cpp */,
BCEFAF4D0C317E6900FA81F6 /* JSEventCustom.cpp */,
+ BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */,
BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */,
BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */,
BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */,
ABFE7E120D32FAF60066F4D2 /* MediaControlElements.cpp in Sources */,
B237C8A70D344D110013F707 /* SVGFontData.cpp in Sources */,
E4EEFFC80D34550C00469A58 /* JSAudioConstructor.cpp in Sources */,
+ BCE7B1930D4E86960075A539 /* JSHistoryCustom.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/*
- * Copyright (C) 2007 Apple, Inc.
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#include "kjs/object.h"
#include "kjs/value.h"
+using namespace KJS;
+
namespace WebCore {
-bool JSDOMWindow::customGetOwnPropertySlot(KJS::ExecState* exec, const KJS::Identifier& propertyName, KJS::PropertySlot& slot)
+bool JSDOMWindow::customGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
// we don't want any properties other than "closed" on a closed window
if (!impl()->frame()) {
if (propertyName == "closed") {
- const KJS::HashEntry* entry = KJS::Lookup::findEntry(classInfo()->propHashTable, propertyName);
+ const HashEntry* entry = Lookup::findEntry(classInfo()->propHashTable, propertyName);
ASSERT(entry);
if (entry) {
- slot.setStaticEntry(this, entry, KJS::staticValueGetter<JSDOMWindow>);
+ slot.setStaticEntry(this, entry, staticValueGetter<JSDOMWindow>);
return true;
}
}
if (propertyName == "close") {
- KJS::JSValue* proto = prototype();
+ JSValue* proto = prototype();
if (proto->isObject()) {
- const KJS::HashEntry* entry = KJS::Lookup::findEntry(static_cast<KJS::JSObject*>(proto)->classInfo()->propHashTable, propertyName);
+ const HashEntry* entry = Lookup::findEntry(static_cast<JSObject*>(proto)->classInfo()->propHashTable, propertyName);
ASSERT(entry);
if (entry) {
- slot.setStaticEntry(this, entry, KJS::staticFunctionGetter);
+ slot.setStaticEntry(this, entry, staticFunctionGetter);
return true;
}
}
// FIXME: We need this to work around the blanket same origin (allowsAccessFrom) check in KJS::Window. Once we remove that, we
// can move this to JSDOMWindowPrototype.
- KJS::JSValue* proto = prototype();
+ JSValue* proto = prototype();
if (proto->isObject()) {
- const KJS::HashEntry* entry = KJS::Lookup::findEntry(static_cast<KJS::JSObject*>(proto)->classInfo()->propHashTable, propertyName);
+ const HashEntry* entry = Lookup::findEntry(static_cast<JSObject*>(proto)->classInfo()->propHashTable, propertyName);
if (entry) {
- if (entry->attr & KJS::Function) {
+ if (entry->attr & Function) {
if (entry->value.functionValue == jsDOMWindowPrototypeFunctionFocus
|| entry->value.functionValue == jsDOMWindowPrototypeFunctionBlur
|| entry->value.functionValue == jsDOMWindowPrototypeFunctionClose
|| entry->value.functionValue == jsDOMWindowPrototypeFunctionPostMessage)
- slot.setStaticEntry(this, entry, KJS::staticFunctionGetter);
+ slot.setStaticEntry(this, entry, staticFunctionGetter);
else {
if (!allowsAccessFrom(exec))
slot.setUndefined(this);
else
- slot.setStaticEntry(this, entry, KJS::staticFunctionGetter);
+ slot.setStaticEntry(this, entry, staticFunctionGetter);
}
return true;
}
return false;
}
-bool JSDOMWindow::customPut(KJS::ExecState* exec, const KJS::Identifier& propertyName, KJS::JSValue* value, int attr)
+bool JSDOMWindow::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
if (!impl()->frame())
return true;
// Called by an internal KJS, save time and jump directly to JSGlobalObject.
- if (attr != KJS::None && attr != KJS::DontDelete) {
- KJS::JSGlobalObject::put(exec, propertyName, value, attr);
+ if (attr != None && attr != DontDelete) {
+ JSGlobalObject::put(exec, propertyName, value, attr);
return true;
}
// We have a local override (e.g. "var location"), save time and jump directly to JSGlobalObject.
- KJS::PropertySlot slot;
- if (KJS::JSGlobalObject::getOwnPropertySlot(exec, propertyName, slot)) {
+ PropertySlot slot;
+ if (JSGlobalObject::getOwnPropertySlot(exec, propertyName, slot)) {
if (allowsAccessFrom(exec))
- KJS::JSGlobalObject::put(exec, propertyName, value, attr);
+ JSGlobalObject::put(exec, propertyName, value, attr);
return true;
}
return false;
}
-KJS::JSValue* JSDOMWindow::postMessage(KJS::ExecState* exec, const KJS::List& args)
+void JSDOMWindow::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
+{
+ // Only allow the window to enumerated by frames in the same origin.
+ if (!allowsAccessFrom(exec))
+ return;
+ Base::getPropertyNames(exec, propertyNames);
+}
+
+JSValue* JSDOMWindow::postMessage(ExecState* exec, const List& args)
{
DOMWindow* window = impl();
String message = args[0]->toString(exec);
if (exec->hadException())
- return KJS::jsUndefined();
+ return jsUndefined();
window->postMessage(message, domain, uri, source);
- return KJS::jsUndefined();
+ return jsUndefined();
}
} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSHistory.h"
+
+#include "Frame.h"
+#include "History.h"
+#include "kjs_window.h"
+
+using namespace KJS;
+
+namespace WebCore {
+
+static bool allowsAccessFromFrame(ExecState* exec, Frame* frame)
+{
+ if (!frame)
+ return false;
+ Window* win = Window::retrieveWindow(frame);
+ return win && win->allowsAccessFrom(exec);
+}
+
+bool JSHistory::customGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+{
+ // Allow access to back(), forward() and go() from any frame.
+ JSValue* proto = prototype();
+ if (proto->isObject()) {
+ const HashEntry* entry = Lookup::findEntry(static_cast<JSObject*>(proto)->classInfo()->propHashTable, propertyName);
+ if (entry && entry->attr & Function) {
+ if (entry->value.functionValue == jsHistoryPrototypeFunctionBack
+ || entry->value.functionValue == jsHistoryPrototypeFunctionForward
+ || entry->value.functionValue == jsHistoryPrototypeFunctionGo)
+ return false;
+ }
+ }
+
+ // Allow access to toString() from any frame as well.
+ if (propertyName == exec->propertyNames().toString)
+ return false;
+
+ if (!allowsAccessFromFrame(exec, impl()->frame())) {
+ slot.setUndefined(this);
+ return true;
+ }
+
+ return false;
+}
+
+bool JSHistory::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
+{
+ // Only allow putting by frames in the same origin.
+ if (!allowsAccessFromFrame(exec, impl()->frame()))
+ return true;
+ return false;
+}
+
+void JSHistory::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
+{
+ // Only allow the history object to enumerated by frames in the same origin.
+ if (!allowsAccessFromFrame(exec, impl()->frame()))
+ return;
+ Base::getPropertyNames(exec, propertyNames);
+}
+
+} // namespace WebCore
-// -*- c-basic-offset: 4 -*-
/*
* Copyright (C) 2000 Harri Porten (porten@kde.org)
* Copyright (C) 2006 Jon Shier (jshier@iastate.edu)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reseved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reseved.
* Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
*
* This library is free software; you can redistribute it and/or
namespace WebCore {
+static bool allowsAccessFromFrame(ExecState* exec, Frame* frame)
+{
+ if (!frame)
+ return false;
+ Window* win = Window::retrieveWindow(frame);
+ return win && win->allowsAccessFrom(exec);
+}
+
const ClassInfo JSLocation::info = { "Location", 0, &JSLocationTable };
/*
}
}
+void JSLocation::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
+{
+ // Only allow the location object to enumerated by frames in the same origin.
+ if (!allowsAccessFromFrame(exec, frame()))
+ return;
+ Base::getPropertyNames(exec, propertyNames);
+}
+
JSValue* jsLocationProtoFuncReplace(ExecState* exec, JSObject* thisObj, const List& args)
{
if (!thisObj->inherits(&JSLocation::info))
/*
* Copyright (C) 2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reseved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reseved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
class Frame;
class JSLocation : public KJS::DOMObject {
+ typedef KJS::DOMObject Base;
+
friend class KJS::Window;
public:
JSLocation(KJS::JSObject* protoype, Frame*);
KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);
+ virtual void getPropertyNames(KJS::ExecState*, KJS::PropertyNameArray&);
+
enum {
Hash, Href, Hostname, Host,
Pathname, Port, Protocol, Search,
-// -*- c-basic-offset: 4 -*-
/*
* Copyright (C) 2000 Harri Porten (porten@kde.org)
* Copyright (C) 2006 Jon Shier (jshier@iastate.edu)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reseved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reseved.
* Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
*
* This library is free software; you can redistribute it and/or
return page->chrome()->shouldInterruptJavaScript();
}
-void Window::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
-{
- if (!allowsAccessFrom(exec))
- return;
- Base::getPropertyNames(exec, propertyNames);
-}
-
void Window::setListener(ExecState* exec, const AtomicString& eventType, JSValue* func)
{
ASSERT(impl()->frame());
/*
* Copyright (C) 2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reseved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reseved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
namespace KJS {
class DOMWindowTimer;
- class Window;
- class WindowFunc;
class WindowPrivate;
// This is the only WebCore JS binding which does not inherit from DOMObject
virtual bool allowsAccessFrom(const JSGlobalObject*) const;
bool allowsAccessFrom(ExecState* exec) const { return allowsAccessFrom(exec->dynamicGlobalObject()); }
- virtual void getPropertyNames(ExecState*, PropertyNameArray&);
-
enum {
// Attributes
Crypto, Event_, Location_, Navigator_,
# Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
# Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org>
# Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
-# Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+# Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# Class declaration
push(@headerContent, "class $className : public $parentClassName {\n");
+ push(@headerContent, " typedef $parentClassName Base;\n");
push(@headerContent, "public:\n");
# Constructor
}
# Destructor
- if (!$hasParent or $interfaceName eq "Document") {
- push(@headerContent, " virtual ~$className();\n");
- }
+ push(@headerContent, " virtual ~$className();\n") if (!$hasParent or $interfaceName eq "Document");
# Getters
if ($numAttributes > 0 || $dataNode->extendedAttributes->{"GenerateConstructor"}) {
push(@headerContent, " virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);\n");
push(@headerContent, " KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;\n");
- if ($dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"}) {
- push(@headerContent, " bool customGetOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);\n");
- }
+ push(@headerContent, " bool customGetOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);\n") if $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"};
}
# Check if we have any writable properties
}
}
- if ($hasReadWriteProperties) {
- push(@headerContent, " virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);\n");
- push(@headerContent, " void putValueProperty(KJS::ExecState*, int, KJS::JSValue*, int attr);\n");
- if ($dataNode->extendedAttributes->{"CustomPutFunction"}) {
- push(@headerContent, " bool customPut(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr);\n");
- }
- }
+ push(@headerContent, " virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);\n") if ($hasReadWriteProperties || $dataNode->extendedAttributes->{"CustomPutFunction"});
+ push(@headerContent, " void putValueProperty(KJS::ExecState*, int, KJS::JSValue*, int attr);\n") if $hasReadWriteProperties;
+ push(@headerContent, " bool customPut(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr);\n") if $dataNode->extendedAttributes->{"CustomPutFunction"};
# Class info
push(@headerContent, " virtual const KJS::ClassInfo* classInfo() const { return &info; }\n");
push(@headerContent, " static const KJS::ClassInfo info;\n\n");
# Custom mark function
- if ($dataNode->extendedAttributes->{"CustomMarkFunction"}) {
- push(@headerContent, " virtual void mark();\n\n");
- }
+ push(@headerContent, " virtual void mark();\n\n") if $dataNode->extendedAttributes->{"CustomMarkFunction"};
# Custom pushEventHandlerScope function
- if ($dataNode->extendedAttributes->{"CustomPushEventHandlerScope"}) {
- push(@headerContent, " virtual void pushEventHandlerScope(KJS::ExecState*, KJS::ScopeChain&) const;\n\n");
- }
+ push(@headerContent, " virtual void pushEventHandlerScope(KJS::ExecState*, KJS::ScopeChain&) const;\n\n") if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"};
# Custom call functions
if ($dataNode->extendedAttributes->{"CustomCall"}) {
push(@headerContent, " virtual bool implementsCall() const;\n\n");
}
+ # Custom getPropertyNames function
+ push(@headerContent, " virtual void getPropertyNames(KJS::ExecState*, KJS::PropertyNameArray&);\n") if $dataNode->extendedAttributes->{"CustomGetPropertyNames"};
+
# Constructor object getter
- if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
- push(@headerContent, " static KJS::JSValue* getConstructor(KJS::ExecState*);\n");
- }
+ push(@headerContent, " static KJS::JSValue* getConstructor(KJS::ExecState*);\n") if $dataNode->extendedAttributes->{"GenerateConstructor"};
my $numCustomFunctions = 0;
my $numCustomAttributes = 0;
# - Initialize static ClassInfo object
push(@implContent, "const ClassInfo $className" . "::info = { \"${visibleClassName}\", ");
if ($hasParent) {
- push(@implContent, "&" .$parentClassName . "::info, ");
+ push(@implContent, "&" . $parentClassName . "::info, ");
} else {
push(@implContent, "0, ");
}
}
if ($requiresManualLookup) {
- push(@implContent, " return ${parentClassName}::getOwnPropertySlot(exec, propertyName, slot);\n");
+ push(@implContent, " return Base::getOwnPropertySlot(exec, propertyName, slot);\n");
} else {
- push(@implContent, " return getStaticValueSlot<$className, $parentClassName>(exec, &${className}Table, this, propertyName, slot);\n");
+ push(@implContent, " return getStaticValueSlot<$className, Base>(exec, &${className}Table, this, propertyName, slot);\n");
}
push(@implContent, "}\n\n");
foreach my $attribute (@{$dataNode->attributes}) {
$hasReadWriteProperties = 1 if $attribute->type !~ /^readonly/;
}
- if ($hasReadWriteProperties) {
+ if ($hasReadWriteProperties || $dataNode->extendedAttributes->{"CustomPutFunction"}) {
push(@implContent, "void ${className}::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)\n");
push(@implContent, "{\n");
if ($dataNode->extendedAttributes->{"HasCustomIndexSetter"}) {
push(@implContent, " if (customPut(exec, propertyName, value, attr))\n");
push(@implContent, " return;\n");
}
+ if ($hasReadWriteProperties) {
+ push(@implContent, " lookupPut<$className, Base>(exec, propertyName, value, attr, &${className}Table, this);\n");
+ } else {
+ push(@implContent, " Base::put(exec, propertyName, value, attr);\n");
+ }
- push(@implContent, " lookupPut<$className, $parentClassName>(exec, propertyName, value, attr, &${className}Table, this);\n");
push(@implContent, "}\n\n");
- push(@implContent, "void ${className}::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)\n");
- push(@implContent, "{\n");
+ if ($hasReadWriteProperties) {
+ push(@implContent, "void ${className}::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)\n");
+ push(@implContent, "{\n");
- push(@implContent, " switch (token) {\n");
+ push(@implContent, " switch (token) {\n");
- foreach my $attribute (@{$dataNode->attributes}) {
- if ($attribute->type !~ /^readonly/) {
- my $name = $attribute->signature->name;
- my $setterFunctionName = $codeGenerator->WK_ucfirst($name);
+ foreach my $attribute (@{$dataNode->attributes}) {
+ if ($attribute->type !~ /^readonly/) {
+ my $name = $attribute->signature->name;
+ my $setterFunctionName = $codeGenerator->WK_ucfirst($name);
- push(@implContent, " case " . $codeGenerator->WK_ucfirst($attribute->signature->name)
- . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "")
- . "AttrNum: {\n");
+ push(@implContent, " case " . $codeGenerator->WK_ucfirst($attribute->signature->name)
+ . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "")
+ . "AttrNum: {\n");
- if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) {
- push(@implContent, " if (!allowsAccessFrom(exec))\n");
- push(@implContent, " return;\n");
- }
-
- if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"CustomSetter"}) {
- push(@implContent, " set$setterFunctionName(exec, value);\n");
- } elsif ($attribute->signature->type =~ /Constructor$/) {
- my $constructorType = $attribute->signature->type;
- $constructorType =~ s/Constructor$//;
- $implIncludes{"JS" . $constructorType . ".h"} = 1;
- push(@implContent, " // Shadowing a built-in constructor\n");
- push(@implContent, " putDirect(\"$name\", value);\n");
- } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) {
- push(@implContent, " putDirect(\"$name\", value);\n");
- } else {
- if ($podType) {
- push(@implContent, " $podType imp(*impl());\n");
- if ($podType eq "float") { # Special case for JSSVGNumber
- push(@implContent, " imp = " . JSValueToNative($attribute->signature, "value") . ";\n");
+ if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) {
+ if ($interfaceName eq "DOMWindow") {
+ push(@implContent, " if (!allowsAccessFrom(exec))\n");
} else {
- push(@implContent, " imp.set$setterFunctionName(" . JSValueToNative($attribute->signature, "value") . ");\n");
+ push(@implContent, " if (!allowsAccessFromFrame(exec, impl()->frame()))\n");
}
- push(@implContent, " m_impl->commitChange(exec, imp);\n");
+ push(@implContent, " return;\n");
+ }
+
+ if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"CustomSetter"}) {
+ push(@implContent, " set$setterFunctionName(exec, value);\n");
+ } elsif ($attribute->signature->type =~ /Constructor$/) {
+ my $constructorType = $attribute->signature->type;
+ $constructorType =~ s/Constructor$//;
+ $implIncludes{"JS" . $constructorType . ".h"} = 1;
+ push(@implContent, " // Shadowing a built-in constructor\n");
+ push(@implContent, " putDirect(\"$name\", value);\n");
+ } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) {
+ push(@implContent, " putDirect(\"$name\", value);\n");
} else {
- push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(impl());\n");
- push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
- push(@implContent, " imp->set$setterFunctionName(" . JSValueToNative($attribute->signature, "value"));
- push(@implContent, ", ec") if @{$attribute->setterExceptions};
- push(@implContent, ");\n");
- push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions};
+ if ($podType) {
+ push(@implContent, " $podType imp(*impl());\n");
+ if ($podType eq "float") { # Special case for JSSVGNumber
+ push(@implContent, " imp = " . JSValueToNative($attribute->signature, "value") . ";\n");
+ } else {
+ push(@implContent, " imp.set$setterFunctionName(" . JSValueToNative($attribute->signature, "value") . ");\n");
+ }
+ push(@implContent, " m_impl->commitChange(exec, imp);\n");
+ } else {
+ push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(impl());\n");
+ push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
+ push(@implContent, " imp->set$setterFunctionName(" . JSValueToNative($attribute->signature, "value"));
+ push(@implContent, ", ec") if @{$attribute->setterExceptions};
+ push(@implContent, ");\n");
+ push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions};
+ }
}
+ push(@implContent, " break;\n");
+ push(@implContent, " }\n");
}
- push(@implContent, " break;\n");
- push(@implContent, " }\n");
}
- }
- push(@implContent, " }\n"); # end switch
+ push(@implContent, " }\n"); # end switch
- if (IsSVGTypeNeedingContextParameter($implClassName)) {
- push(@implContent, " if (context())\n");
- push(@implContent, " context()->notifyAttributeChange();\n");
- }
+ if (IsSVGTypeNeedingContextParameter($implClassName)) {
+ push(@implContent, " if (context())\n");
+ push(@implContent, " context()->notifyAttributeChange();\n");
+ }
- push(@implContent, "}\n\n"); # end function
+ push(@implContent, "}\n\n"); # end function
+ }
}
}
if ($dataNode->extendedAttributes->{"GenerateNativeConverter"} && $hasParent) {
push(@implContent, "\n$implClassName* ${className}::impl() const\n");
push(@implContent, "{\n");
- push(@implContent, " return static_cast<$implClassName*>(${parentClassName}::impl());\n");
+ push(@implContent, " return static_cast<$implClassName*>(Base::impl());\n");
push(@implContent, "}\n");
}
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
module window {
- interface [LegacyParent=KJS::Window, DoNotCache, CheckDomainSecurity, GenerateNativeConverter, CustomGetOwnPropertySlot, CustomPutFunction] DOMWindow {
+ interface [LegacyParent=KJS::Window, DoNotCache, CheckDomainSecurity, GenerateNativeConverter, CustomGetOwnPropertySlot, CustomPutFunction, CustomGetPropertyNames] DOMWindow {
// DOM Level 0
readonly attribute Screen screen;
readonly attribute [DoNotCheckDomainSecurity] History history;
/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
module window {
- interface History {
+ interface [CustomGetOwnPropertySlot, CustomPutFunction, CustomGetPropertyNames] History {
readonly attribute unsigned long length;
void back();