Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: Source/bindings/v8/custom/V8DocumentCustom.cpp

Issue 111533002: Have document.evaluate() report TypeError over incorrect resolvers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: The detail argument is no longer optional. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/v8/ExceptionMessages.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 #include "V8Document.h" 32 #include "V8Document.h"
33 33
34 #include "V8CanvasRenderingContext2D.h" 34 #include "V8CanvasRenderingContext2D.h"
35 #include "V8DOMImplementation.h" 35 #include "V8DOMImplementation.h"
36 #include "V8Node.h" 36 #include "V8Node.h"
37 #include "V8Touch.h" 37 #include "V8Touch.h"
38 #include "V8TouchList.h" 38 #include "V8TouchList.h"
39 #include "V8WebGLRenderingContext.h" 39 #include "V8WebGLRenderingContext.h"
40 #include "V8XPathNSResolver.h" 40 #include "V8XPathNSResolver.h"
41 #include "V8XPathResult.h" 41 #include "V8XPathResult.h"
42 #include "bindings/v8/ExceptionMessages.h"
42 #include "bindings/v8/ExceptionState.h" 43 #include "bindings/v8/ExceptionState.h"
43 #include "bindings/v8/ScriptController.h" 44 #include "bindings/v8/ScriptController.h"
44 #include "bindings/v8/V8Binding.h" 45 #include "bindings/v8/V8Binding.h"
45 #include "bindings/v8/V8DOMWrapper.h" 46 #include "bindings/v8/V8DOMWrapper.h"
46 #include "bindings/v8/custom/V8CustomXPathNSResolver.h" 47 #include "bindings/v8/custom/V8CustomXPathNSResolver.h"
47 #include "core/dom/Document.h" 48 #include "core/dom/Document.h"
48 #include "core/dom/ExceptionCode.h" 49 #include "core/dom/ExceptionCode.h"
49 #include "core/dom/Node.h" 50 #include "core/dom/Node.h"
50 #include "core/dom/TouchList.h" 51 #include "core/dom/TouchList.h"
51 #include "core/html/canvas/CanvasRenderingContext.h" 52 #include "core/html/canvas/CanvasRenderingContext.h"
52 #include "core/frame/Frame.h" 53 #include "core/frame/Frame.h"
53 #include "core/xml/DocumentXPathEvaluator.h" 54 #include "core/xml/DocumentXPathEvaluator.h"
54 #include "core/xml/XPathNSResolver.h" 55 #include "core/xml/XPathNSResolver.h"
55 #include "core/xml/XPathResult.h" 56 #include "core/xml/XPathResult.h"
56 #include "wtf/RefPtr.h" 57 #include "wtf/RefPtr.h"
57 58
58 namespace WebCore { 59 namespace WebCore {
59 60
60 void V8Document::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) 61 void V8Document::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
61 { 62 {
62 RefPtr<Document> document = V8Document::toNative(info.Holder()); 63 RefPtr<Document> document = V8Document::toNative(info.Holder());
63 ExceptionState exceptionState(ExceptionState::ExecutionContext, "evaluate", "Document", info.Holder(), info.GetIsolate()); 64 ExceptionState exceptionState(ExceptionState::ExecutionContext, "evaluate", "Document", info.Holder(), info.GetIsolate());
64 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, expression, info[0] ); 65 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, expression, info[0] );
65 RefPtr<Node> contextNode; 66 RefPtr<Node> contextNode;
66 if (V8Node::hasInstance(info[1], info.GetIsolate(), worldType(info.GetIsolat e()))) 67 if (V8Node::hasInstance(info[1], info.GetIsolate(), worldType(info.GetIsolat e())))
67 contextNode = V8Node::toNative(v8::Handle<v8::Object>::Cast(info[1])); 68 contextNode = V8Node::toNative(v8::Handle<v8::Object>::Cast(info[1]));
68 69
69 RefPtr<XPathNSResolver> resolver = toXPathNSResolver(info[2], info.GetIsolat e()); 70 const int resolverArgumentIndex = 2;
70 if (!resolver && !info[2]->IsNull() && !info[2]->IsUndefined()) { 71 RefPtr<XPathNSResolver> resolver = toXPathNSResolver(info[resolverArgumentIn dex], info.GetIsolate());
71 setDOMException(TypeMismatchError, info.GetIsolate()); 72 if (!resolver && !isUndefinedOrNull(info[resolverArgumentIndex])) {
73 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(r esolverArgumentIndex + 1, "is not a resolver function."));
74 exceptionState.throwIfNeeded();
72 return; 75 return;
73 } 76 }
74 77
75 int type = toInt32(info[3]); 78 int type = toInt32(info[3]);
76 RefPtr<XPathResult> inResult; 79 RefPtr<XPathResult> inResult;
77 if (V8XPathResult::hasInstance(info[4], info.GetIsolate(), worldType(info.Ge tIsolate()))) 80 if (V8XPathResult::hasInstance(info[4], info.GetIsolate(), worldType(info.Ge tIsolate())))
78 inResult = V8XPathResult::toNative(v8::Handle<v8::Object>::Cast(info[4]) ); 81 inResult = V8XPathResult::toNative(v8::Handle<v8::Object>::Cast(info[4]) );
79 82
80 V8TRYCATCH_VOID(RefPtr<XPathResult>, result, DocumentXPathEvaluator::evaluat e(document.get(), expression, contextNode.get(), resolver.release(), type, inRes ult.get(), exceptionState)); 83 V8TRYCATCH_VOID(RefPtr<XPathResult>, result, DocumentXPathEvaluator::evaluat e(document.get(), expression, contextNode.get(), resolver.release(), type, inRes ult.get(), exceptionState));
81 if (exceptionState.throwIfNeeded()) 84 if (exceptionState.throwIfNeeded())
82 return; 85 return;
83 86
84 v8SetReturnValueFast(info, result.release(), document.get()); 87 v8SetReturnValueFast(info, result.release(), document.get());
85 } 88 }
86 89
87 } // namespace WebCore 90 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/ExceptionMessages.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698