tor-browser

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

draggable_attribute.html (5275B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <meta charset='utf-8'>
      5    <title>HTML Test: draggable_attribute</title>
      6    <link rel='author' title='Intel' href='http://www.intel.com'>
      7    <link rel='help' href='https://html.spec.whatwg.org/multipage/#the-draggable-attribute'>
      8    <script src='/resources/testharness.js'></script>
      9    <script src='/resources/testharnessreport.js'></script>
     10    <script src='/html/semantics/interfaces.js'></script>
     11  </head>
     12 
     13  <body>
     14    <div id='log'> </div>
     15 
     16    <script>
     17      elements.forEach(function(a) {
     18        test(function() {
     19          var eElement = document.createElement(a[0]);
     20          assert_inherits(eElement, 'draggable', 'Element ' + a[0] +' should have draggable property');
     21        }, 'Element ' + a[0] +' should have draggable property');
     22      });
     23 
     24      function run_test(element, element_name, exp) {
     25        if (exp) {
     26          assert_true(element.draggable, 'Element ' + element_name +' should be draggable');
     27        } else {
     28          assert_false(element.draggable, 'Element ' + element_name +' should not be draggable');
     29        }
     30      }
     31 
     32      function run_idl_test(element, element_name, exp) {
     33        if (exp) {
     34          assert_equals(element.getAttribute('draggable'), 'true', 'Element ' + element_name +' should be draggable');
     35        } else {
     36          assert_equals(element.getAttribute('draggable'), 'false', 'Element ' + element_name +' should not be draggable');
     37        }
     38      }
     39 
     40      elements.forEach(function(a) {
     41 
     42        test(function() {
     43          //Default values for elements
     44          //If the element is an img element, or, if the element is an a element with an href content attribute,
     45          //the draggable IDL attribute must return true.
     46          var eElement = document.createElement(a[0]);
     47          switch (a[0]) {
     48            case 'a':
     49              eElement.setAttribute('href', 'http://w3.org');
     50              run_test(eElement, 'a', true);
     51              break;
     52            case 'img':
     53              run_test(eElement, 'img', true);
     54              break;
     55            default:
     56              run_test(eElement, a[0], false);
     57          }
     58 
     59          //If an element's draggable content attribute has the state true,
     60          //the draggable IDL attribute must return true.
     61          eElement.setAttribute('draggable', 'true');
     62          run_test(eElement, a[0] + ' draggable=\'true\'', true);
     63 
     64          //If an element's draggable content attribute has the state false,
     65          //the draggable IDL attribute must return false.
     66          eElement.setAttribute('draggable', 'false');
     67          run_test(eElement, a[0] + ' draggable=\'false\'', false);
     68 
     69          //auto values for elements
     70          //The element's draggable content attribute has the state auto.
     71          //If the element is an img element, or, if the element is an a element with an href content attribute,
     72          //the draggable IDL attribute must return true.
     73          switch (a[0]) {
     74            case 'a':
     75              eElement.setAttribute('href', 'http://w3.org');
     76              eElement.setAttribute('draggable', 'auto');
     77              run_test(eElement, 'Element ' + 'a' + ' draggable=\'auto\'', true);
     78              break;
     79            case 'img':
     80              eElement.setAttribute('draggable', 'auto');
     81              run_test(eElement, 'Element ' + 'img' + ' draggable=\'auto\'', true);
     82              break;
     83            default:
     84              run_test(eElement, 'Element ' + a[0] + ' draggable=\'auto\'', false);
     85          }
     86 
     87          //Foo values for elements
     88          //The element's draggable content attribute value is not enumerated (true, false, auto) but unexpected.
     89          //Fallback to defaults
     90          switch (a[0]) {
     91            case 'a':
     92              eElement.setAttribute('href', 'http://w3.org');
     93              eElement.setAttribute('draggable', 'foo');
     94              run_test(eElement, 'Element ' + 'a' + ' draggable=\'foo\'', true);
     95              break;
     96            case 'img':
     97              eElement.setAttribute('draggable', 'foo');
     98              run_test(eElement, 'Element ' + 'img' + ' draggable=\'foo\'', true);
     99              break;
    100            default:
    101              run_test(eElement, 'Element ' + a[0] + ' draggable=\'foo\'', false);
    102          }
    103 
    104          //An element with a draggable attribute should also have a title attribute
    105          //that names the element for the purpose of non-visual interactions.
    106          eElement.setAttribute('title', 'foo as title value');
    107          assert_equals(typeof eElement.title, 'string', '<' + a[0] + '> draggable block has title attribute');
    108 
    109          //If the draggable IDL attribute is set to the value false,
    110          //the draggable content attribute must be set to the literal value false.
    111          eElement.draggable = false;
    112          run_idl_test(eElement, a[0] + '.getAttribute(\'draggable\') is \'false\'', false);
    113 
    114          //If the draggable IDL attribute is set to the value true,
    115          //the draggable content attribute must be set to the literal value true.
    116          eElement.draggable = true;
    117          run_idl_test(eElement, a[0] + '.getAttribute(\'draggable\') is \'true\'', true);
    118          }, 'Element ' + a[0] +' draggable attribute test');
    119 
    120        });
    121    </script>
    122  </body>
    123 </html>