Home | History | Annotate | Download | only in plugin
      1 // Copyright (c) 2011 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 "content/test/plugin/plugin_npobject_proxy_test.h"
      6 
      7 #include "base/basictypes.h"
      8 #include "base/compiler_specific.h"
      9 
     10 namespace NPAPIClient {
     11 
     12 NPObjectProxyTest::NPObjectProxyTest(NPP id, NPNetscapeFuncs *host_functions)
     13   : PluginTest(id, host_functions) {
     14 }
     15 
     16 NPError NPObjectProxyTest::SetWindow(NPWindow* pNPWindow) {
     17 #if !defined(OS_MACOSX)
     18   if (pNPWindow->window == NULL)
     19     return NPERR_NO_ERROR;
     20 #endif
     21 
     22   NPIdentifier document_id = HostFunctions()->getstringidentifier("document");
     23   NPIdentifier create_text_node_id = HostFunctions()->getstringidentifier("createTextNode");
     24   NPIdentifier append_child_id = HostFunctions()->getstringidentifier("appendChild");
     25 
     26   NPVariant docv;
     27   NPObject *window_obj = NULL;
     28   HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window_obj);
     29 
     30   HostFunctions()->getproperty(id(), window_obj, document_id, &docv);
     31   NPObject *doc = NPVARIANT_TO_OBJECT(docv);
     32 
     33   NPVariant strv;
     34   MSVC_SUPPRESS_WARNING(4267);
     35   STRINGZ_TO_NPVARIANT("div", strv);
     36 
     37   NPVariant textv;
     38   HostFunctions()->invoke(id(), doc, create_text_node_id, &strv, 1, &textv);
     39 
     40   NPVariant v;
     41   HostFunctions()->invoke(id(), doc, append_child_id, &textv, 1, &v);
     42 
     43   // If this test failed, then we'd have crashed by now.
     44   SignalTestCompleted();
     45 
     46   return NPERR_NO_ERROR;
     47 }
     48 
     49 } // namespace NPAPIClient
     50