1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "webkit/plugins/npapi/test/plugin_npobject_proxy_test.h"
namespace NPAPIClient {
NPObjectProxyTest::NPObjectProxyTest(NPP id, NPNetscapeFuncs *host_functions)
: PluginTest(id, host_functions) {
}
NPError NPObjectProxyTest::SetWindow(NPWindow* pNPWindow) {
#if !defined(OS_MACOSX)
if (pNPWindow->window == NULL)
return NPERR_NO_ERROR;
#endif
NPIdentifier document_id = HostFunctions()->getstringidentifier("document");
NPIdentifier create_text_node_id = HostFunctions()->getstringidentifier("createTextNode");
NPIdentifier append_child_id = HostFunctions()->getstringidentifier("appendChild");
NPVariant docv;
NPObject *window_obj = NULL;
HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window_obj);
HostFunctions()->getproperty(id(), window_obj, document_id, &docv);
NPObject *doc = NPVARIANT_TO_OBJECT(docv);
NPVariant strv;
MSVC_SUPPRESS_WARNING(4267);
STRINGZ_TO_NPVARIANT("div", strv);
NPVariant textv;
HostFunctions()->invoke(id(), doc, create_text_node_id, &strv, 1, &textv);
NPVariant v;
HostFunctions()->invoke(id(), doc, append_child_id, &textv, 1, &v);
// If this test failed, then we'd have crashed by now.
SignalTestCompleted();
return NPERR_NO_ERROR;
}
} // namespace NPAPIClient
|