コード例 #1
0
   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      NodeList acronymList;
      Node testNode;
      NamedNodeMap attributes;
      Attr titleAttr;
      String value;
      Node textNode;
      Node retval;
      Node lastChild;
      Document otherDoc;
      doc = (Document) baseT::load("hc_staff", true);
      otherDoc = (Document) baseT::load("hc_staff", true);
      acronymList = doc.getElementsByTagName(SA::construct_from_utf8("acronym"));
      testNode = acronymList.item(3);
      attributes = testNode.getAttributes();
      titleAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("title"));
      textNode = otherDoc.createTextNode(SA::construct_from_utf8("terday"));
      
      {
         boolean success = false;
         try {
            retval = titleAttr.appendChild(textNode);
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::WRONG_DOCUMENT_ERR);
         }
         assertTrue(success);
      }

   }
コード例 #2
0
JSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionGetNamedItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSNamedNodeMap::s_info))
        return throwError(exec, TypeError);
    JSNamedNodeMap* castedThisObj = static_cast<JSNamedNodeMap*>(asObject(thisValue));
    NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThisObj->impl());
    const UString& name = args.at(0).toString(exec);


    JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->getNamedItem(name)));
    return result;
}
コード例 #3
0
ファイル: JSNamedNodeMap.cpp プロジェクト: 13W/phantomjs
EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionGetNamedItem(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSNamedNodeMap::s_info))
        return throwVMTypeError(exec);
    JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(thisValue));
    NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl());
    const String& name(ustringToString(exec->argument(0).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->getNamedItem(name)));
    return JSValue::encode(result);
}
コード例 #4
0
   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      NodeList genderList;
      Node gender;
      NodeList genList;
      Node gen;
      NodeList gList;
      Node g;
      NamedNodeMap attrList;
      Attr attrNode;
      doc = (Document) baseT::load("staff", true);
      genderList = doc.getElementsByTagName(SA::construct_from_utf8("gender"));
      gender = genderList.item(2);
      baseT::assertNotNull(gender, __LINE__, __FILE__);
      genList = gender.getChildNodes();
      gen = genList.item(0);
      baseT::assertNotNull(gen, __LINE__, __FILE__);
      gList = gen.getChildNodes();
      g = gList.item(0);
      baseT::template skipIfNot<EntityReference>(g);
     baseT::assertNotNull(g, __LINE__, __FILE__);
      attrList = g.getAttributes();
      baseT::assertNotNull(attrList, __LINE__, __FILE__);
      attrNode = (Attr) attrList.getNamedItem(SA::construct_from_utf8("domestic"));
      baseT::assertNotNull(attrNode, __LINE__, __FILE__);
      
      {
         boolean success = false;
         try {
            attrNode.setValue(SA::construct_from_utf8("newvalue"));
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::NO_MODIFICATION_ALLOWED_ERR);
         }
         assertTrue(success);
      }

      {
         boolean success = false;
         try {
            attrNode.setNodeValue(SA::construct_from_utf8("newvalue2"));
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::NO_MODIFICATION_ALLOWED_ERR);
         }
         assertTrue(success);
      }

   }
コード例 #5
0
v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.NamedNodeMap.NamedPropertyGetter");

    if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
        return v8::Handle<v8::Value>();
    if (info.Holder()->HasRealNamedCallbackProperty(name))
        return v8::Handle<v8::Value>();

    NamedNodeMap* imp = V8NamedNodeMap::toNative(info.Holder());
    RefPtr<Node> result = imp->getNamedItem(toWebCoreString(name));
    if (!result)
        return v8::Handle<v8::Value>();

    return toV8(result.release(), info.GetIsolate());
}
コード例 #6
0
 /*
  * Runs the test case.
  */
 void runTest()
 {
    Document doc;
    NodeList addressList;
    Node testNode;
    NamedNodeMap attributes;
    Attr domesticAttr;
    Node s;
    doc = (Document) baseT::load("staff", false);
    addressList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
    testNode = addressList.item(0);
    attributes = testNode.getAttributes();
    domesticAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("domestic"));
    s = domesticAttr.getPreviousSibling();
    baseT::assertNull(s, __LINE__, __FILE__);
    
 }
コード例 #7
0
  /*
   * Runs the test case.
   */
  void runTest()
  {
     Document doc;
     NodeList addressList;
     Node testNode;
     NamedNodeMap attributes;
     Attr domesticAttr;
     String value;
     doc = (Document) baseT::load("hc_staff", false);
     addressList = doc.getElementsByTagName(SA::construct_from_utf8("acronym"));
     testNode = addressList.item(0);
     attributes = testNode.getAttributes();
     domesticAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("title"));
     value = domesticAttr.getNodeValue();
     baseT::assertEquals("Yes", value, __LINE__, __FILE__);
 
  }
