Bug 145528

Summary: [Content Extensions] resource-type and load-type should be independent
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: WebCore Misc.Assignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, japhet
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch benjamin: review+

Description Alex Christensen 2015-06-01 15:08:48 PDT
Right now we use the same uint16_t to store all the load-type and resource-type flags, then we just do a bitwise and to check both at the same time.  This results in a trigger with load-type and resource-type firing if either condition is met, not both conditions.  A trigger with both resource-type and load-type conditions should only fire if both conditions are met.
Comment 1 Alex Christensen 2015-06-01 15:12:02 PDT
Created attachment 254015 [details]
Patch
Comment 2 Benjamin Poulain 2015-06-01 15:32:58 PDT
Comment on attachment 254015 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=254015&action=review

> Source/WebCore/ChangeLog:8
> +        Covered by existing tests and a new API test.

IMHO, you should explain the bug here. Having the explanation in bugzilla is not enough.

> Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp:81
> +    bool shouldAppendAction = false;
> +    if (shouldCheckLoadType && shouldCheckResourceType)
> +        shouldAppendAction = (flagsToCheck & LoadTypeMask & flags) && (flagsToCheck & ResourceTypeMask & flags);
> +    else if (shouldCheckLoadType)
> +        shouldAppendAction = flagsToCheck & LoadTypeMask & flags;
> +    else {
> +        ASSERT(shouldCheckResourceType);
> +        shouldAppendAction = flagsToCheck & ResourceTypeMask & flags;
> +    }

What about:

uint16_t loadTypeFlags = flagsToCheck & LoadTypeMask;
uint16_t ressourceTypeFlags = flagsToCheck & ResourceTypeMask;

bool loadTypeMatches = loadTypeFlags ? (loadTypeFlags & flags) : true;
bool ressourceTypeMatches = ressourceTypeFlags ? (ressourceTypeFlags & flags) : true;

if (loadTypeMatches && ressourceTypeMatches)
   ...
Comment 3 Alex Christensen 2015-06-01 15:34:31 PDT
rdar://problem/21190765
Comment 4 Alex Christensen 2015-06-01 15:41:22 PDT
http://trac.webkit.org/changeset/185079