OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>MediaImage interface</title> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script> |
| 6 console.warn("dummy log entry to avoid an empty -expected.txt in virtual/"); |
| 7 |
| 8 test(function() { |
| 9 var image = new MediaImage({}); |
| 10 assert_true(image != null); |
| 11 |
| 12 var exception = false; |
| 13 try { |
| 14 image = new MediaImage("foobar"); |
| 15 } catch (e) { |
| 16 exception = true; |
| 17 } |
| 18 assert_true(exception); |
| 19 |
| 20 exception = false; |
| 21 try { |
| 22 image = new MediaImage(42); |
| 23 } catch (e) { |
| 24 exception = true; |
| 25 } |
| 26 assert_true(exception); |
| 27 }, 'Test that MediaImage is constructed using a dictionary'); |
| 28 |
| 29 test (function() { |
| 30 var image = new MediaImage({ |
| 31 src: 'foo', sizes: 'bar', type: 'plop'}); |
| 32 assert_greater_than(image.src.indexOf('foo'), -1); |
| 33 assert_equals(image.sizes, 'bar'); |
| 34 assert_equals(image.type, 'plop'); |
| 35 }, 'Test the different values allowed in MediaImage init dictionary'); |
| 36 |
| 37 test (function() { |
| 38 var image = new MediaImage({}); |
| 39 assert_equals(image.src, document.URL); |
| 40 assert_equals(image.sizes, ''); |
| 41 assert_equals(image.type, ''); |
| 42 }, 'Test the default values for MediaImage'); |
| 43 |
| 44 test (function() { |
| 45 var image = new MediaMetadata({ randomValueThatWillNotBeAdded: '... hopefull
y ;)' }); |
| 46 assert_equals(image.randomValueThatWillNotBeAdded, undefined); |
| 47 }, 'Test that passing unknown values to the dictionary is a no-op'); |
| 48 </script> |
OLD | NEW |