OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include <stdint.h> | |
6 | |
7 #include "PluginTest.h" | |
8 | |
9 using namespace std; | |
10 | |
11 class LeakWindowScriptableObject : public PluginTest { | |
12 public: | |
13 LeakWindowScriptableObject(NPP npp, const string& identifier) | |
14 : PluginTest(npp, identifier) | |
15 { | |
16 } | |
17 | |
18 private: | |
19 NPError NPP_New(NPMIMEType pluginType, | |
20 uint16_t mode, | |
21 int16_t argc, | |
22 char* argn[], | |
23 char* argv[], | |
24 NPSavedData* saved) override { | |
25 // Get a new reference to the window script object. | |
26 NPObject* window; | |
27 if (NPN_GetValue(NPNVWindowNPObject, &window) != NPERR_NO_ERROR) { | |
28 log("Fail: Cannot fetch window script object"); | |
29 return NPERR_NO_ERROR; | |
30 } | |
31 | |
32 // Get another reference to the same object via window.self. | |
33 NPIdentifier self_name = NPN_GetStringIdentifier("self"); | |
34 NPVariant window_self_variant; | |
35 if (!NPN_GetProperty(window, self_name, &window_self_variant)) { | |
36 log("Fail: Cannot query window.self"); | |
37 return NPERR_NO_ERROR; | |
38 } | |
39 if (!NPVARIANT_IS_OBJECT(window_self_variant)) { | |
40 log("Fail: window.self is not an object"); | |
41 return NPERR_NO_ERROR; | |
42 } | |
43 | |
44 // Leak both references to the window script object. | |
45 return NPERR_NO_ERROR; | |
46 } | |
47 }; | |
48 | |
49 static PluginTest::Register<LeakWindowScriptableObject> leakWindowScriptableObje
ct("leak-window-scriptable-object"); | |
OLD | NEW |