コード例 #8
0
  /*
   * Runs the test case.
   */
  void runTest()
  {
     Document doc;
     NodeList elementList;
     Node testEmployee;
     NamedNodeMap attributes;
     Attr domesticAttr;
     String attrName;
     doc = (Document) baseT::load("staff", false);
     elementList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
     testEmployee = elementList.item(1);
     attributes = testEmployee.getAttributes();
     domesticAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("domestic"));
     attrName = domesticAttr.getNodeName();
     baseT::assertEquals("domestic", attrName, __LINE__, __FILE__);
 
  }
コード例 #9
0
    /*
     * Runs the test case.
     */
    void runTest()
    {
        Document doc;
        DocumentType docType;
        NamedNodeMap notations;
        Node notationNode;
        String notationName;
        doc = (Document) baseT::load("staff", false);
        docType = doc.getDoctype();
        baseT::assertNotNull(docType, __LINE__, __FILE__);
        notations = docType.getNotations();
        baseT::assertNotNull(notations, __LINE__, __FILE__);
        notationNode = notations.getNamedItem(SA::construct_from_utf8("notation1"));
        baseT::skipIfNull(notationNode);
        notationName = notationNode.getNodeName();
        baseT::assertEquals("notation1", notationName, __LINE__, __FILE__);

    }
コード例 #10
0
   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      DocumentType docType;
      NamedNodeMap notations;
      Notation notationNode;
      String systemId;
      doc = (Document) baseT::load("staff", false);
      docType = doc.getDoctype();
      baseT::assertNotNull(docType, __LINE__, __FILE__);
      notations = docType.getNotations();
      baseT::assertNotNull(notations, __LINE__, __FILE__);
      notationNode = (Notation) notations.getNamedItem(SA::construct_from_utf8("notation2"));
      baseT::skipIfNull(notationNode);
      systemId = notationNode.getSystemId();
      baseT::assertURIEquals("uriEquals", "", "", "", "notation2File", "", "", "", false, systemId);

   }
コード例 #11
0
  /*
   * Runs the test case.
   */
  void runTest()
  {
     Document doc;
     DocumentType docType;
     NamedNodeMap entities;
     Node entityNode;
     String entityName;
     doc = (Document) baseT::load("staff", false);
     docType = doc.getDoctype();
     baseT::assertNotNull(docType, __LINE__, __FILE__);
     entities = docType.getEntities();
     baseT::assertNotNull(entities, __LINE__, __FILE__);
     entityNode = entities.getNamedItem(SA::construct_from_utf8("ent1"));
     baseT::assertNotNull(entityNode, __LINE__, __FILE__);
     entityName = entityNode.getNodeName();
     baseT::assertEquals("ent1", entityName, __LINE__, __FILE__);
 
  }
コード例 #12
0
 /*
  * Runs the test case.
  */
 void runTest()
 {
    Document doc;
    DocumentType docType;
    NamedNodeMap notations;
    Notation notationNode;
    String publicId;
    doc = (Document) baseT::load("staff", false);
    docType = doc.getDoctype();
    baseT::assertNotNull(docType, __LINE__, __FILE__);
    notations = docType.getNotations();
    baseT::assertNotNull(notations, __LINE__, __FILE__);
    notationNode = (Notation) notations.getNamedItem(SA::construct_from_utf8("notation2"));
    baseT::skipIfNull(notationNode);
    publicId = notationNode.getPublicId();
    baseT::assertNull(publicId, __LINE__, __FILE__);
    
 }
コード例 #13
0
   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      NodeList addressList;
      Node testNode;
      NamedNodeMap attributes;
      Attr streetAttr;
      boolean state;
      doc = (Document) baseT::load("staff", true);
      addressList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
      testNode = addressList.item(2);
      ((Element) /*Node */testNode).removeAttribute(SA::construct_from_utf8("street"));
      attributes = testNode.getAttributes();
      streetAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("street"));
      baseT::skipIfNull(streetAttr);
      state = streetAttr.getSpecified();
      assertFalse(state);

   }
