[Content Extensions] Correctly handle regular expressions matching everything
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Mar 2015 00:48:30 +0000 (00:48 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Mar 2015 00:48:30 +0000 (00:48 +0000)
commite778e10c37d0df5d5ffa50c253f4e74fe414f413
tree23b1cc6f042e910e83a6cee43475bb061b7cf207
parentdc1d7de0a79783866e5db57076af442696dac884
[Content Extensions] Correctly handle regular expressions matching everything
https://bugs.webkit.org/show_bug.cgi?id=143235

Reviewed by Benjamin Poulain.

Source/WebCore:

Test: http/tests/contentextensions/whitelist.html

* contentextensions/CompiledContentExtension.cpp:
(WebCore::ContentExtensions::CompiledContentExtension::globalDisplayNoneSelectors):
Global actions can have non-css actions.  Only put the selectors into the list of selectors.
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::serializeSelector):
(WebCore::ContentExtensions::serializeActions):
Merge sequential css selectors with identical triggers (usually .*) into one action to reduce the number of actions.
(WebCore::ContentExtensions::compileRuleList):
Fail if a regular expression matches everything after ignore-previous-rules.
* contentextensions/ContentExtensionError.cpp:
(WebCore::ContentExtensions::contentExtensionErrorCategory):
* contentextensions/ContentExtensionError.h:
Add more failure cases.
* contentextensions/ContentExtensionRule.h:
(WebCore::ContentExtensions::Trigger::operator==):
Allow comparing of Triggers to determine if sequential triggers are equal.
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad):
Put non-css actions that match everything into the list of actions if ignore-previous-rules was not hit.
These actions will be out of order, but order only matters when determining if ignore-previous-rules, and this case is handled correctly.
* contentextensions/DFABytecodeInterpreter.cpp:
(WebCore::ContentExtensions::DFABytecodeInterpreter::actionsFromDFARoot):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
Added an assertion that all actions that match everything should be in the first DFA root.
We should catch them all with URLFilterParser::MatchesEverything.

Tools:

* TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::checkCompilerError):
(TestWebKitAPI::TEST_F):
Test ContentExtensionErrors.

LayoutTests:

* http/tests/contentextensions/css-display-none.html:
* http/tests/contentextensions/css-display-none.html.json:
Test multiple selectors with triggers that match everything.
* http/tests/contentextensions/whitelist-expected.txt: Added.
* http/tests/contentextensions/whitelist.html: Added.
* http/tests/contentextensions/whitelist.html.json: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182168 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/contentextensions/css-display-none.html
LayoutTests/http/tests/contentextensions/css-display-none.html.json
LayoutTests/http/tests/contentextensions/whitelist-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/contentextensions/whitelist.html [new file with mode: 0644]
LayoutTests/http/tests/contentextensions/whitelist.html.json [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/contentextensions/CompiledContentExtension.cpp
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
Source/WebCore/contentextensions/ContentExtensionError.cpp
Source/WebCore/contentextensions/ContentExtensionError.h
Source/WebCore/contentextensions/ContentExtensionRule.h
Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp