OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Holger Hans Peter Freyther | 3 * Copyright (C) 2009 Holger Hans Peter Freyther |
4 * Copyright (C) 2010 Collabora Ltd. | 4 * Copyright (C) 2010 Collabora Ltd. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 | 517 |
518 NPUTF8* callbackString = createCStringFromNPVariant(&args[0]); | 518 NPUTF8* callbackString = createCStringFromNPVariant(&args[0]); |
519 NPIdentifier callbackIdentifier = browser->getstringidentifier(callbackStrin
g); | 519 NPIdentifier callbackIdentifier = browser->getstringidentifier(callbackStrin
g); |
520 free(callbackString); | 520 free(callbackString); |
521 | 521 |
522 NPVariant browserResult; | 522 NPVariant browserResult; |
523 if (browser->invoke(obj->npp, windowScriptObject, callbackIdentifier, 0, 0,
&browserResult)) | 523 if (browser->invoke(obj->npp, windowScriptObject, callbackIdentifier, 0, 0,
&browserResult)) |
524 browser->releasevariantvalue(&browserResult); | 524 browser->releasevariantvalue(&browserResult); |
525 | 525 |
526 browser->releaseobject(windowScriptObject); | 526 browser->releaseobject(windowScriptObject); |
527 | 527 |
528 VOID_TO_NPVARIANT(*result); | 528 VOID_TO_NPVARIANT(*result); |
529 return true; | 529 return true; |
530 } | 530 } |
531 | 531 |
532 static bool testCallbackReturn(PluginObject* obj, const NPVariant* args, uint32_
t argCount, NPVariant* result) | 532 static bool testCallbackReturn(PluginObject* obj, const NPVariant* args, uint32_
t argCount, NPVariant* result) |
533 { | 533 { |
534 if (argCount != 1 || !NPVARIANT_IS_STRING(args[0])) | 534 if (argCount != 1 || !NPVARIANT_IS_STRING(args[0])) |
535 return false; | 535 return false; |
536 | 536 |
537 NPObject* windowScriptObject; | 537 NPObject* windowScriptObject; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 free(url); | 816 free(url); |
817 | 817 |
818 BOOLEAN_TO_NPVARIANT(error == NPERR_NO_ERROR, *result); | 818 BOOLEAN_TO_NPVARIANT(error == NPERR_NO_ERROR, *result); |
819 return true; | 819 return true; |
820 } | 820 } |
821 | 821 |
822 static bool testConstruct(PluginObject* obj, const NPVariant* args, uint32_t arg
Count, NPVariant* result) | 822 static bool testConstruct(PluginObject* obj, const NPVariant* args, uint32_t arg
Count, NPVariant* result) |
823 { | 823 { |
824 if (!argCount || !NPVARIANT_IS_OBJECT(args[0])) | 824 if (!argCount || !NPVARIANT_IS_OBJECT(args[0])) |
825 return false; | 825 return false; |
826 | 826 |
827 return browser->construct(obj->npp, NPVARIANT_TO_OBJECT(args[0]), args + 1,
argCount - 1, result); | 827 return browser->construct(obj->npp, NPVARIANT_TO_OBJECT(args[0]), args + 1,
argCount - 1, result); |
828 } | 828 } |
829 | 829 |
830 // Invoke a script callback to get a script NPObject. Then call a method on the | 830 // Invoke a script callback to get a script NPObject. Then call a method on the |
831 // script NPObject passing it a freshly created NPObject. | 831 // script NPObject passing it a freshly created NPObject. |
832 static bool testScriptObjectInvoke(PluginObject* obj, const NPVariant* args, uin
t32_t argCount, NPVariant* result) | 832 static bool testScriptObjectInvoke(PluginObject* obj, const NPVariant* args, uin
t32_t argCount, NPVariant* result) |
833 { | 833 { |
834 if (argCount != 2 || !NPVARIANT_IS_STRING(args[0]) || !NPVARIANT_IS_STRING(a
rgs[1])) | 834 if (argCount != 2 || !NPVARIANT_IS_STRING(args[0]) || !NPVARIANT_IS_STRING(a
rgs[1])) |
835 return false; | 835 return false; |
836 NPObject* windowScriptObject; | 836 NPObject* windowScriptObject; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 return true; | 971 return true; |
972 } | 972 } |
973 | 973 |
974 static bool testSetStatus(PluginObject* obj, const NPVariant* args, uint32_t arg
Count, NPVariant* result) | 974 static bool testSetStatus(PluginObject* obj, const NPVariant* args, uint32_t arg
Count, NPVariant* result) |
975 { | 975 { |
976 char* message = 0; | 976 char* message = 0; |
977 if (argCount && NPVARIANT_IS_STRING(args[0])) { | 977 if (argCount && NPVARIANT_IS_STRING(args[0])) { |
978 NPString statusString = NPVARIANT_TO_STRING(args[0]); | 978 NPString statusString = NPVARIANT_TO_STRING(args[0]); |
979 message = toCString(statusString); | 979 message = toCString(statusString); |
980 } | 980 } |
981 | 981 |
982 browser->status(obj->npp, message); | 982 browser->status(obj->npp, message); |
983 | 983 |
984 free(message); | 984 free(message); |
985 return true; | 985 return true; |
986 } | 986 } |
987 | 987 |
988 static bool testResizeTo(PluginObject* obj, const NPVariant* args, uint32_t argC
ount, NPVariant* result) | 988 static bool testResizeTo(PluginObject* obj, const NPVariant* args, uint32_t argC
ount, NPVariant* result) |
989 { | 989 { |
990 VOID_TO_NPVARIANT(*result); | 990 VOID_TO_NPVARIANT(*result); |
991 | 991 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 } | 1286 } |
1287 | 1287 |
1288 void testNPRuntime(NPP npp) | 1288 void testNPRuntime(NPP npp) |
1289 { | 1289 { |
1290 NPObject* windowScriptObject; | 1290 NPObject* windowScriptObject; |
1291 browser->getvalue(npp, NPNVWindowNPObject, &windowScriptObject); | 1291 browser->getvalue(npp, NPNVWindowNPObject, &windowScriptObject); |
1292 | 1292 |
1293 // Invoke | 1293 // Invoke |
1294 NPIdentifier testNPInvoke = browser->getstringidentifier("testNPInvoke"); | 1294 NPIdentifier testNPInvoke = browser->getstringidentifier("testNPInvoke"); |
1295 NPVariant args[7]; | 1295 NPVariant args[7]; |
1296 | 1296 |
1297 VOID_TO_NPVARIANT(args[0]); | 1297 VOID_TO_NPVARIANT(args[0]); |
1298 NULL_TO_NPVARIANT(args[1]); | 1298 NULL_TO_NPVARIANT(args[1]); |
1299 BOOLEAN_TO_NPVARIANT(true, args[2]); | 1299 BOOLEAN_TO_NPVARIANT(true, args[2]); |
1300 INT32_TO_NPVARIANT(242, args[3]); | 1300 INT32_TO_NPVARIANT(242, args[3]); |
1301 DOUBLE_TO_NPVARIANT(242.242, args[4]); | 1301 DOUBLE_TO_NPVARIANT(242.242, args[4]); |
1302 STRINGZ_TO_NPVARIANT("Hello, World", args[5]); | 1302 STRINGZ_TO_NPVARIANT("Hello, World", args[5]); |
1303 OBJECT_TO_NPVARIANT(windowScriptObject, args[6]); | 1303 OBJECT_TO_NPVARIANT(windowScriptObject, args[6]); |
1304 | 1304 |
1305 NPVariant result; | 1305 NPVariant result; |
1306 if (browser->invoke(npp, windowScriptObject, testNPInvoke, args, 7, &result)
) | 1306 if (browser->invoke(npp, windowScriptObject, testNPInvoke, args, 7, &result)
) |
1307 browser->releasevariantvalue(&result); | 1307 browser->releasevariantvalue(&result); |
1308 | 1308 |
1309 browser->releaseobject(windowScriptObject); | 1309 browser->releaseobject(windowScriptObject); |
1310 } | 1310 } |
OLD | NEW |