コード例 #14
0
 /*
  * Runs the test case.
  */
 void runTest()
 {
    Document doc;
    DocumentType docType;
    NamedNodeMap entities;
    Node entityNode;
    String entityValue;
    doc = (Document) baseT::load("staff", true);
    docType = doc.getDoctype();
    baseT::assertNotNull(docType, __LINE__, __FILE__);
    entities = docType.getEntities();
    baseT::assertNotNull(entities, __LINE__, __FILE__);
    entityNode = entities.getNamedItem(SA::construct_from_utf8("ent1"));
    baseT::assertNotNull(entityNode, __LINE__, __FILE__);
    entityNode.setNodeValue(SA::construct_from_utf8("This should have no effect"));
    entityValue = entityNode.getNodeValue();
    baseT::assertNull(entityValue, __LINE__, __FILE__);
    
 }
コード例 #15
0
ファイル: hc_attrname.hpp プロジェクト: QuentinFiard/arabica
  /*
   * Runs the test case.
   */
  void runTest()
  {
     Document doc;
     NodeList addressList;
     Node testNode;
     NamedNodeMap attributes;
     Attr streetAttr;
     String strong1;
     String strong2;
     doc = (Document) baseT::load("hc_staff", false);
     addressList = doc.getElementsByTagName(SA::construct_from_utf8("acronym"));
     testNode = addressList.item(1);
     attributes = testNode.getAttributes();
     streetAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("class"));
     strong1 = streetAttr.getNodeName();
     strong2 = streetAttr.getName();
     baseT::assertEquals("class", strong1, __LINE__, __FILE__);
 baseT::assertEquals("class", strong2, __LINE__, __FILE__);
 
  }
コード例 #16
0
v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.NamedNodeMap.NamedPropertyGetter");
    // Search the prototype chain first.
    v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name);
    if (!value.IsEmpty())
        return value;

    // Then look for IDL defined properties on the object itself.
    if (info.Holder()->HasRealNamedCallbackProperty(name))
        return notHandledByInterceptor();

    // Finally, search the DOM.
    NamedNodeMap* imp = V8NamedNodeMap::toNative(info.Holder());
    RefPtr<Node> result = imp->getNamedItem(toWebCoreString(name));
    if (!result)
        return notHandledByInterceptor();

    return toV8(result.release());
}
コード例 #17
0
 /*
  * Runs the test case.
  */
 void runTest()
 {
    Document doc;
    DocumentType docType;
    NamedNodeMap entityList;
    Node entity;
    doc = (Document) baseT::load("staff", false);
    docType = doc.getDoctype();
    baseT::assertNotNull(docType, __LINE__, __FILE__);
    entityList = docType.getEntities();
    baseT::assertNotNull(entityList, __LINE__, __FILE__);
    entity = entityList.getNamedItem(SA::construct_from_utf8("ent5"));
    baseT::skipIfNull(entity);
    
    if (("image/svg+xml" == baseT::getContentType())) {
        baseT::assertSize(7, entityList, __LINE__, __FILE__);
    } else {
        baseT::assertSize(5, entityList, __LINE__, __FILE__);
    }
      
  
 }
コード例 #18
0
 /*
  * Runs the test case.
  */
 void runTest()
 {
    Document doc;
    NodeList addressList;
    Node testAddress;
    NamedNodeMap attributes;
    DocumentType docType;
    NamedNodeMap notations;
    Notation notationNode;
    String notationName;
    doc = (Document) baseT::load("staff", false);
    docType = doc.getDoctype();
    baseT::assertNotNull(docType, __LINE__, __FILE__);
    notations = docType.getNotations();
    baseT::assertNotNull(notations, __LINE__, __FILE__);
    notationNode = (Notation) notations.getNamedItem(SA::construct_from_utf8("notation1"));
    baseT::skipIfNull(notationNode);
    addressList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
    testAddress = addressList.item(0);
    attributes = testAddress.getAttributes();
    baseT::assertSize(2, attributes, __LINE__, __FILE__);
    
 }
コード例 #19
0
   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      DocumentType docType;
      NamedNodeMap entityList;
      Entity entityNode;
      String publicId;
      String systemId;
      String notation;
      doc = (Document) baseT::load("staff", false);
      docType = doc.getDoctype();
      baseT::assertNotNull(docType, __LINE__, __FILE__);
      entityList = docType.getEntities();
      baseT::assertNotNull(entityList, __LINE__, __FILE__);
      entityNode = (Entity) entityList.getNamedItem(SA::construct_from_utf8("ent5"));
      baseT::skipIfNull(entityNode);
      publicId = entityNode.getPublicId();
      baseT::assertEquals("entityURI", publicId, __LINE__, __FILE__);
  systemId = entityNode.getSystemId();
      baseT::assertURIEquals("systemId", "", "", "", "entityFile", "", "", "", false, systemId);
notation = entityNode.getNotationName();
      baseT::assertEquals("notation1", notation, __LINE__, __FILE__);
  
   }