Reviewed by Maciej.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Mar 2006 20:30:58 +0000 (20:30 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Mar 2006 20:30:58 +0000 (20:30 +0000)
        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7708
        REGRESSION: Flash callback to JavaScript function not working.

        Test: plugins/invoke.html

        * bindings/c/c_utility.cpp:
        (KJS::Bindings::convertUTF8ToUTF16): Return a correct string length.

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

JavaScriptCore/ChangeLog
JavaScriptCore/bindings/c/c_utility.cpp
LayoutTests/ChangeLog
LayoutTests/plugins/invoke-expected.txt [new file with mode: 0644]
LayoutTests/plugins/invoke.html [new file with mode: 0644]

index 0ff207f69cc0d94eb18eea34936f6b7574ed0265..7c492b5eeb3ac4011948a53f1d721cb59605f2a9 100644 (file)
@@ -1,3 +1,15 @@
+2006-03-12  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Maciej.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7708
+        REGRESSION: Flash callback to JavaScript function not working.
+
+        Test: plugins/invoke.html
+
+        * bindings/c/c_utility.cpp:
+        (KJS::Bindings::convertUTF8ToUTF16): Return a correct string length.
+
 2006-03-08  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by darin.
index 8eb1ac5e2257be0bf1e348c261146698c9b68963..c1d13167e12d75835e70645a1db3bb2560dbc401 100644 (file)
@@ -62,7 +62,7 @@ void convertUTF8ToUTF16(const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16
     if (U_SUCCESS(status)) { 
         *UTF16Chars = (NPUTF16 *)malloc(sizeof(NPUTF16) * (*UTF16Length));
         ucnv_setToUCallBack(conv, UCNV_TO_U_CALLBACK_STOP, 0, 0, 0, &status);
-        ucnv_toUChars(conv, *UTF16Chars, *UTF16Length, UTF8Chars, UTF8Length, &status); 
+        *UTF16Length = ucnv_toUChars(conv, *UTF16Chars, *UTF16Length, UTF8Chars, UTF8Length, &status); 
         ucnv_close(conv);
     } 
     
@@ -71,12 +71,13 @@ void convertUTF8ToUTF16(const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16
     // There is no "bad data" for latin1. It is unlikely that the plugin was really sending text in this encoding,
     // but it should have used UTF-8, and now we are simply avoiding a crash.
     if (!U_SUCCESS(status)) {
+        *UTF16Length = UTF8Length;
+        
         if (!*UTF16Chars)   // If the memory wasn't allocated, allocate it.
             *UTF16Chars = (NPUTF16 *)malloc(sizeof(NPUTF16) * (*UTF16Length));
  
         for (unsigned i = 0; i < *UTF16Length; i++)
             (*UTF16Chars)[i] = UTF8Chars[i] & 0xFF;
-
     }
 }
 
index b9207b2bb6608a5ad79de697b9bc1e249237b35e..41e7e19c6d97f3bab1baac7ae2a9033c09ac92f4 100644 (file)
@@ -1,3 +1,13 @@
+2006-03-12  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Maciej.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=7708
+        REGRESSION: Flash callback to JavaScript function not working.
+
+        * plugins/invoke-expected.txt: Added.
+        * plugins/invoke.html: Added.
+
 2006-03-12  David Kilzer  <ddkilzer@kilzer.net>
 
         Reviewed by Darin, landed by ap.
diff --git a/LayoutTests/plugins/invoke-expected.txt b/LayoutTests/plugins/invoke-expected.txt
new file mode 100644 (file)
index 0000000..f6bba76
--- /dev/null
@@ -0,0 +1,5 @@
+
+Test for bug 7708: REGRESSION: Flash callback to JavaScript function not working.
+
+SUCCESS
+
diff --git a/LayoutTests/plugins/invoke.html b/LayoutTests/plugins/invoke.html
new file mode 100644 (file)
index 0000000..677c31e
--- /dev/null
@@ -0,0 +1,25 @@
+<html>
+<body>
+<embed name="plg" type="application/x-webkit-test-netscape"></embed>
+<p>Test for <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=7708">bug 7708</a>:
+REGRESSION: Flash callback to JavaScript function not working.</p>
+<div id=res>FAILURE</div>
+<script>
+
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+    
+    function MyCallback() {
+        document.getElementById('res').innerHTML = 'SUCCESS';
+    }
+    
+    try {
+        
+        plg.testCallback('MyCallback');
+
+    } catch (ex) {
+        alert("Exception: " + ex.description);
+    }
+</script>
+</body>
+</html>