tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

stylehash-allowed.sub.html (5287B)


      1 <!DOCTYPE html>
      2 <html>
      3 
      4 <head>
      5    <!-- Programmatically converted from a WebKit Reftest, please forgive resulting idiosyncracies.-->
      6    <meta http-equiv="Content-Security-Policy" content="style-src 'self' 'sha256-pAKi9r4/WB7fHydbE3F3t8i8602ij2JN8zHJpL2T5BM=' 'sha256-hndjYvzUzy2Ykuad81Cwsl1FOXX/qYs/aDVyUyNZwBw=' 'sha384-bSVm1i3sjPBRM4TwZtYTDjk9JxZMExYHWbFmP1SxDhJH4ue0Wu9OPOkY5hcqRcSt' 'sha512-440MmBLtj9Kp5Bqloogn9BqGDylY8vFsv5/zXL1zH2fJVssCoskRig4gyM+9KqwvCSapSz5CVoUGHQcxv43UQg=='; script-src 'self' 'unsafe-inline'; connect-src 'self';">
      7    <title>stylehash-allowed</title>
      8    <script src="/resources/testharness.js"></script>
      9    <script src="/resources/testharnessreport.js"></script>
     10    <script src="../support/logTest.sub.js?logs=[]"></script>
     11    <script>
     12        window.addEventListener('securitypolicyviolation', function(e) {
     13            alert_assert("Fail");
     14        });
     15 
     16        var t_alert = async_test('Expecting alerts: ["PASS (1/4): The \'#p1\' element\'s text is green, which means the style was correctly applied.","PASS (2/4): The \'#p2\' element\'s text is green, which means the style was correctly applied.","PASS (3/4): The \'#p3\' element\'s text is green, which means the style was correctly applied.","PASS (4/4): The \'#p4\' element\'s text is green, which means the style was correctly applied."]');
     17        var expected_alerts = ["PASS (1/4): The '#p1' element's text is green, which means the style was correctly applied.", "PASS (2/4): The '#p2' element's text is green, which means the style was correctly applied.", "PASS (3/4): The '#p3' element's text is green, which means the style was correctly applied.", "PASS (4/4): The '#p4' element's text is green, which means the style was correctly applied."];
     18 
     19        function alert_assert(msg) {
     20            t_alert.step(function() {
     21                if (msg.match(/^FAIL/i)) {
     22                    assert_unreached(msg);
     23                    t_alert.done();
     24                }
     25                for (var i = 0; i < expected_alerts.length; i++) {
     26                    if (expected_alerts[i] == msg) {
     27                        assert_equals(expected_alerts[i], msg);
     28                        expected_alerts.splice(i, 1);
     29                        if (expected_alerts.length == 0) {
     30                            t_alert.done();
     31                        }
     32                        return;
     33                    }
     34                }
     35                assert_unreached('unexpected alert: ' + msg);
     36                t_log.done();
     37            });
     38        }
     39 
     40    </script>
     41    <!-- enforcing policy:
     42 style-src 'sha256-pAKi9r4/WB7fHydbE3F3t8i8602ij2JN8zHJpL2T5BM=' 'sha256-hndjYvzUzy2Ykuad81Cwsl1FOXX/qYs/aDVyUyNZwBw=' 'sha384-bSVm1i3sjPBRM4TwZtYTDjk9JxZMExYHWbFmP1SxDhJH4ue0Wu9OPOkY5hcqRcSt' 'sha512-440MmBLtj9Kp5Bqloogn9BqGDylY8vFsv5/zXL1zH2fJVssCoskRig4gyM+9KqwvCSapSz5CVoUGHQcxv43UQg=='; script-src 'self' 'unsafe-inline'; connect-src 'self';
     43 -->
     44 </head>
     45 
     46 <body>
     47    <p id="p1">This tests the result of a valid style hash. It passes if this text is green, and a &quot;PASS&quot; alert for p1 is fired.</p>
     48    <p id="p2">This tests the result of a valid style hash. It passes if this text is green, and a &quot;PASS&quot; alert for p2 is fired.</p>
     49    <p id="p3">This tests the result of a valid style hash. It passes if this text is green, and a &quot;PASS&quot; alert for p3 is fired.</p>
     50    <p id="p4">This tests the result of a valid style hash. It passes if this text is green, and a &quot;PASS&quot; alert for p4 is fired.</p>
     51    <style>p#p1 { color: green; }</style>
     52    <style>p#p2 { color: green; }</style>
     53    <style>p#p3 { color: green; }</style>
     54    <style>p#p4 { color: green; }</style>
     55    <script>
     56        var color = window.getComputedStyle(document.querySelector('#p1')).color;
     57        if (color === "rgb(0, 128, 0)")
     58            alert_assert("PASS (1/4): The '#p1' element's text is green, which means the style was correctly applied.");
     59        else
     60            alert_assert("FAIL (1/4): The '#p1' element's text is " + color + ", which means the style was incorrectly applied.");
     61        var color = window.getComputedStyle(document.querySelector('#p2')).color;
     62        if (color === "rgb(0, 128, 0)")
     63            alert_assert("PASS (2/4): The '#p2' element's text is green, which means the style was correctly applied.");
     64        else
     65            alert_assert("FAIL (2/4): The '#p2' element's text is " + color + ", which means the style was incorrectly applied.");
     66        var color = window.getComputedStyle(document.querySelector('#p3')).color;
     67        if (color === "rgb(0, 128, 0)")
     68            alert_assert("PASS (3/4): The '#p3' element's text is green, which means the style was correctly applied.");
     69        else
     70            alert_assert("FAIL (3/4): The '#p3' element's text is " + color + ", which means the style was incorrectly applied.");
     71        var color = window.getComputedStyle(document.querySelector('#p4')).color;
     72        if (color === "rgb(0, 128, 0)")
     73            alert_assert("PASS (4/4): The '#p4' element's text is green, which means the style was correctly applied.");
     74        else
     75            alert_assert("FAIL (4/4): The '#p4' element's text is " + color + ", which means the style was incorrectly applied.");
     76 
     77    </script>
     78    <div id="log"></div>
     79 </body>
     80 
     81 </html>