Reviewed by Anders Carlsson.
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Mar 2010 22:42:16 +0000 (22:42 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Mar 2010 22:42:16 +0000 (22:42 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=36327
        Test that a plug-in can override Node methods of its element

        * plugins/override-node-method-expected.txt: Added.
        * plugins/override-node-method.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@56198 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/plugins/override-node-method-expected.txt [new file with mode: 0644]
LayoutTests/plugins/override-node-method.html [new file with mode: 0644]
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp

index a4bea80..e56e782 100644 (file)
@@ -1,3 +1,13 @@
+2010-03-18  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        https://bugs.webkit.org/show_bug.cgi?id=36327
+        Test that a plug-in can override Node methods of its element
+
+        * plugins/override-node-method-expected.txt: Added.
+        * plugins/override-node-method.html: Added.
+
 2010-03-18  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dave Hyatt.
diff --git a/LayoutTests/plugins/override-node-method-expected.txt b/LayoutTests/plugins/override-node-method-expected.txt
new file mode 100644 (file)
index 0000000..cec67dd
--- /dev/null
@@ -0,0 +1,5 @@
+ALERT: PASS
+
+Test that a plug-in can override Node methods of its element. This also means that the plug-in is instantiated when accessing properties and methods of its owner element.
+
+Should alert PASS.
diff --git a/LayoutTests/plugins/override-node-method.html b/LayoutTests/plugins/override-node-method.html
new file mode 100644 (file)
index 0000000..d82da50
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+<body>
+<embed name="plg" type="application/x-webkit-test-netscape"></embed>
+<p>Test that a plug-in can override Node methods of its element. This also means that the plug-in
+is instantiated when accessing properties and methods of its owner element.</p>
+<p>Should alert PASS.</p>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    function pluginCallback() { alert("PASS") }
+
+    try {
+        plg.normalize();
+    } catch (ex) {
+        alert("Exception: " + ex.description + ". Test plugin was not found");
+    }
+</script>
+</body>
+</html>
index fb6b17c..fd787c5 100644 (file)
@@ -1,3 +1,15 @@
+2010-03-18  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        https://bugs.webkit.org/show_bug.cgi?id=36327
+        Test that a plug-in can override Node methods of its element
+
+        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp:
+        (normalizeOverride):
+        (pluginInvoke):
+        Override "normalize", and call back to let a test know that the plug-in was called.
+
 2010-03-17  Dirk Pranke  <dpranke@chromium.org>
 
         Reviewed by Dimitri Glazkov.
index 3a6b8c0..1f0f11b 100644 (file)
@@ -185,6 +185,7 @@ enum {
     ID_REF_COUNT,
     ID_SET_STATUS,
     ID_RESIZE_TO,
+    ID_NORMALIZE,
     NUM_METHOD_IDENTIFIERS
 };
 
@@ -221,6 +222,7 @@ static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
     "refCount",
     "setStatus",
     "resizeTo",
+    "normalize"
 };
 
 static NPUTF8* createCStringFromNPVariant(const NPVariant* variant)
@@ -821,6 +823,22 @@ static bool testResizeTo(PluginObject* obj, const NPVariant* args, uint32_t argC
     return true;
 }
 
+static bool normalizeOverride(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+    VOID_TO_NPVARIANT(*result);
+
+    NPObject* windowObject;
+    if (NPERR_NO_ERROR != browser->getvalue(obj->npp, NPNVWindowNPObject, &windowObject))
+        return false;
+
+    NPVariant callResult;
+    if (browser->invoke(obj->npp, windowObject, browser->getstringidentifier("pluginCallback"), args, argCount, &callResult))
+        browser->releasevariantvalue(&callResult);
+
+    return true;
+}
+
+
 static bool pluginInvoke(NPObject* header, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
     PluginObject* plugin = reinterpret_cast<PluginObject*>(header);
@@ -906,6 +924,8 @@ static bool pluginInvoke(NPObject* header, NPIdentifier name, const NPVariant* a
         return testSetStatus(plugin, args, argCount, result);
     else if (name == pluginMethodIdentifiers[ID_RESIZE_TO])
         return testResizeTo(plugin, args, argCount, result);
+    else if (name == pluginMethodIdentifiers[ID_NORMALIZE])
+        return normalizeOverride(plugin, args, argCount, result);
     
     return false;
 }