chromium/third_party/blink/web_tests/fast/dom/HTMLIFrameElement/sandbox-feature-detection.html

<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
    test(function() {
        var iframe = document.createElement("iframe");
        // Test that setting sandbox is working, for both valid and invalid values
        iframe.sandbox = "whatever";
        assert_true(iframe.sandbox.contains("whatever"));
        iframe.sandbox = "allow-forms";
        assert_true(iframe.sandbox.contains("allow-forms"));
        // Test that "add()" works
        iframe.sandbox.add("allow-formssss");
        assert_equals(iframe.sandbox.value, "allow-forms allow-formssss");
        assert_true(iframe.sandbox.contains("allow-formssss"));
        // Test that "supports()" is returning true for valid values and false for invalid ones
        assert_false(iframe.sandbox.supports("bogus"));
        assert_false(iframe.sandbox.supports("allow-formssss"));
        assert_true(iframe.sandbox.supports("allow-forms"));
        assert_true(iframe.sandbox.supports("allow-modals"));
        assert_true(iframe.sandbox.supports("allow-orientation-lock"));
        assert_true(iframe.sandbox.supports("allow-pointer-lock"));
        assert_true(iframe.sandbox.supports("allow-popups"));
        assert_true(iframe.sandbox.supports("allow-popups-to-escape-sandbox"));
        assert_true(iframe.sandbox.supports("allow-presentation"));
        assert_true(iframe.sandbox.supports("allow-same-origin"));
        assert_true(iframe.sandbox.supports("allow-scripts"));
        assert_true(iframe.sandbox.supports("allow-top-navigation"));
        assert_true(iframe.sandbox.supports("allow-top-navigation-by-user-activation"));
        assert_true(iframe.sandbox.supports("allow-downloads"));
        // Test that "supports()" does a case-insensitive comparison
        assert_true(iframe.sandbox.supports("ALLOW-FORMS"));
        assert_true(iframe.sandbox.supports("Allow-Forms"));
    }, "Make sure that sandbox based feature detection is working");
</script>