tor-browser

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

HTMLInputElement.html (3666B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Custom Elements: CEReactions on HTMLInputElement interface</title>
      4 <link rel="author" title="Intel" href="http://www.intel.com">
      5 <link rel="author" title="Wanming Lin" href="mailto:wanming.lin@intel.com">
      6 <meta name="assert" content="capture of HTMLInputElement interface must have CEReactions">
      7 <meta name="help" content="https://www.w3.org/TR/html-media-capture/#the-capture-attribute">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="../../resources/custom-elements-helpers.js"></script>
     11 <script src="../resources/reactions.js"></script>
     12 <body>
     13 <script>
     14 if ('capture' in HTMLInputElement.prototype) {
     15    test(() => {
     16        const element = define_build_in_custom_element(['capture'], HTMLInputElement, 'input');
     17        const instance = document.createElement('input', { is: element.name });
     18 
     19        assert_array_equals(element.takeLog().types(), ['constructed']);
     20        instance['capture'] = 'user';
     21        const logEntries = element.takeLog();
     22        assert_array_equals(logEntries.types(), ['attributeChanged']);
     23        assert_attribute_log_entry(logEntries.last(), {name: 'capture', oldValue: null, newValue: 'user', namespace: null});
     24    }, 'capture on HTMLInputElement must enqueue an attributeChanged reaction when adding new attribute');
     25 
     26    test(() => {
     27        const element = define_build_in_custom_element(['capture'], HTMLInputElement, 'input');
     28        const instance = document.createElement('input', { is: element.name });
     29 
     30        instance['capture'] = 'user';
     31        assert_array_equals(element.takeLog().types(), ['constructed', 'attributeChanged']);
     32        instance['capture'] = 'environment';
     33        const logEntries = element.takeLog();
     34        assert_array_equals(logEntries.types(), ['attributeChanged']);
     35        assert_attribute_log_entry(logEntries.last(), {name: 'capture', oldValue: 'user', newValue: 'environment', namespace: null});
     36    }, 'capture on HTMLInputElement must enqueue an attributeChanged reaction when replacing an existing attribute');
     37 
     38    test(() => {
     39        const element = define_build_in_custom_element(['capture'], HTMLInputElement, 'input');
     40        const instance = document.createElement('input', { is: element.name });
     41 
     42        assert_array_equals(element.takeLog().types(), ['constructed']);
     43        instance['capture'] = 'asdf';
     44        const logEntries = element.takeLog();
     45        assert_array_equals(logEntries.types(), ['attributeChanged']);
     46        assert_attribute_log_entry(logEntries.last(), {name: 'capture', oldValue: null, newValue: 'asdf', namespace: null});
     47    }, 'capture on HTMLInputElement must enqueue an attributeChanged reaction when adding invalid value default');
     48 
     49    test(() => {
     50        const element = define_build_in_custom_element(['capture'], HTMLInputElement, 'input');
     51        const instance = document.createElement('input', { is: element.name });
     52 
     53        instance['capture'] = 'user';
     54        assert_array_equals(element.takeLog().types(), ['constructed', 'attributeChanged']);
     55        instance['capture'] = '';
     56        const logEntries = element.takeLog();
     57        assert_array_equals(logEntries.types(), ['attributeChanged']);
     58        assert_attribute_log_entry(logEntries.last(), {name: 'capture', oldValue: 'user', newValue: '', namespace: null});
     59    }, 'capture on HTMLInputElement must enqueue an attributeChanged reaction when removing the attribute');
     60 } else {
     61    // testharness.js doesn't allow a test file with no tests.
     62    test(() => {
     63    }, 'No tests if HTMLInputEement has no "capture" IDL attribute');
     64 }
     65 </script>
     66 </body>