LayoutTests:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Mar 2007 19:31:02 +0000 (19:31 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Mar 2007 19:31:02 +0000 (19:31 +0000)
        Reviewed by Adam, Darin.

        <rdar://problem/5025212>
        In Mail, a crash occurs at WebCore::Frame::tree() when clicking on embedded flash object

        * plugins/get-url-with-blank-target-expected.txt: Added.
        * plugins/get-url-with-blank-target.html: Added.

WebKit:

        Reviewed by Adam, Darin.

        <rdar://problem/5025212>
        In Mail, a crash occurs at WebCore::Frame::tree() when clicking on embedded flash object

        * Plugins/WebBaseNetscapePluginView.mm:
        (-[WebBaseNetscapePluginView loadPluginRequest:]):
        Handle the case where the web view returned from the delegate method is null. Also, send out an error notification
        in that case so we can catch it.

WebKitTools:

        Reviewed by Adam, Darin.

        <rdar://problem/5025212>
        In Mail, a crash occurs at WebCore::Frame::tree() when clicking on embedded flash object

        Add a "getURLNotify" method to the plugin object. This lets you pass a URL, a target and a callback function
        to be run when the URL has finished (or failed) loading.

        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
        (pluginInvoke):
        (handleCallback):
        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
        * DumpRenderTree/TestNetscapePlugIn.subproj/main.c:
        (NPP_URLNotify):

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

LayoutTests/ChangeLog
LayoutTests/plugins/get-url-with-blank-target-expected.txt [new file with mode: 0644]
LayoutTests/plugins/get-url-with-blank-target.html [new file with mode: 0644]
WebKit/ChangeLog
WebKit/Plugins/WebBaseNetscapePluginView.mm
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.c

index 46320c1..d2d746e 100644 (file)
@@ -1,3 +1,13 @@
+2007-03-05  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Adam, Darin.
+
+        <rdar://problem/5025212>
+        In Mail, a crash occurs at WebCore::Frame::tree() when clicking on embedded flash object
+
+        * plugins/get-url-with-blank-target-expected.txt: Added.
+        * plugins/get-url-with-blank-target.html: Added.
+
 2007-03-05  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin.
diff --git a/LayoutTests/plugins/get-url-with-blank-target-expected.txt b/LayoutTests/plugins/get-url-with-blank-target-expected.txt
new file mode 100644 (file)
index 0000000..115d0b9
--- /dev/null
@@ -0,0 +1,3 @@
+ This tests that we won't crash when a plugin tries to open an URL in a new window when the application does not create the window. If this test is successful, the text SUCCESS should be seen below.
+SUCCESS
+
diff --git a/LayoutTests/plugins/get-url-with-blank-target.html b/LayoutTests/plugins/get-url-with-blank-target.html
new file mode 100644 (file)
index 0000000..5ce907e
--- /dev/null
@@ -0,0 +1,29 @@
+<html>
+<body>
+<embed name="plg" type="application/x-webkit-test-netscape"></embed>
+<script>
+var NPERR_GENERIC_ERROR = 1;
+
+function callback(result) {
+    var d = document.getElementById('result');
+
+    if (result == NPERR_GENERIC_ERROR)
+        d.innerHTML = "SUCCESS"
+    else
+        d.innerHTML = "FAILED - Expected error code 1 but got error code " + result
+
+    layoutTestController.notifyDone();
+}
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+    
+    plg.getURLNotify("http://www.apple.com", "_blank", "callback");
+} else {
+    document.write("Cannot run interactively");
+}
+</script>This tests that we won't crash when a plugin tries to open an URL in a new window when the application does not create the window. If this test is successful, the word SUCCESS should be seen below.
+<div id="result">FAILED</div>
+</body>
+</html>
index 890057e..d1ed81d 100644 (file)
@@ -1,3 +1,15 @@
+2007-03-05  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Adam, Darin.
+        <rdar://problem/5025212>
+        In Mail, a crash occurs at WebCore::Frame::tree() when clicking on embedded flash object
+
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (-[WebBaseNetscapePluginView loadPluginRequest:]):
+        Handle the case where the web view returned from the delegate method is null. Also, send out an error notification
+        in that case so we can catch it.
+
 2007-03-05  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Darin and Kevin D
index 984bb3a..a7ca2db 100644 (file)
@@ -1978,6 +1978,16 @@ static OSStatus TSMEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEve
             } else {
                 newWebView = [[WebDefaultUIDelegate sharedUIDelegate] webView:currentWebView createWebViewWithRequest:nil];
             }
