• Ian Clelland's avatar
    Add stream printer for WebSandboxFlags · 5fb64779
    Ian Clelland authored
    This allows debug messages to print sandbox flags in a convenient binary
    format, rather than outputting them as decimal numbers or 4-byte arrays.
    
    This means that you can easily add debug statements for sandboxing code like:
    
    DLOG(INFO) << "The sandbox flags here look like " << sandbox_flags_;
    
    rather than having to cast:
    
    DLOG(INFO) << "The sandbox flags here look like " <<
        std::bitset<32>(static_cast<int>(sandbox_flags_));
    
    It also changes the test output from EXPECT_EQ failures from looking like:
    
    ../../content/browser/some_browsertest.cc:12345: Failure
          Expected: blink::WebSandboxFlags::kAll & ~blink::WebSandboxFlags::kScripts & ~blink::WebSandboxFlags::kAutomaticFeatures
          Which is: 4-byte object <6F-FF FF-FF>
    To be equal to: root->child_at(1)->effective_frame_policy().sandbox_flags
          Which is: 4-byte object <FF-FA FF-FF>
    
    to the more reasonable:
    
    ../../content/browser/some_browsertest.cc:12345: Failure
          Expected: blink::WebSandboxFlags::kAll & ~blink::WebSandboxFlags::kScripts & ~blink::WebSandboxFlags::kAutomaticFeatures
          Which is: 11111111111111111111111101101111
    To be equal to: root->child_at(1)->effective_frame_policy().sandbox_flags
          Which is: 11111111111111111111101011111111
    
    in which single bit errors can easily be spotted.
    
    Change-Id: Ibc9020d67654c555e1c70dcb99829e2eb29d0b3c
    Reviewed-on: https://chromium-review.googlesource.com/772320Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
    Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
    Commit-Queue: Ian Clelland <iclelland@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#574151}
    5fb64779
sandbox_flags.h 1.98 KB