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.
5 #include "PluginTest.h"
9 class LeakWindowScriptableObject : public PluginTest {
11 LeakWindowScriptableObject(NPP npp, const string& identifier)
12 : PluginTest(npp, identifier)
17 virtual NPError NPP_New(NPMIMEType pluginType,
22 NPSavedData* saved) OVERRIDE {
23 // Get a new reference to the window script object.
25 if (NPN_GetValue(NPNVWindowNPObject, &window) != NPERR_NO_ERROR) {
26 log("Fail: Cannot fetch window script object");
27 return NPERR_NO_ERROR;
30 // Get another reference to the same object via window.self.
31 NPIdentifier self_name = NPN_GetStringIdentifier("self");
32 NPVariant window_self_variant;
33 if (!NPN_GetProperty(window, self_name, &window_self_variant)) {
34 log("Fail: Cannot query window.self");
35 return NPERR_NO_ERROR;
37 if (!NPVARIANT_IS_OBJECT(window_self_variant)) {
38 log("Fail: window.self is not an object");
39 return NPERR_NO_ERROR;
42 // Leak both references to the window script object.
43 return NPERR_NO_ERROR;
47 static PluginTest::Register<LeakWindowScriptableObject> leakWindowScriptableObject("leak-window-scriptable-object");