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

Side by Side Diff: third_party/WebKit/Source/core/svg/UnsafeSVGAttributeSanitizationTest.cpp

Issue 2617783002: Migrate WTF::Vector::append() to ::push_back() [part 12 of N] (Closed)
Patch Set: rebase Created 3 years, 11 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // FIXME(dominicc): Poor confused check-webkit-style demands Attribute.h here. 5 // FIXME(dominicc): Poor confused check-webkit-style demands Attribute.h here.
6 #include "core/dom/Attribute.h" 6 #include "core/dom/Attribute.h"
7 7
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/SVGNames.h" 9 #include "core/SVGNames.h"
10 #include "core/XLinkNames.h" 10 #include "core/XLinkNames.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 280
281 // Sanity check that href was identified as a "string" attribute 281 // Sanity check that href was identified as a "string" attribute
282 EXPECT_EQ(AnimatedString, element->animatedPropertyType()); 282 EXPECT_EQ(AnimatedString, element->animatedPropertyType());
283 283
284 EXPECT_FALSE(element->animatedPropertyTypeSupportsAddition()); 284 EXPECT_FALSE(element->animatedPropertyTypeSupportsAddition());
285 } 285 }
286 286
287 TEST(UnsafeSVGAttributeSanitizationTest, 287 TEST(UnsafeSVGAttributeSanitizationTest,
288 stripScriptingAttributes_animateElement) { 288 stripScriptingAttributes_animateElement) {
289 Vector<Attribute> attributes; 289 Vector<Attribute> attributes;
290 attributes.append(Attribute(XLinkNames::hrefAttr, "javascript:alert()")); 290 attributes.push_back(Attribute(XLinkNames::hrefAttr, "javascript:alert()"));
291 attributes.append(Attribute(SVGNames::hrefAttr, "javascript:alert()")); 291 attributes.push_back(Attribute(SVGNames::hrefAttr, "javascript:alert()"));
292 attributes.append(Attribute(SVGNames::fromAttr, "/home")); 292 attributes.push_back(Attribute(SVGNames::fromAttr, "/home"));
293 attributes.append(Attribute(SVGNames::toAttr, "javascript:own3d()")); 293 attributes.push_back(Attribute(SVGNames::toAttr, "javascript:own3d()"));
294 294
295 Document* document = Document::create(); 295 Document* document = Document::create();
296 Element* element = SVGAnimateElement::create(*document); 296 Element* element = SVGAnimateElement::create(*document);
297 element->stripScriptingAttributes(attributes); 297 element->stripScriptingAttributes(attributes);
298 298
299 EXPECT_EQ(3ul, attributes.size()) 299 EXPECT_EQ(3ul, attributes.size())
300 << "One of the attributes should have been stripped."; 300 << "One of the attributes should have been stripped.";
301 EXPECT_EQ(XLinkNames::hrefAttr, attributes[0].name()) 301 EXPECT_EQ(XLinkNames::hrefAttr, attributes[0].name())
302 << "The 'xlink:href' attribute should not have been stripped from " 302 << "The 'xlink:href' attribute should not have been stripped from "
303 "<animate> because it is not a URL attribute of <animate>."; 303 "<animate> because it is not a URL attribute of <animate>.";
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 Attribute fineAttribute(SVGNames::fromAttr, "hello, world!"); 383 Attribute fineAttribute(SVGNames::fromAttr, "hello, world!");
384 Document* document = Document::create(); 384 Document* document = Document::create();
385 Element* element = SVGSetElement::create(*document); 385 Element* element = SVGSetElement::create(*document);
386 EXPECT_FALSE( 386 EXPECT_FALSE(
387 element->isSVGAnimationAttributeSettingJavaScriptURL(fineAttribute)) 387 element->isSVGAnimationAttributeSettingJavaScriptURL(fineAttribute))
388 << "The animate element should not identify a 'from' attribute with an " 388 << "The animate element should not identify a 'from' attribute with an "
389 "innocuous value as setting a JavaScript URL."; 389 "innocuous value as setting a JavaScript URL.";
390 } 390 }
391 391
392 } // namespace blink 392 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698