Diff
Modified: trunk/LayoutTests/ChangeLog (152465 => 152466)
--- trunk/LayoutTests/ChangeLog 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/LayoutTests/ChangeLog 2013-07-08 21:24:33 UTC (rev 152466)
@@ -1,3 +1,16 @@
+2013-07-08 Radu Stavila <[email protected]>
+
+ NamedFlowCollection getters should return undefined when there's no NamedFlow
+ https://bugs.webkit.org/show_bug.cgi?id=118463
+
+ Reviewed by Christophe Dumez.
+
+ Added test that validates that NamedFlowCollection getters return undefined
+ when no named flows exist.
+
+ * fast/regions/webkit-named-flow-collection-undefined-expected.txt: Added.
+ * fast/regions/webkit-named-flow-collection-undefined.html: Added.
+
2013-07-08 David Farler <[email protected]>
fast/repaint/fixed-right-in-page-scale.html also crashing on Mountain Lion.
Added: trunk/LayoutTests/fast/regions/webkit-named-flow-collection-undefined-expected.txt (0 => 152466)
--- trunk/LayoutTests/fast/regions/webkit-named-flow-collection-undefined-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/regions/webkit-named-flow-collection-undefined-expected.txt 2013-07-08 21:24:33 UTC (rev 152466)
@@ -0,0 +1,11 @@
+Test for [118463] NamedFlowCollection getters should return undefined when there's no NamedFlow
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS namedFlowCollection.item(0) is undefined.
+PASS namedFlowCollection.namedItem('flow') is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/regions/webkit-named-flow-collection-undefined.html (0 => 152466)
--- trunk/LayoutTests/fast/regions/webkit-named-flow-collection-undefined.html (rev 0)
+++ trunk/LayoutTests/fast/regions/webkit-named-flow-collection-undefined.html 2013-07-08 21:24:33 UTC (rev 152466)
@@ -0,0 +1,18 @@
+<!doctype html>
+<html>
+ <body>
+
+ <script src=""
+ <script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ description("Test for <a href=''>[118463] NamedFlowCollection getters should return undefined when there's no NamedFlow</a>");
+
+ var namedFlowCollection = document.webkitGetNamedFlows();
+ shouldBeUndefined("namedFlowCollection.item(0)");
+ shouldBeUndefined("namedFlowCollection.namedItem('flow')");
+ </script>
+ <script src=""
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (152465 => 152466)
--- trunk/Source/WebCore/ChangeLog 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/ChangeLog 2013-07-08 21:24:33 UTC (rev 152466)
@@ -1,3 +1,33 @@
+2013-07-08 Radu Stavila <[email protected]>
+
+ NamedFlowCollection getters should return undefined when there's no NamedFlow
+ https://bugs.webkit.org/show_bug.cgi?id=118463
+
+ Reviewed by Christophe Dumez.
+
+ Added new TreatReturnedNullObjectAs attribute for generated methods and set it to Undefined
+ for the item and namedItem methods of DOMNamedFlowCollection.
+
+ Test: fast/regions/webkit-named-flow-collection-undefined.html
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateImplementationFunctionCall):
+ * bindings/scripts/IDLAttributes.txt:
+ * bindings/scripts/test/CPP/WebDOMTestObj.cpp:
+ (WebDOMTestObj::treatReturnedNullObjectAsUndefined):
+ * bindings/scripts/test/CPP/WebDOMTestObj.h:
+ * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
+ (webkit_dom_test_obj_treat_returned_null_object_as_undefined):
+ * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::jsTestObjPrototypeFunctionTreatReturnedNullObjectAsUndefined):
+ * bindings/scripts/test/JS/JSTestObj.h:
+ * bindings/scripts/test/ObjC/DOMTestObj.h:
+ * bindings/scripts/test/ObjC/DOMTestObj.mm:
+ (-[DOMTestObj treatReturnedNullObjectAsUndefined]):
+ * bindings/scripts/test/TestObj.idl:
+ * dom/DOMNamedFlowCollection.idl:
+
2013-07-06 Changhun Kang <[email protected]>
Remove unused variables in FocusCandidate.
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2013-07-08 21:24:33 UTC (rev 152466)
@@ -3344,6 +3344,11 @@
push(@implContent, $indent . " return JSValue::encode(jsUndefined());\n");
}
+ if ($function->signature->extendedAttributes->{"TreatReturnedNullObjectAs"} and $function->signature->extendedAttributes->{"TreatReturnedNullObjectAs"} eq "Undefined") {
+ push(@implContent, $indent . "if (result == jsNull())\n");
+ push(@implContent, $indent . " result = jsUndefined();\n\n");
+ }
+
push(@implContent, $indent . "return JSValue::encode(result);\n");
}
}
Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2013-07-08 21:24:33 UTC (rev 152466)
@@ -102,6 +102,7 @@
StrictTypeChecking
SuppressToJSObject
TreatNullAs=NullString
+TreatReturnedNullObjectAs=Undefined
TreatReturnedNullStringAs=Null|Undefined
TreatUndefinedAs=NullString
TypedArray=*
Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp 2013-07-08 21:24:33 UTC (rev 152466)
@@ -990,6 +990,14 @@
#endif
+WebDOMTestObj WebDOMTestObj::treatReturnedNullObjectAsUndefined()
+{
+ if (!impl())
+ return WebDOMTestObj();
+
+ return toWebKit(WTF::getPtr(impl()->treatReturnedNullObjectAsUndefined()));
+}
+
void WebDOMTestObj::classMethod()
{
if (!impl())
Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h 2013-07-08 21:24:33 UTC (rev 152466)
@@ -188,6 +188,7 @@
#if ENABLE(Condition1) || ENABLE(Condition2)
void conditionalMethod3();
#endif
+ WebDOMTestObj treatReturnedNullObjectAsUndefined();
void classMethod();
int classMethodWithOptional(int arg);
#if ENABLE(Condition1)
Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp 2013-07-08 21:24:33 UTC (rev 152466)
@@ -1413,6 +1413,16 @@
#endif /* ENABLE(Condition1) || ENABLE(Condition2) */
}
+WebKitDOMTestObj*
+webkit_dom_test_obj_treat_returned_null_object_as_undefined(WebKitDOMTestObj* self)
+{
+ WebCore::JSMainThreadNullState state;
+ g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
+ WebCore::TestObj* item = WebKit::core(self);
+ RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->treatReturnedNullObjectAsUndefined());
+ return WebKit::kit(gobjectResult.get());
+}
+
void
webkit_dom_test_obj_class_method(WebKitDOMTestObj* self)
{
Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h 2013-07-08 21:24:33 UTC (rev 152466)
@@ -405,6 +405,16 @@
webkit_dom_test_obj_conditional_method3(WebKitDOMTestObj* self);
/**
+ * webkit_dom_test_obj_treat_returned_null_object_as_undefined:
+ * @self: A #WebKitDOMTestObj
+ *
+ * Returns: (transfer none):
+ *
+**/
+WEBKIT_API WebKitDOMTestObj*
+webkit_dom_test_obj_treat_returned_null_object_as_undefined(WebKitDOMTestObj* self);
+
+/**
* webkit_dom_test_obj_class_method:
* @self: A #WebKitDOMTestObj
*
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2013-07-08 21:24:33 UTC (rev 152466)
@@ -319,6 +319,7 @@
#if ENABLE(Condition1) || ENABLE(Condition2)
{ "conditionalMethod3", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConditionalMethod3), (intptr_t)0, NoIntrinsic },
#endif
+ { "treatReturnedNullObjectAsUndefined", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTreatReturnedNullObjectAsUndefined), (intptr_t)0, NoIntrinsic },
{ "overloadedMethod", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t)2, NoIntrinsic },
{ "classMethodWithClamp", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethodWithClamp), (intptr_t)2, NoIntrinsic },
{ "methodWithUnsignedLongSequence", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithUnsignedLongSequence), (intptr_t)1, NoIntrinsic },
@@ -2504,6 +2505,22 @@
#endif
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTreatReturnedNullObjectAsUndefined(ExecState* exec)
+{
+ JSValue thisValue = exec->hostThisValue();
+ if (!thisValue.inherits(&JSTestObj::s_info))
+ return throwVMTypeError(exec);
+ JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));
+ ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
+ TestObj* impl = static_cast<TestObj*>(castedThis->impl());
+
+ JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->treatReturnedNullObjectAsUndefined()));
+ if (result == jsNull())
+ result = jsUndefined();
+
+ return JSValue::encode(result);
+}
+
static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h 2013-07-08 21:24:33 UTC (rev 152466)
@@ -209,6 +209,7 @@
#if ENABLE(Condition1) || ENABLE(Condition2)
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalMethod3(JSC::ExecState*);
#endif
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTreatReturnedNullObjectAsUndefined(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethodWithOptional(JSC::ExecState*);
Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h 2013-07-08 21:24:33 UTC (rev 152466)
@@ -167,6 +167,7 @@
#if ENABLE(Condition1) || ENABLE(Condition2)
- (void)conditionalMethod3;
#endif
+- (DOMTestObj *)treatReturnedNullObjectAsUndefined;
- (void)classMethod;
- (int)classMethodWithOptional:(int)arg;
- (void)classMethod2:(int)arg;
Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm 2013-07-08 21:24:33 UTC (rev 152466)
@@ -1052,6 +1052,12 @@
#endif
+- (DOMTestObj *)treatReturnedNullObjectAsUndefined
+{
+ WebCore::JSMainThreadNullState state;
+ return kit(WTF::getPtr(IMPL->treatReturnedNullObjectAsUndefined()));
+}
+
- (void)classMethod
{
WebCore::JSMainThreadNullState state;
Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (152465 => 152466)
--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2013-07-08 21:24:33 UTC (rev 152466)
@@ -167,6 +167,9 @@
[Conditional=Condition1] const unsigned short CONDITIONAL_CONST = 0;
+ // 'TreatReturnedNullObjectAs' extended method
+ [TreatReturnedNullObjectAs=Undefined] TestObj treatReturnedNullObjectAsUndefined();
+
#if defined(TESTING_JS)
[CachedAttribute] readonly attribute any cachedAttribute1;
[CachedAttribute] readonly attribute any cachedAttribute2;
Modified: trunk/Source/WebCore/dom/DOMNamedFlowCollection.idl (152465 => 152466)
--- trunk/Source/WebCore/dom/DOMNamedFlowCollection.idl 2013-07-08 21:05:34 UTC (rev 152465)
+++ trunk/Source/WebCore/dom/DOMNamedFlowCollection.idl 2013-07-08 21:24:33 UTC (rev 152466)
@@ -35,6 +35,6 @@
ImplementationLacksVTable
] interface DOMNamedFlowCollection {
readonly attribute unsigned long length;
- getter WebKitNamedFlow item(unsigned long index);
- getter WebKitNamedFlow namedItem(DOMString name);
+ [TreatReturnedNullObjectAs=Undefined] getter WebKitNamedFlow item(unsigned long index);
+ [TreatReturnedNullObjectAs=Undefined] getter WebKitNamedFlow namedItem(DOMString name);
};