+            
+            if (!newWebView) {
+                if ([pluginRequest sendNotification]) {
+                    [self willCallPlugInFunction];
+                    NPP_URLNotify(plugin, [[[pluginRequest request] URL] _web_URLCString], NPERR_GENERIC_ERROR, [pluginRequest notifyData]);
+                    [self didCallPlugInFunction];
+                }
+                return;
+            }
+            
             frame = [newWebView mainFrame];
             core(frame)->tree()->setName(frameName);
             [[newWebView _UIDelegateForwarder] webViewShow:newWebView];
index 3b820aa..9ca76d6 100644 (file)
@@ -1,3 +1,20 @@
+2007-03-05  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Adam, Darin.
+
+        <rdar://problem/5025212>
+        In Mail, a crash occurs at WebCore::Frame::tree() when clicking on embedded flash object
+        
+        Add a "getURLNotify" method to the plugin object. This lets you pass a URL, a target and a callback function
+        to be run when the URL has finished (or failed) loading.
+        
+        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
+        (pluginInvoke):
+        (handleCallback):
+        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
+        * DumpRenderTree/TestNetscapePlugIn.subproj/main.c:
+        (NPP_URLNotify):
+
 2007-03-04  Krzysztof Kowalczyk  <kkowalczyk@gmail.com>
 
         Reviewed by Nikolas Zimmermann.
index 4d68f93..78bce0e 100644 (file)
@@ -79,15 +79,17 @@ static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
 #define ID_TEST_GETURL              1
 #define ID_REMOVE_DEFAULT_METHOD    2
 #define ID_TEST_DOM_ACCESS          3
+#define ID_TEST_GET_URL_NOTIFY      4
 
-#define NUM_METHOD_IDENTIFIERS      4
+#define NUM_METHOD_IDENTIFIERS      5
 
 static NPIdentifier pluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
 static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
     "testCallback",
     "getURL",
     "removeDefaultMethod",
-    "testDOMAccess"
+    "testDOMAccess",
+    "getURLNotify",
 };
 
 static NPUTF8* createCStringFromNPVariant(const NPVariant *variant)
@@ -209,6 +211,22 @@ static bool pluginInvoke(NPObject *header, NPIdentifier name, const NPVariant *a
         testDOMAccess(obj);
         VOID_TO_NPVARIANT(*result);
         return true;
+    } else if (name == pluginMethodIdentifiers[ID_TEST_GET_URL_NOTIFY]) {
+        if (argCount == 3 && NPVARIANT_IS_STRING(args[0]) && NPVARIANT_IS_STRING(args[1]) && NPVARIANT_IS_STRING(args[2])) {
+            NPUTF8* urlString = createCStringFromNPVariant(&args[0]);
+            NPUTF8* targetString = createCStringFromNPVariant(&args[1]);            
+            NPUTF8* callbackString = createCStringFromNPVariant(&args[2]);
+            
+            NPIdentifier callbackIdentifier = browser->getstringidentifier(callbackString);
+            browser->geturlnotify(obj->npp, urlString, targetString, callbackIdentifier);
+
+            free(urlString);
+            free(targetString);
+            free(callbackString);
+            
+            VOID_TO_NPVARIANT(*result);
+            return true;
+        }
     }
 
     return false;
@@ -244,3 +262,21 @@ static void pluginDeallocate(NPObject *obj)
 {
     free(obj);
 }
+
+void handleCallback(PluginObject* object, const char *url, NPReason reason, void *notifyData)
+{
+    assert(object);
+    
+    NPVariant args[1];
+    
+    NPObject *windowScriptObject;
+    browser->getvalue(object->npp, NPPVpluginScriptableNPObject, &windowScriptObject);
+    
+    NPIdentifier callbackIdentifier = notifyData;
+
+    INT32_TO_NPVARIANT(reason, args[0]);
+
+    NPVariant browserResult;
+    browser->invoke(object->npp, windowScriptObject, callbackIdentifier, args, 1, &browserResult);
+    browser->releasevariantvalue(&browserResult);
+}
index 93296dd..ac35a54 100644 (file)
@@ -42,3 +42,4 @@ typedef struct {
 } PluginObject;
 
 extern NPClass *getPluginClass(void);
+extern void handleCallback(PluginObject* object, const char *url, NPReason reason, void *notifyData);
index 9ad97ac..fb21368 100644 (file)
@@ -192,6 +192,9 @@ int16 NPP_HandleEvent(NPP instance, void *event)
 
 void NPP_URLNotify(NPP instance, const char *url, NPReason reason, void *notifyData)
 {
+    PluginObject *obj = instance->pdata;
+        
+    handleCallback(obj, url, reason, notifyData);
 }
 
 NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)