Commit a667be55 authored by japhet@chromium.org's avatar japhet@chromium.org

2009-08-12 Nate Chapin <japhet@chromium.org>

        Reviewed by Adam Barth.

        Add a Custom Setter for DOMWindowEvent in the V8 bindings.
        https://bugs.webkit.org/show_bug.cgi?id=27719

        Tests: fast/events/set-event-in-another-frame.html
               fast/events/set-event-to-null.html



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47130 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent aa5bf36f
2009-08-12 Nate Chapin <japhet@chromium.org>
Reviewed by Adam Barth.
Add a layout test to ensure that window.event can be properly accessed
after it has been nulled by a script on a page.
https://bugs.webkit.org/show_bug.cgi?id=27719
* fast/events/set-event-in-another-frame-expected.txt: Added.
* fast/events/set-event-in-another-frame.html: Added.
* fast/events/set-event-to-null-expected.txt: Added.
* fast/events/set-event-to-null.html: Added.
2009-08-12 Eric Seidel <eric@webkit.org>
No review, just skipping tests to make the bots green.
......
Helpers loaded!
--- Test begins ---
window.event = undefined
--- After window.event = null ---
window.event = null
--- After MouseEvent completes ---
window.event = undefined
--- Test ends ---
<html>
<head>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
function log(msg) {
var line = document.createElement('div');
line.appendChild(document.createTextNode(msg));
document.getElementById('console').appendChild(line);
}
function getEvent() {
var target = frames[1].window;
var newEvent = frames[1].document.createEvent("MouseEvent");
newEvent.initMouseEvent("mouseover", false, false, window, 0, 10, 10, 10, 10, false, false, false, false, 0, target);
target.dispatchEvent(newEvent);
}
var testStarted = false;
function doTest() {
if (testStarted)
return;
testStarted = true;
frames[0].location = "javascript:" +
"window.myeventnull = function() { parent.frames[1].window.event = null; };" +
"window.myeventreal = function() { parent.frames[1].window.event = parent.getEvent(); };" +
"parent.log('Helpers loaded!\\n');" +
"parent.setTimeout('continueTest()', 10);";
}
function continueTest() {
log('--- Test begins ---\n');
log('window.event = ' + frames[1].window.event + '\n');
log('--- After window.event = null ---\n');
frames[0].myeventnull();
log('window.event = ' + frames[1].window.event + '\n');
log('--- After MouseEvent completes ---\n');
frames[0].myeventreal();
log('window.event = ' + frames[1].window.event + '\n');
log('--- Test ends ---\n');
layoutTestController.notifyDone();
}
</script>
</head>
<body onload="doTest()">
<iframe src="about:blank"></iframe>
<iframe src=""></iframe>
<div id="console"></div>
</body>
</html>
This test will trigger a mouse over of this element. We will then check to see if event was properly set (i.e., not null). This is in response to a v8 bug that can break window.event exposure if the client tries to manually set event.
PASS: After MouseEvent, event is valid
<html>
<head>
<script language="javascript">
function log(s)
{
document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
}
function mouseOver(event)
{
if (event === null) {
log("FAIL: After MouseEvent, event is null");
} else {
log("PASS: After MouseEvent, event is valid");
}
}
function runTest() {
var target = document.getElementById("target");
var newEvent = document.createEvent("MouseEvent");
newEvent.initMouseEvent("mouseover", false, false, window, 0, 10, 10, 10, 10, false, false, false, false, 0, target);
target.dispatchEvent(newEvent);
if (window.layoutTestController) {
layoutTestController.dumpAsText();
}
}
</script>
</head>
<body onLoad="runTest();">
<div id="target" onMouseOver="mouseOver(event);">This test will trigger a mouse over of this element.
We will then check to see if event was properly set (i.e., not null).
This is in response to a v8 bug that can break window.event exposure if the client tries to manually set event.</div>
<div id="console"></div>
<script>
if (!(event === undefined)) {
log("FAIL: event does not begin as undefined");
}
event = null;
if (!(event === null)) {
log("FAIL: event was not successfully set to null");
}
</script>
</body>
</html>
2009-08-12 Nate Chapin <japhet@chromium.org>
Reviewed by Adam Barth.
Add a Custom Setter for DOMWindowEvent in the V8 bindings.
https://bugs.webkit.org/show_bug.cgi?id=27719
Tests: fast/events/set-event-in-another-frame.html
fast/events/set-event-to-null.html
* bindings/scripts/CodeGeneratorV8.pm: Clean up custom getter/setter code,
as it currently doesn't support a custom getter
and a v8-specific custom setter simultaneously.
* bindings/v8/custom/V8CustomBinding.h:
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::ACCESSOR_SETTER):
* page/DOMWindow.idl:
2009-08-12 Peter Kasting <pkasting@google.com>
Reviewed by Adam Treat.
......@@ -975,51 +975,24 @@ sub GenerateBatchedAttributeData
$setter = "V8Custom::v8${customAccessor}AccessorSetter";
}
}
} else {
# Default Getter and Setter
$getter = "${interfaceName}Internal::${attrName}AttrGetter";
$setter = "${interfaceName}Internal::${attrName}AttrSetter";
# Custom Getter and Setter
} elsif ($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
$getter = "V8Custom::v8${customAccessor}AccessorGetter";
if ($interfaceName eq "WorkerContext" and $attrName eq "self") {
$setter = "0";
$propAttr = "v8::ReadOnly";
} else {
# Custom Setter
if ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
$hasCustomSetter = 1;
$setter = "V8Custom::v8${customAccessor}AccessorSetter";
}
# Custom Setter
} elsif ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"}) {
$hasCustomSetter = 1;
$getter = "${interfaceName}Internal::${attrName}AttrGetter";
$setter = "V8Custom::v8${customAccessor}AccessorSetter";
# Custom Getter
} elsif ($attrExt->{"CustomGetter"}) {
$getter = "V8Custom::v8${customAccessor}AccessorGetter";
$setter = "${interfaceName}Internal::${attrName}AttrSetter";
# Replaceable
} elsif ($attrExt->{"Replaceable"}) {
# Replaceable accessor is put on instance template with ReadOnly attribute.
$getter = "${interfaceName}Internal::${attrName}AttrGetter";
$setter = "0";
# Mark to avoid duplicate v8::ReadOnly flags in output.
$hasCustomSetter = 1;
# Handle the special case of window.top being marked upstream as Replaceable.
# FIXME: Investigate why [Replaceable] is not marked as ReadOnly
# upstream and reach parity.
if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) {
$propAttr .= "|v8::ReadOnly";
# Custom Getter
if ($attrExt->{"CustomGetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
$getter = "V8Custom::v8${customAccessor}AccessorGetter";
}
# Normal
} else {
$getter = "${interfaceName}Internal::${attrName}AttrGetter";
$setter = "${interfaceName}Internal::${attrName}AttrSetter";
}
# Replaceable
if ($attrExt->{"Replaceable"} && !$hasCustomSetter) {
$setter = "0";
$propAttr .= "|v8::ReadOnly";
......
......@@ -218,7 +218,7 @@ namespace WebCore {
DECLARE_PROPERTY_ACCESSOR(CanvasRenderingContext2DStrokeStyle);
DECLARE_PROPERTY_ACCESSOR(CanvasRenderingContext2DFillStyle);
DECLARE_PROPERTY_ACCESSOR_GETTER(DOMWindowEvent);
DECLARE_PROPERTY_ACCESSOR(DOMWindowEvent);
DECLARE_PROPERTY_ACCESSOR_GETTER(DOMWindowCrypto);
DECLARE_PROPERTY_ACCESSOR_SETTER(DOMWindowLocation);
DECLARE_PROPERTY_ACCESSOR_SETTER(DOMWindowOpener);
......
......@@ -153,6 +153,21 @@ ACCESSOR_GETTER(DOMWindowEvent)
return jsEvent;
}
ACCESSOR_SETTER(DOMWindowEvent)
{
v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This());
if (holder.IsEmpty())
return;
Frame* frame = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder)->frame();
if (!frame || !V8Proxy::canAccessFrame(frame, true))
return;
v8::Local<v8::Context> context = V8Proxy::context(frame);
v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event");
context->Global()->SetHiddenValue(eventSymbol, value);
}
ACCESSOR_GETTER(DOMWindowCrypto)
{
// FIXME: Implement me.
......
......@@ -55,7 +55,7 @@ module window {
attribute [Replaceable] Navigator clientInformation;
attribute [DoNotCheckDomainSecurity, JSCCustom, V8CustomSetter, V8DisallowShadowing] Location location;
attribute [Replaceable, CustomGetter] Event event;
attribute [Replaceable, CustomGetter, V8CustomSetter] Event event;
readonly attribute [Custom] Crypto crypto;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment