Title: [123936] trunk
Revision
123936
Author
[email protected]
Date
2012-07-27 16:44:27 -0700 (Fri, 27 Jul 2012)

Log Message

Plugins should not be allowed to override standard properties/attributes in non-standard worlds
<rdar://problem/11975252> and https://bugs.webkit.org/show_bug.cgi?id=92519

Reviewed by Anders Carlsson.

Source/WebCore:

Change the 3 plugin-owning element's custom bindings to prefer built-in properties if they exist.
When they do they don't give the plugin a chance to override.

Test: plugins/npruntime/overrides-all-properties.html

Add plugin custom functions to prefer built-in properties over plugin scriptable object properties:
* bindings/js/JSPluginElementFunctions.h:
(WebCore::pluginElementCustomGetOwnPropertySlot):
(WebCore::pluginElementCustomGetOwnPropertyDescriptor):

Use those new custom functions for getting properties:
* bindings/js/JSHTMLAppletElementCustom.cpp:
(WebCore::JSHTMLAppletElement::getOwnPropertySlotDelegate):
(WebCore::JSHTMLAppletElement::getOwnPropertyDescriptorDelegate):
* bindings/js/JSHTMLEmbedElementCustom.cpp:
(WebCore::JSHTMLEmbedElement::getOwnPropertySlotDelegate):
(WebCore::JSHTMLEmbedElement::getOwnPropertyDescriptorDelegate):
* bindings/js/JSHTMLObjectElementCustom.cpp:
(WebCore::JSHTMLObjectElement::getOwnPropertySlotDelegate):
(WebCore::JSHTMLObjectElement::getOwnPropertyDescriptorDelegate):

Tools:

Add a test plugin which overrides all properties it is asked about:
* DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableObjectOverridesAllProperties.cpp: Added.
(PluginScriptableObjectOverridesAllProperties):
(PluginScriptableObjectOverridesAllProperties::PluginScriptableObjectOverridesAllProperties):
(PluginObject):
(PluginScriptableObjectOverridesAllProperties::PluginObject::PluginObject):
(PluginScriptableObjectOverridesAllProperties::PluginObject::~PluginObject):
(PluginScriptableObjectOverridesAllProperties::PluginObject::hasProperty):
(PluginScriptableObjectOverridesAllProperties::PluginObject::getProperty):
(PluginScriptableObjectOverridesAllProperties::NPP_GetValue):

Expose NPN_MemAlloc to the test plugin:
* DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp:
(PluginTest::NPN_MemAlloc):
* DumpRenderTree/TestNetscapePlugIn/PluginTest.h:
(PluginTest):

* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
* DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro:

LayoutTests:

* plugins/npruntime/overrides-all-properties-expected.txt: Added.
* plugins/npruntime/overrides-all-properties.html: Added.
* platform/chromium/TestExpectations: Test behaves different in V8, so skip on chromium

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (123935 => 123936)


--- trunk/LayoutTests/ChangeLog	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/LayoutTests/ChangeLog	2012-07-27 23:44:27 UTC (rev 123936)
@@ -1,3 +1,14 @@
+2012-07-27  Brady Eidson  <[email protected]>
+
+        Plugins should not be allowed to override standard properties/attributes in non-standard worlds
+        <rdar://problem/11975252> and https://bugs.webkit.org/show_bug.cgi?id=92519
+
+        Reviewed by Anders Carlsson.
+
+        * plugins/npruntime/overrides-all-properties-expected.txt: Added.
+        * plugins/npruntime/overrides-all-properties.html: Added.
+        * platform/chromium/TestExpectations: Test behaves different in V8, so skip on chromium
+
 2012-07-27  Arnaud Renevier  <[email protected]>
 
         use createUninitialized when creating TypedArray from another array

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (123935 => 123936)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2012-07-27 23:44:27 UTC (rev 123936)
@@ -850,6 +850,9 @@
 // Test for BlackBerry port only
 WONTFIX SKIP : platform/blackberry = PASS
 
+// _javascript_Core bindings willfully have different behavior than V8 bindings
+WONTFIX SKIP : plugins/npruntime/overrides-all-properties.html = TEXT
+
 // -----------------------------------------------------------------
 // TESTS TO FIX
 // -----------------------------------------------------------------

Added: trunk/LayoutTests/plugins/npruntime/overrides-all-properties-expected.txt (0 => 123936)


--- trunk/LayoutTests/plugins/npruntime/overrides-all-properties-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/plugins/npruntime/overrides-all-properties-expected.txt	2012-07-27 23:44:27 UTC (rev 123936)
@@ -0,0 +1,21 @@
+
+
+Test that the plugin script object - in a non-standard world - can override any property on its owning node *except* for the properties that are built in to the node or its constructor/prototype chain.
+For example, it can override "madeUpProperty" but cannot override "getAttribute" or "className".
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+

Added: trunk/LayoutTests/plugins/npruntime/overrides-all-properties.html (0 => 123936)


--- trunk/LayoutTests/plugins/npruntime/overrides-all-properties.html	                        (rev 0)
+++ trunk/LayoutTests/plugins/npruntime/overrides-all-properties.html	2012-07-27 23:44:27 UTC (rev 123936)
@@ -0,0 +1,65 @@
+<head>
+
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function runTest() {
+    if (!window.testRunner) {
+        log("This test can only be run under WebKit's testRunner environment");
+        return;
+    }
+
+    testRunner.evaluateScriptInIsolatedWorld(0, " \
+        function test(msg, expected) \
+        { \
+            var console = document.getElementById('console'); \
+            var span = document.createElement('span'); \
+			if (msg == undefined) \
+				msg = 'undefined'; \
+			else \
+				msg = msg.toString(); \
+            span.innerHTML = msg == expected ? 'PASS<br>' : 'FAIL - <br>(' + msg + ') but expected <br>(' + expected + ')<br>'; \
+            console.appendChild(span); \
+        } \
+        \
+        pluginEmbed = document.getElementById('plugin-embed'); \
+        \
+        test('madeUpProperty' in pluginEmbed, 'true'); \
+        test(typeof pluginEmbed.madeUpProperty, 'string'); \
+        test(pluginEmbed.madeUpProperty, 'My name is madeUpProperty'); \
+        test('getAttribute' in pluginEmbed, 'true'); \
+        test(typeof pluginEmbed.getAttribute, 'function'); \
+        test(pluginEmbed.getAttribute, 'function getAttribute() {\\n    [native code]\\n}'); \
+        \
+        test(Object.getOwnPropertyDescriptor(pluginEmbed, 'madeUpProperty'), '[object Object]'); \
+        test(Object.getOwnPropertyDescriptor(pluginEmbed, 'getAttribute'), 'undefined'); \
+        \
+        pluginObject = document.getElementById('plugin-object'); \
+        \
+        test('madeUpProperty' in pluginObject, 'true'); \
+        test(typeof pluginObject.madeUpProperty, 'string'); \
+        test(pluginObject.madeUpProperty, 'My name is madeUpProperty'); \
+        test('getAttribute' in pluginObject, 'true'); \
+        test(typeof pluginObject.getAttribute, 'function'); \
+        test(pluginObject.getAttribute, 'function getAttribute() {\\n    [native code]\\n}'); \
+        \
+        test(Object.getOwnPropertyDescriptor(pluginObject, 'madeUpProperty'), '[object Object]'); \
+        test(Object.getOwnPropertyDescriptor(pluginObject, 'getAttribute'), 'undefined'); \
+    ");
+
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+</head>
+
+<body _onLoad_="runTest()">
+<embed id="plugin-embed" type="application/x-webkit-test-netscape" test="plugin-scriptable-object-overrides-all-properties"></embed><br>
+<object id="plugin-object" type="application/x-webkit-test-netscape" test="plugin-scriptable-object-overrides-all-properties"></object><br>
+Test that the plugin script object - in a non-standard world - can override any property on its owning node *except* for the properties that are built in to the node or its constructor/prototype chain.<br>
+For example, it can override "madeUpProperty" but cannot override "getAttribute" or "className".<br>
+<div id="console"></div>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (123935 => 123936)


--- trunk/Source/WebCore/ChangeLog	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Source/WebCore/ChangeLog	2012-07-27 23:44:27 UTC (rev 123936)
@@ -1,3 +1,31 @@
+2012-07-27  Brady Eidson  <[email protected]>
+
+        Plugins should not be allowed to override standard properties/attributes in non-standard worlds
+        <rdar://problem/11975252> and https://bugs.webkit.org/show_bug.cgi?id=92519
+
+        Reviewed by Anders Carlsson.
+
+        Change the 3 plugin-owning element's custom bindings to prefer built-in properties if they exist.
+        When they do they don't give the plugin a chance to override.
+
+        Test: plugins/npruntime/overrides-all-properties.html
+
+        Add plugin custom functions to prefer built-in properties over plugin scriptable object properties:
+        * bindings/js/JSPluginElementFunctions.h:
+        (WebCore::pluginElementCustomGetOwnPropertySlot):
+        (WebCore::pluginElementCustomGetOwnPropertyDescriptor):
+
+        Use those new custom functions for getting properties:
+        * bindings/js/JSHTMLAppletElementCustom.cpp:
+        (WebCore::JSHTMLAppletElement::getOwnPropertySlotDelegate):
+        (WebCore::JSHTMLAppletElement::getOwnPropertyDescriptorDelegate):
+        * bindings/js/JSHTMLEmbedElementCustom.cpp:
+        (WebCore::JSHTMLEmbedElement::getOwnPropertySlotDelegate):
+        (WebCore::JSHTMLEmbedElement::getOwnPropertyDescriptorDelegate):
+        * bindings/js/JSHTMLObjectElementCustom.cpp:
+        (WebCore::JSHTMLObjectElement::getOwnPropertySlotDelegate):
+        (WebCore::JSHTMLObjectElement::getOwnPropertyDescriptorDelegate):
+
 2012-07-27  Arnaud Renevier  <[email protected]>
 
         use createUninitialized when creating TypedArray from another array

Modified: trunk/Source/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp (123935 => 123936)


--- trunk/Source/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Source/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp	2012-07-27 23:44:27 UTC (rev 123936)
@@ -35,12 +35,12 @@
 
 bool JSHTMLAppletElement::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 {
-    return runtimeObjectCustomGetOwnPropertySlot(exec, propertyName, slot, this);
+    return pluginElementCustomGetOwnPropertySlot<JSHTMLAppletElement, Base>(exec, propertyName, slot, this);
 }
 
 bool JSHTMLAppletElement::getOwnPropertyDescriptorDelegate(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
 {
-    return runtimeObjectCustomGetOwnPropertyDescriptor(exec, propertyName, descriptor, this);
+    return pluginElementCustomGetOwnPropertyDescriptor<JSHTMLAppletElement, Base>(exec, propertyName, descriptor, this);
 }
 
 bool JSHTMLAppletElement::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)

Modified: trunk/Source/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp (123935 => 123936)


--- trunk/Source/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Source/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp	2012-07-27 23:44:27 UTC (rev 123936)
@@ -35,12 +35,12 @@
 
 bool JSHTMLEmbedElement::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 {
-    return runtimeObjectCustomGetOwnPropertySlot(exec, propertyName, slot, this);
+    return pluginElementCustomGetOwnPropertySlot<JSHTMLEmbedElement, Base>(exec, propertyName, slot, this);
 }
 
 bool JSHTMLEmbedElement::getOwnPropertyDescriptorDelegate(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
 {
-    return runtimeObjectCustomGetOwnPropertyDescriptor(exec, propertyName, descriptor, this);
+    return pluginElementCustomGetOwnPropertyDescriptor<JSHTMLEmbedElement, Base>(exec, propertyName, descriptor, this);
 }
 
 bool JSHTMLEmbedElement::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)

Modified: trunk/Source/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp (123935 => 123936)


--- trunk/Source/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Source/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp	2012-07-27 23:44:27 UTC (rev 123936)
@@ -35,12 +35,12 @@
 
 bool JSHTMLObjectElement::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 {
-    return runtimeObjectCustomGetOwnPropertySlot(exec, propertyName, slot, this);
+    return pluginElementCustomGetOwnPropertySlot<JSHTMLObjectElement, Base>(exec, propertyName, slot, this);
 }
 
 bool JSHTMLObjectElement::getOwnPropertyDescriptorDelegate(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
 {
-    return runtimeObjectCustomGetOwnPropertyDescriptor(exec, propertyName, descriptor, this);
+    return pluginElementCustomGetOwnPropertyDescriptor<JSHTMLObjectElement, Base>(exec, propertyName, descriptor, this);
 }
 
 bool JSHTMLObjectElement::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)

Modified: trunk/Source/WebCore/bindings/js/JSPluginElementFunctions.h (123935 => 123936)


--- trunk/Source/WebCore/bindings/js/JSPluginElementFunctions.h	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Source/WebCore/bindings/js/JSPluginElementFunctions.h	2012-07-27 23:44:27 UTC (rev 123936)
@@ -44,6 +44,34 @@
     bool runtimeObjectCustomPut(JSC::ExecState*, JSC::PropertyName, JSC::JSValue, JSHTMLElement*, JSC::PutPropertySlot&);
     JSC::CallType runtimeObjectGetCallData(JSHTMLElement*, JSC::CallData&);
 
+    template <class Type, class Base> bool pluginElementCustomGetOwnPropertySlot(JSC::ExecState* exec, JSC::PropertyName propertyName, JSC::PropertySlot& slot, Type* element)
+    {
+        if (!element->globalObject()->world()->isNormal()) {
+            if (JSC::getStaticValueSlot<Type, Base>(exec, element->s_info.staticPropHashTable, element, propertyName, slot))
+                return true;
+
+            JSC::JSValue proto = element->prototype();
+            if (proto.isObject() && JSC::jsCast<JSC::JSObject*>(asObject(proto))->hasProperty(exec, propertyName))
+                return false;
+        }
+        
+        return runtimeObjectCustomGetOwnPropertySlot(exec, propertyName, slot, element);
+    }
+
+    template <class Type, class Base> bool pluginElementCustomGetOwnPropertyDescriptor(JSC::ExecState* exec, JSC::PropertyName propertyName, JSC::PropertyDescriptor& descriptor, Type* element)
+    {
+        if (!element->globalObject()->world()->isNormal()) {
+            if (JSC::getStaticValueDescriptor<Type, Base>(exec, element->s_info.staticPropHashTable, element, propertyName, descriptor))
+                return true;
+
+            JSC::JSValue proto = element->prototype();
+            if (proto.isObject() && JSC::jsCast<JSC::JSObject*>(asObject(proto))->hasProperty(exec, propertyName))
+                return false;
+        }
+
+        return runtimeObjectCustomGetOwnPropertyDescriptor(exec, propertyName, descriptor, element);
+    }
+
 } // namespace WebCore
 
 #endif // JSPluginElementFunctions_h

Modified: trunk/Tools/ChangeLog (123935 => 123936)


--- trunk/Tools/ChangeLog	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Tools/ChangeLog	2012-07-27 23:44:27 UTC (rev 123936)
@@ -1,3 +1,32 @@
+2012-07-27  Brady Eidson  <[email protected]>
+
+        Plugins should not be allowed to override standard properties/attributes in non-standard worlds
+        <rdar://problem/11975252> and https://bugs.webkit.org/show_bug.cgi?id=92519
+
+        Reviewed by Anders Carlsson.
+
+        Add a test plugin which overrides all properties it is asked about:
+        * DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableObjectOverridesAllProperties.cpp: Added.
+        (PluginScriptableObjectOverridesAllProperties):
+        (PluginScriptableObjectOverridesAllProperties::PluginScriptableObjectOverridesAllProperties):
+        (PluginObject):
+        (PluginScriptableObjectOverridesAllProperties::PluginObject::PluginObject):
+        (PluginScriptableObjectOverridesAllProperties::PluginObject::~PluginObject):
+        (PluginScriptableObjectOverridesAllProperties::PluginObject::hasProperty):
+        (PluginScriptableObjectOverridesAllProperties::PluginObject::getProperty):
+        (PluginScriptableObjectOverridesAllProperties::NPP_GetValue):
+
+        Expose NPN_MemAlloc to the test plugin:
+        * DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp:
+        (PluginTest::NPN_MemAlloc):
+        * DumpRenderTree/TestNetscapePlugIn/PluginTest.h:
+        (PluginTest):
+
+        * DumpRenderTree/DumpRenderTree.gypi:
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
+        * DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro:
+
 2012-07-27  Rafael Brandao  <[email protected]>
 
         "webkit-patch upload" should strip colors from patch if necessary

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.gypi (123935 => 123936)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.gypi	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.gypi	2012-07-27 23:44:27 UTC (rev 123936)
@@ -95,6 +95,7 @@
             'TestNetscapePlugIn/Tests/NullNPPGetValuePointer.cpp',
             'TestNetscapePlugIn/Tests/PassDifferentNPPStruct.cpp',
             'TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp',
