tor-browser

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

elementFromPoint-parameters.html (1948B)


      1 <!DOCTYPE html>
      2 <title>Tests that the parameters to document.elementFromPoint() and
      3 document.elementsFromPoint() are mandatory and of type double.</title>
      4 <link rel="help" href="https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script>
      8 function validate_function_parameter_count(testFunc, funcName) {
      9    test(function() {
     10        assert_throws_js(TypeError, function() {
     11            testFunc();
     12        }, "Called with no parameter");
     13        assert_throws_js(TypeError, function() {
     14            testFunc(0);
     15        }, "Called with 1 parameter");
     16    }, funcName + ": Parameters are mandatory.");
     17 }
     18 
     19 function validate_function_parameter_type(testFunc, funcName) {
     20    test(function() {
     21        assert_throws_js(TypeError, function() {
     22            testFunc(0, Infinity);
     23        }, "Passing Infinity as second parameter throws");
     24        assert_throws_js(TypeError, function() {
     25            testFunc(Infinity, 0);
     26        }, "Passing Infinity as first parameter throws");
     27        assert_throws_js(TypeError, function() {
     28            testFunc(0, NaN);
     29        }, "Passing NaN as second parameter throws");
     30        assert_throws_js(TypeError, function() {
     31            testFunc(NaN, 0);
     32        }, "Passing NaN as first parameter throws");
     33    }, funcName + ": Parameters should be finite floating point values.");
     34 }
     35 
     36 validate_function_parameter_count(function(x, y) {
     37    document.elementFromPoint(x, y);
     38 }, "document.elementFromPoint");
     39 
     40 validate_function_parameter_type(function(x, y) {
     41    document.elementFromPoint(x, y);
     42 }, "document.elementFromPoint");
     43 
     44 validate_function_parameter_count(function(x, y) {
     45    document.elementsFromPoint(x, y);
     46 }, "document.elementsFromPoint");
     47 
     48 validate_function_parameter_type(function(x, y) {
     49    document.elementsFromPoint(x, y);
     50 }, "document.elementsFromPoint");
     51 </script>