Roll src/third_party/WebKit a452221:9ff6d11 (svn 202117:202119)
[chromium-blink-merge.git] / content / shell / tools / plugin / Tests / LeakWindowScriptableObject.cpp
blob3b68c5ba72e2b54b218b231bddd673df104fe8c1
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"
7 using namespace std;
9 class LeakWindowScriptableObject : public PluginTest {
10 public:
11 LeakWindowScriptableObject(NPP npp, const string& identifier)
12 : PluginTest(npp, identifier)
16 private:
17 NPError NPP_New(NPMIMEType pluginType,
18 uint16_t mode,
19 int16_t argc,
20 char* argn[],
21 char* argv[],
22 NPSavedData* saved) override {
23 // Get a new reference to the window script object.
24 NPObject* window;
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");