|
Make WebNode::to<Type>() (and toConst) casts contain type asserts.
Previously you could cast a WebNode to any subclass and then call invalid
methods on it resulting in invalid address access. Instead we change the
to<Type>() and toConst<Type>() casting methods to contain type checks just
like the toFoo() casting methods inside Blink. This will catch the bad casts
early by crashing on an ASSERT_WITH_SECURITY_IMPLICATION.
These new asserts caught bad casts inside WebFrameTest where it was casting
a WebElement(div) into a WebInputElement. It also caught one in the
form_autofill_browsertest where it was casting a WebElement(textarea) to a
WebInputElement.
Finally I fixed a case of this I found inside form_autofill_util.cc's
MatchLabelsAndFields method which converted correspondingControl() to a
WebFormControlElement without checking if it was one first. This code was
actually safe since it always checked isFormControlElement() on the
WebFormControlElement afterwards, but doing that is super subtle.
This also lets us remove the usage of nodeType() in the WebViewTest.cpp
since now the to<WebElement>() calls contain asserts, and with that being
the last usage of nodeType() we can remove WebNode::nodeType() completely.
Committed: https://crrev.com/740cd24e4e3db9f160462f7bf861929b18e4861f
Cr-Commit-Position: refs/heads/master@{#350944}
Total comments: 4
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+116 lines, -80 lines) |
Patch |
 |
M |
chrome/renderer/autofill/form_autofill_browsertest.cc
|
View
|
1
2
3
4
|
2 chunks |
+25 lines, -1 line |
0 comments
|
Download
|
 |
M |
components/autofill/content/renderer/form_autofill_util.cc
|
View
|
1
2
|
2 chunks |
+7 lines, -8 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/AssertMatchingEnums.cpp
|
View
|
1
2
|
1 chunk |
+0 lines, -10 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebDocument.cpp
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebDocumentType.cpp
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebElement.cpp
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebFormControlElement.cpp
|
View
|
1
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebFormElement.cpp
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebInputElement.cpp
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebLabelElement.cpp
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebNode.cpp
|
View
|
1
2
|
2 chunks |
+5 lines, -5 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebOptionElement.cpp
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebPluginDocument.cpp
|
View
|
1
2
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebSelectElement.cpp
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebTextAreaElement.cpp
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
View
|
1
2
3
4
5
|
4 chunks |
+0 lines, -4 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
View
|
1
2
|
5 chunks |
+0 lines, -11 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebDocument.h
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebDocumentType.h
|
View
|
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebElement.h
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebFormControlElement.h
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebFormElement.h
|
View
|
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebInputElement.h
|
View
|
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebLabelElement.h
|
View
|
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebNode.h
|
View
|
1
2
3
4
5
6
|
4 chunks |
+27 lines, -33 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebOptionElement.h
|
View
|
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebPluginDocument.h
|
View
|
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebSelectElement.h
|
View
|
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebTextAreaElement.h
|
View
|
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
Total messages: 32 (14 generated)
|