+            'TestNetscapePlugIn/Tests/PluginScriptableObjectOverridesAllProperties.cpp',
             'TestNetscapePlugIn/Tests/PrivateBrowsing.cpp',
             'TestNetscapePlugIn/main.cpp',
         ],

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (123935 => 123936)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2012-07-27 23:44:27 UTC (rev 123936)
@@ -67,6 +67,7 @@
 		4437730E125CBC3600AAE02C /* WebArchiveDumpSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 44A997830FCDE86400580F10 /* WebArchiveDumpSupport.cpp */; };
 		4437730F125CBC4D00AAE02C /* WebArchiveDumpSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 44A997820FCDE86400580F10 /* WebArchiveDumpSupport.h */; };
 		4AD6A11413C8124000EA9737 /* FormValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AD6A11313C8124000EA9737 /* FormValue.cpp */; };
+		515F429C15C07872007C8F90 /* PluginScriptableObjectOverridesAllProperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515F429B15C07872007C8F90 /* PluginScriptableObjectOverridesAllProperties.cpp */; };
 		5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5185F69F10714A57007AA393 /* HistoryDelegate.mm */; };
 		5185F6B310714E12007AA393 /* HistoryDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5185F69E10714A57007AA393 /* HistoryDelegate.h */; };
 		53CBB832134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBB830134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp */; };
