1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug346485.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=346485 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 346485</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=346485">Mozilla Bug 346485</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + <input id='a'> 1.19 + <input id='b'> 1.20 + <output id='o' for='a b'></output> 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script type="application/javascript"> 1.24 + 1.25 +/** Test for Bug 346485 **/ 1.26 + 1.27 +/** 1.28 + * This test is testing DOMSettableTokenList used by the output element. 1.29 + */ 1.30 + 1.31 +var o = document.getElementById('o'); 1.32 + 1.33 +is(o.htmlFor, 'a b', 1.34 + "htmlFor IDL attribute should reflect for content attribute"); 1.35 + 1.36 +is(o.htmlFor.value, 'a b', 1.37 + "value should return the underlying string"); 1.38 + 1.39 +is(o.htmlFor.length, 2, "Size should be '2'"); 1.40 + 1.41 +ok(o.htmlFor.contains('a'), "It should contain 'a' token'"); 1.42 +ok(!o.htmlFor.contains('c'), "It should not contain 'c' token"); 1.43 + 1.44 +is(o.htmlFor.item(0), 'a', "First item is 'a' token'"); 1.45 +is(o.htmlFor.item(42), null, "Out-of-range should return null"); 1.46 + 1.47 +o.htmlFor.add('c'); 1.48 +is(o.htmlFor, 'a b c', "'c' token should have been added"); 1.49 +is(o.htmlFor.length, 3, "Size should be '3'"); 1.50 + 1.51 +o.htmlFor.add('a'); 1.52 +is(o.htmlFor, 'a b c', "Nothing should have changed"); 1.53 +is(o.htmlFor.length, 3, "Size should be '3'"); 1.54 + 1.55 +o.htmlFor.remove('a'); 1.56 +is(o.htmlFor, 'b c', "'a' token should have been removed"); 1.57 +is(o.htmlFor.length, 2, "Size should be '2'"); 1.58 + 1.59 +o.htmlFor.remove('d'); 1.60 +is(o.htmlFor, 'b c', "Nothing should have been removed"); 1.61 +is(o.htmlFor.length, 2, "Size should be '2'"); 1.62 + 1.63 +o.htmlFor.toggle('a'); 1.64 +is(o.htmlFor, 'b c a', "'a' token should have been added"); 1.65 +is(o.htmlFor.length, 3, "Size should be '3'"); 1.66 + 1.67 +o.htmlFor.toggle('b'); 1.68 +is(o.htmlFor, 'c a', "Nothing should have changed"); 1.69 +is(o.htmlFor.length, 2, "Size should be '2'"); 1.70 + 1.71 +o.htmlFor.value = "foo bar"; 1.72 +is(o.htmlFor, 'foo bar', "The underlying string should have changed"); 1.73 +is(o.htmlFor.length, 2, "Size should be '2'"); 1.74 +ok(o.htmlFor.contains('foo'), "It should contain 'foo'"); 1.75 + 1.76 +</script> 1.77 +</pre> 1.78 +</body> 1.79 +</html>