Changeset 218956 in webkit


Ignore:
Timestamp:
Jun 29, 2017 12:31:36 PM (7 years ago)
Author:
achristensen@apple.com
Message:

WKContentRuleLists with if-top-url or unless-top-url should run regex against entire top URL
https://bugs.webkit.org/show_bug.cgi?id=173980

Reviewed by Tim Horton.

Source/WebKit2:

if-top-url and unless-top-url were broken inside WebKit2 apps. This fixes them and adds a test.
ContentExtension::populateConditionCacheIfNeeded was calling WebCompiledContentRuleList::conditionsApplyOnlyToDomain
but m_data.conditionsApplyOnlyToDomainOffset was always 0 instead of ConditionsApplyOnlyToDomainOffset because
it wasn't being encoded and decoded when telling the WebProcess about the content rule list. This was causing us
to use whatever was at offset 0 in the file instead of the correct value stored in the file to determine
whether to run regular expressions against the entire top URL for if-top-url or unless-top-url or against
just the domain for if-top-domain or unless-top-domain. Luckily, offset 0 in the file is always
ContentRuleListStore::CurrentContentRuleListFileVersion, so it was deterministic and easy to debug.

I should have added a LayoutTest with r213669 to verify correct behavior in an actual WKWebView,
but I didn't because it wouldn't have caught regressions since the contentextension tests are
marked as flaky since r206914, but once that is fixed the new test http/tests/contentextensions/top-url.html
will verify that this feature is behaving correctly. It failed before this change and passes after.

  • Shared/WebCompiledContentRuleListData.cpp:

(WebKit::WebCompiledContentRuleListData::encode):
(WebKit::WebCompiledContentRuleListData::decode):

LayoutTests:

  • http/tests/contentextensions/top-url-expected.txt: Added.
  • http/tests/contentextensions/top-url.html: Added.
  • http/tests/contentextensions/top-url.html.json: Added.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r218951 r218956  
     12017-06-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        WKContentRuleLists with if-top-url or unless-top-url should run regex against entire top URL
     4        https://bugs.webkit.org/show_bug.cgi?id=173980
     5
     6        Reviewed by Tim Horton.
     7
     8        * http/tests/contentextensions/top-url-expected.txt: Added.
     9        * http/tests/contentextensions/top-url.html: Added.
     10        * http/tests/contentextensions/top-url.html.json: Added.
     11
    1122017-06-29  JF Bastien  <jfbastien@apple.com>
    213
  • trunk/Source/WebKit2/ChangeLog

    r218953 r218956  
     12017-06-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        WKContentRuleLists with if-top-url or unless-top-url should run regex against entire top URL
     4        https://bugs.webkit.org/show_bug.cgi?id=173980
     5
     6        Reviewed by Tim Horton.
     7
     8        if-top-url and unless-top-url were broken inside WebKit2 apps.  This fixes them and adds a test.
     9        ContentExtension::populateConditionCacheIfNeeded was calling WebCompiledContentRuleList::conditionsApplyOnlyToDomain
     10        but m_data.conditionsApplyOnlyToDomainOffset was always 0 instead of ConditionsApplyOnlyToDomainOffset because
     11        it wasn't being encoded and decoded when telling the WebProcess about the content rule list.  This was causing us
     12        to use whatever was at offset 0 in the file instead of the correct value stored in the file to determine
     13        whether to run regular expressions against the entire top URL for if-top-url or unless-top-url or against
     14        just the domain for if-top-domain or unless-top-domain.  Luckily, offset 0 in the file is always
     15        ContentRuleListStore::CurrentContentRuleListFileVersion, so it was deterministic and easy to debug.
     16
     17        I should have added a LayoutTest with r213669 to verify correct behavior in an actual WKWebView,
     18        but I didn't because it wouldn't have caught regressions since the contentextension tests are
     19        marked as flaky since r206914, but once that is fixed the new test http/tests/contentextensions/top-url.html
     20        will verify that this feature is behaving correctly.  It failed before this change and passes after.
     21
     22        * Shared/WebCompiledContentRuleListData.cpp:
     23        (WebKit::WebCompiledContentRuleListData::encode):
     24        (WebKit::WebCompiledContentRuleListData::decode):
     25
    1262017-06-29  Chris Dumez  <cdumez@apple.com>
    227
  • trunk/Source/WebKit2/Shared/WebCompiledContentRuleListData.cpp

    r216809 r218956  
    3939    encoder << handle;
    4040
     41    encoder << conditionsApplyOnlyToDomainOffset;
    4142    encoder << actionsOffset;
    4243    encoder << actionsSize;
     
    5657    compiledContentRuleListData.data = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
    5758
     59    if (!decoder.decode(compiledContentRuleListData.conditionsApplyOnlyToDomainOffset))
     60        return false;
    5861    if (!decoder.decode(compiledContentRuleListData.actionsOffset))
    5962        return false;
Note: See TracChangeset for help on using the changeset viewer.