@@ -276,6 +277,7 @@
 		44A997820FCDE86400580F10 /* WebArchiveDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebArchiveDumpSupport.h; path = cf/WebArchiveDumpSupport.h; sourceTree = "<group>"; };
 		44A997830FCDE86400580F10 /* WebArchiveDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebArchiveDumpSupport.cpp; path = cf/WebArchiveDumpSupport.cpp; sourceTree = "<group>"; };
 		4AD6A11313C8124000EA9737 /* FormValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormValue.cpp; sourceTree = "<group>"; };
+		515F429B15C07872007C8F90 /* PluginScriptableObjectOverridesAllProperties.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginScriptableObjectOverridesAllProperties.cpp; sourceTree = "<group>"; };
 		5185F69E10714A57007AA393 /* HistoryDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HistoryDelegate.h; path = mac/HistoryDelegate.h; sourceTree = "<group>"; };
 		5185F69F10714A57007AA393 /* HistoryDelegate.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = HistoryDelegate.mm; path = mac/HistoryDelegate.mm; sourceTree = "<group>"; };
 		53CBB830134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CyclicRedundancyCheck.cpp; sourceTree = "<group>"; };
@@ -546,6 +548,7 @@
 				C0EC3C9B12787F0500939164 /* NullNPPGetValuePointer.cpp */,
 				C06F9ABB1267A7060058E1F6 /* PassDifferentNPPStruct.cpp */,
 				1AD9D2FD12028409001A70D1 /* PluginScriptableNPObjectInvokeDefault.cpp */,
+				515F429B15C07872007C8F90 /* PluginScriptableObjectOverridesAllProperties.cpp */,
 				1A1E4296141141C400388758 /* PrivateBrowsing.cpp */,
 			);
 			path = Tests;
@@ -895,6 +898,7 @@
 				1A14C8A51406DE0400B254F7 /* SupportsCarbonEventModel.cpp in Sources */,
 				1A1E4298141141C400388758 /* PrivateBrowsing.cpp in Sources */,
 				1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */,
