• Devlin Cronin's avatar
    [Extensions] Split up ScriptContext::GetEffectiveDocumentURL() · b8d8feed
    Devlin Cronin authored
    ScriptContext::GetEffectiveDocumentURL() is used to
    1) Classify javascript contexts (e.g., associating about:blank frames
       with an extension context), and
    2) Determining an "effective" URL for script injection (to allow content
       scripts to run in about:blank frames if an extension has access to
       the parent).
    
    However, these have different traits. For instance, for case 1), we
    don't want to consider sandboxed frames (which cannot access their
    parent frames) - a sandboxed frame should not inherit its privileges.
    But for case 2), we want to consider sandboxed frames, so that content
    scripts can run in these.
    
    Split ScriptContext::GetEffectiveDocumentURL() into
    ScriptContext::GetEffectiveDocumentURLForContext() and
    ScriptContext::GetEffectiveDocumentURLForInjection() to account for
    these differences; this fixes an issue where scripts wouldn't correctly
    inject in sandboxed frames. Modify existing tests for both
    GetEffectiveDocumentURL() and injecting scripts in sandboxed frames.
    
    This also paves some more of the way to injecting in data: URLs.
    
    Bug: 1108505, 55084
    Change-Id: I97707b7bba520f8177f59a4568971df543f69785
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2314810
    Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
    Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#792349}
    b8d8feed
script_context_set.cc 9.13 KB