| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /* | 5 /* |
| 6 * Copyright (C) 2011 Apple Inc. All rights reserved. | 6 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 public: | 37 public: |
| 38 NPDeallocateCalledBeforeNPShutdown(NPP npp, const string& identifier) | 38 NPDeallocateCalledBeforeNPShutdown(NPP npp, const string& identifier) |
| 39 : PluginTest(npp, identifier) | 39 : PluginTest(npp, identifier) |
| 40 { | 40 { |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 // This is the test object. | 44 // This is the test object. |
| 45 class TestObject : public Object<TestObject> { | 45 class TestObject : public Object<TestObject> { |
| 46 public: | 46 public: |
| 47 virtual ~TestObject() | 47 ~TestObject() override { |
| 48 { | |
| 49 if (wasShutdownCalled) | 48 if (wasShutdownCalled) |
| 50 indicateTestFailure(); | 49 indicateTestFailure(); |
| 51 } | 50 } |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 // This is the scriptable object. It has a single "testObject" property. | 53 // This is the scriptable object. It has a single "testObject" property. |
| 55 class ScriptableObject : public Object<ScriptableObject> { | 54 class ScriptableObject : public Object<ScriptableObject> { |
| 56 public: | 55 public: |
| 57 bool hasProperty(NPIdentifier propertyName) | 56 bool hasProperty(NPIdentifier propertyName) |
| 58 { | 57 { |
| 59 return propertyName == pluginTest()->NPN_GetStringIdentifier("testOb
ject"); | 58 return propertyName == pluginTest()->NPN_GetStringIdentifier("testOb
ject"); |
| 60 } | 59 } |
| 61 | 60 |
| 62 bool getProperty(NPIdentifier propertyName, NPVariant* result) | 61 bool getProperty(NPIdentifier propertyName, NPVariant* result) |
| 63 { | 62 { |
| 64 if (propertyName != pluginTest()->NPN_GetStringIdentifier("testObjec
t")) | 63 if (propertyName != pluginTest()->NPN_GetStringIdentifier("testObjec
t")) |
| 65 return false; | 64 return false; |
| 66 | 65 |
| 67 NPObject* testObject = TestObject::create(pluginTest()); | 66 NPObject* testObject = TestObject::create(pluginTest()); |
| 68 OBJECT_TO_NPVARIANT(testObject, *result); | 67 OBJECT_TO_NPVARIANT(testObject, *result); |
| 69 return true; | 68 return true; |
| 70 } | 69 } |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 virtual NPError NPP_New(NPMIMEType pluginType, | 72 NPError NPP_New(NPMIMEType pluginType, |
| 74 uint16_t mode, | 73 uint16_t mode, |
| 75 int16_t argc, | 74 int16_t argc, |
| 76 char* argn[], | 75 char* argn[], |
| 77 char* argv[], | 76 char* argv[], |
| 78 NPSavedData* saved) override { | 77 NPSavedData* saved) override { |
| 79 registerNPShutdownFunction(shutdown); | 78 registerNPShutdownFunction(shutdown); |
| 80 | 79 |
| 81 return NPERR_NO_ERROR; | 80 return NPERR_NO_ERROR; |
| 82 } | 81 } |
| 83 | 82 |
| 84 virtual NPError NPP_GetValue(NPPVariable variable, void *value) override | 83 NPError NPP_GetValue(NPPVariable variable, void* value) override { |
| 85 { | |
| 86 if (variable != NPPVpluginScriptableNPObject) | 84 if (variable != NPPVpluginScriptableNPObject) |
| 87 return NPERR_GENERIC_ERROR; | 85 return NPERR_GENERIC_ERROR; |
| 88 | 86 |
| 89 *(NPObject**)value = ScriptableObject::create(this); | 87 *(NPObject**)value = ScriptableObject::create(this); |
| 90 | 88 |
| 91 return NPERR_NO_ERROR; | 89 return NPERR_NO_ERROR; |
| 92 } | 90 } |
| 93 | 91 |
| 94 static void shutdown() | 92 static void shutdown() |
| 95 { | 93 { |
| 96 wasShutdownCalled = true; | 94 wasShutdownCalled = true; |
| 97 } | 95 } |
| 98 | 96 |
| 99 }; | 97 }; |
| 100 | 98 |
| 101 static PluginTest::Register<NPDeallocateCalledBeforeNPShutdown> npRuntimeObjectF
romDestroyedPlugin("np-deallocate-called-before-np-shutdown"); | 99 static PluginTest::Register<NPDeallocateCalledBeforeNPShutdown> npRuntimeObjectF
romDestroyedPlugin("np-deallocate-called-before-np-shutdown"); |
| 102 | 100 |
| OLD | NEW |