+				515F429C15C07872007C8F90 /* PluginScriptableObjectOverridesAllProperties.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp (123935 => 123936)


--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp	2012-07-27 23:44:27 UTC (rev 123936)
@@ -166,6 +166,11 @@
     browser->invalidaterect(m_npp, invalidRect);
 }
 
+void* PluginTest::NPN_MemAlloc(uint32_t size)
+{
+    return browser->memalloc(size);
+}
+
 // NPRuntime NPN functions.
 
 NPIdentifier PluginTest::NPN_GetStringIdentifier(const NPUTF8 *name)

Modified: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h (123935 => 123936)


--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h	2012-07-27 23:44:27 UTC (rev 123936)
@@ -76,6 +76,7 @@
     NPError NPN_GetURLNotify(const char* url, const char* target, void* notifyData);
     NPError NPN_GetValue(NPNVariable, void* value);
     void NPN_InvalidateRect(NPRect* invalidRect);
+    void* NPN_MemAlloc(uint32_t size);
 
     // NPRuntime NPN functions.
     NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name);

Added: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableObjectOverridesAllProperties.cpp (0 => 123936)


--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableObjectOverridesAllProperties.cpp	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableObjectOverridesAllProperties.cpp	2012-07-27 23:44:27 UTC (rev 123936)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2012 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "PluginTest.h"
+
+#include <string.h>
+
+using namespace std;
+
+class PluginScriptableObjectOverridesAllProperties : public PluginTest {
+public:
+    PluginScriptableObjectOverridesAllProperties(NPP npp, const string& identifier)
+        : PluginTest(npp, identifier)
+    {
+    }
+    
+private:
+    class PluginObject : public Object<PluginObject> {
+    public:
+        PluginObject()
+        {
+        }
+
+        ~PluginObject()
+        {
+        }
+
+        bool hasProperty(NPIdentifier propertyName)
+        {
+            return true;
+        }
+
+        bool getProperty(NPIdentifier propertyName, NPVariant* result)
+        {
+            static const char* message = "My name is ";
+            char* propertyString = pluginTest()->NPN_UTF8FromIdentifier(propertyName);
+            
+            int bufferLength = strlen(propertyString) + strlen(message) + 1;
+            char* resultBuffer = static_cast<char*>(pluginTest()->NPN_MemAlloc(bufferLength));
+            snprintf(resultBuffer, bufferLength, "%s%s", message, propertyString);
+            
+            STRINGZ_TO_NPVARIANT(resultBuffer, *result);
+
+            return true;
+        }
+    };
+    
+    virtual NPError NPP_GetValue(NPPVariable variable, void *value)
+    {
+        if (variable != NPPVpluginScriptableNPObject)
+            return NPERR_GENERIC_ERROR;
+        
+        *(NPObject**)value = PluginObject::create(this);
+        
+        return NPERR_NO_ERROR;
+    }
+    
+};
+
+static PluginTest::Register<PluginScriptableObjectOverridesAllProperties> pluginScriptableObjectOverridesAllProperties("plugin-scriptable-object-overrides-all-properties");

Modified: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj (123935 => 123936)


--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj	2012-07-27 23:44:27 UTC (rev 123936)
@@ -450,6 +450,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\Tests\PluginScriptableObjectOverridesAllProperties.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\Tests\PrivateBrowsing.cpp"
 				>
 			</File>

Modified: trunk/Tools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro (123935 => 123936)


--- trunk/Tools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro	2012-07-27 23:32:19 UTC (rev 123935)
+++ trunk/Tools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro	2012-07-27 23:44:27 UTC (rev 123936)
@@ -28,6 +28,7 @@
     Tests/NullNPPGetValuePointer.cpp \
     Tests/PassDifferentNPPStruct.cpp \
     Tests/PluginScriptableNPObjectInvokeDefault.cpp \
+    Tests/PluginScriptableObjectOverridesAllProperties.cpp \
     Tests/PrivateBrowsing.cpp
 
 WEBKIT += webcore # For NPAPI headers
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to