mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 346485 - "Implement output element -- Test" [r=smaug]
This commit is contained in:
parent
9961147316
commit
8b86c5b307
@ -378,6 +378,7 @@ _TEST_FILES = test_bug5141.html \
|
|||||||
file_csp_redirects_page.sjs \
|
file_csp_redirects_page.sjs \
|
||||||
file_csp_redirects_main.html \
|
file_csp_redirects_main.html \
|
||||||
file_csp_redirects_resource.sjs \
|
file_csp_redirects_resource.sjs \
|
||||||
|
test_bug346485.html \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
# This test fails on the Mac for some reason
|
# This test fails on the Mac for some reason
|
||||||
|
77
content/base/test/test_bug346485.html
Normal file
77
content/base/test/test_bug346485.html
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=346485
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 346485</title>
|
||||||
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=346485">Mozilla Bug 346485</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
<input id='a'>
|
||||||
|
<input id='b'>
|
||||||
|
<output id='o' for='a b'></output>
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
/** Test for Bug 346485 **/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test is testing DOMSettableTokenList used by the output element.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var o = document.getElementById('o');
|
||||||
|
|
||||||
|
is(o.htmlFor, 'a b',
|
||||||
|
"htmlFor IDL attribute should reflect for content attribute");
|
||||||
|
|
||||||
|
is(o.htmlFor.value, 'a b',
|
||||||
|
"value should return the underlying string");
|
||||||
|
|
||||||
|
is(o.htmlFor.length, 2, "Size should be '2'");
|
||||||
|
|
||||||
|
ok(o.htmlFor.contains('a'), "It should contain 'a' token'");
|
||||||
|
ok(!o.htmlFor.contains('c'), "It should not contain 'c' token");
|
||||||
|
|
||||||
|
is(o.htmlFor.item(0), 'a', "First item is 'a' token'");
|
||||||
|
is(o.htmlFor.item(42), null, "Out-of-range should return null");
|
||||||
|
|
||||||
|
o.htmlFor.add('c');
|
||||||
|
is(o.htmlFor, 'a b c', "'c' token should have been added");
|
||||||
|
is(o.htmlFor.length, 3, "Size should be '3'");
|
||||||
|
|
||||||
|
o.htmlFor.add('a');
|
||||||
|
is(o.htmlFor, 'a b c', "Nothing should have changed");
|
||||||
|
is(o.htmlFor.length, 3, "Size should be '3'");
|
||||||
|
|
||||||
|
o.htmlFor.remove('a');
|
||||||
|
is(o.htmlFor, 'b c', "'a' token should have been removed");
|
||||||
|
is(o.htmlFor.length, 2, "Size should be '2'");
|
||||||
|
|
||||||
|
o.htmlFor.remove('d');
|
||||||
|
is(o.htmlFor, 'b c', "Nothing should have been removed");
|
||||||
|
is(o.htmlFor.length, 2, "Size should be '2'");
|
||||||
|
|
||||||
|
o.htmlFor.toggle('a');
|
||||||
|
is(o.htmlFor, 'b c a', "'a' token should have been added");
|
||||||
|
is(o.htmlFor.length, 3, "Size should be '3'");
|
||||||
|
|
||||||
|
o.htmlFor.toggle('b');
|
||||||
|
is(o.htmlFor, 'c a', "Nothing should have changed");
|
||||||
|
is(o.htmlFor.length, 2, "Size should be '2'");
|
||||||
|
|
||||||
|
o.htmlFor.value = "foo bar";
|
||||||
|
is(o.htmlFor, 'foo bar', "The underlying string should have changed");
|
||||||
|
is(o.htmlFor.length, 2, "Size should be '2'");
|
||||||
|
ok(o.htmlFor.contains('foo'), "It should contain 'foo'");
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -160,6 +160,7 @@ _TEST_FILES = test_bug589.html \
|
|||||||
test_bug458037.xhtml \
|
test_bug458037.xhtml \
|
||||||
test_bug559284.html \
|
test_bug559284.html \
|
||||||
test_bug551670.html \
|
test_bug551670.html \
|
||||||
|
test_bug346485.html \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libs:: $(_TEST_FILES)
|
libs:: $(_TEST_FILES)
|
||||||
|
179
content/html/content/test/test_bug346485.html
Normal file
179
content/html/content/test/test_bug346485.html
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=346485
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 346485</title>
|
||||||
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=346485">Mozilla Bug 346485</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<iframe name="submit_frame" onload="checkFormSubmission();" style="visibility: hidden;"></iframe>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
<form id='f' method='get' target='submit_frame' action='foo'>
|
||||||
|
<input name='a' id='a'>
|
||||||
|
<input name='b' id='b'>
|
||||||
|
<output id='o' for='a b' name='output-name'>tulip</output>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
/** Test for Bug 346485 **/
|
||||||
|
|
||||||
|
function checkNameAttribute(element)
|
||||||
|
{
|
||||||
|
function nameAttributeEquals(element, expectedValue)
|
||||||
|
{
|
||||||
|
is(element.name, expectedValue, "Output name IDL attribute is not correct");
|
||||||
|
is(element.getAttribute('name'), expectedValue,
|
||||||
|
"Output name content attribute is not correct");
|
||||||
|
}
|
||||||
|
|
||||||
|
nameAttributeEquals(element, "output-name");
|
||||||
|
|
||||||
|
element.name = "new-name";
|
||||||
|
nameAttributeEquals(element, "new-name");
|
||||||
|
|
||||||
|
element.setAttribute('name', 'new-name-2');
|
||||||
|
nameAttributeEquals(element, "new-name-2");
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkValueAndDefaultValueIDLAttribute(element)
|
||||||
|
{
|
||||||
|
is(element.value, element.textContent,
|
||||||
|
"The value IDL attribute should act like the textContent IDL attribute");
|
||||||
|
|
||||||
|
element.value = "foo";
|
||||||
|
is(element.value, "foo", "Value should be 'foo'");
|
||||||
|
|
||||||
|
is(element.defaultValue, "", "Default defaultValue is ''");
|
||||||
|
|
||||||
|
element.defaultValue = "bar";
|
||||||
|
is(element.defaultValue, "bar", "defaultValue should be 'bar'");
|
||||||
|
|
||||||
|
// More complex situation.
|
||||||
|
element.textContent = 'foo';
|
||||||
|
var b = document.createElement('b');
|
||||||
|
b.textContent = 'bar'
|
||||||
|
element.appendChild(b);
|
||||||
|
is(element.value, element.textContent,
|
||||||
|
"The value IDL attribute should act like the textContent IDL attribute");
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkValueModeFlag(element)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The value mode flag is the flag used to know if value should represent the
|
||||||
|
* textContent or the default value.
|
||||||
|
*/
|
||||||
|
// value mode flag should be 'value'
|
||||||
|
isnot(element.defaultValue, element.value,
|
||||||
|
"When value is set, defaultValue keeps its value");
|
||||||
|
|
||||||
|
var f = document.getElementById('f');
|
||||||
|
f.reset();
|
||||||
|
// value mode flag should be 'default'
|
||||||
|
is(element.defaultValue, element.value, "When reset, defaultValue=value");
|
||||||
|
is(element.textContent, element.defaultValue,
|
||||||
|
"textContent should contain the defaultValue");
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkDescendantChanged(element)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Whenever a descendant is changed if the value mode flag is value,
|
||||||
|
* the default value should be the textContent value.
|
||||||
|
*/
|
||||||
|
element.defaultValue = 'tulip';
|
||||||
|
element.value = 'foo';
|
||||||
|
|
||||||
|
// set value mode flag to 'default'
|
||||||
|
var f = document.getElementById('f');
|
||||||
|
f.reset();
|
||||||
|
|
||||||
|
is(element.textContent, element.defaultValue,
|
||||||
|
"textContent should contain the defaultValue");
|
||||||
|
element.textContent = "bar";
|
||||||
|
is(element.textContent, element.defaultValue,
|
||||||
|
"textContent should contain the defaultValue");
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkFormIDLAttribute(element)
|
||||||
|
{
|
||||||
|
is(element.form, document.getElementById('f'),
|
||||||
|
"form IDL attribute is invalid");
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkHtmlForIDLAttribute(element)
|
||||||
|
{
|
||||||
|
is(element.htmlFor, 'a b',
|
||||||
|
"htmlFor IDL attribute should reflect the for content attribute");
|
||||||
|
|
||||||
|
// DOMSettableTokenList is tested in another bug so we just test assignation
|
||||||
|
element.htmlFor.value = 'a b c';
|
||||||
|
is(element.htmlFor, 'a b c', "htmlFor shoud have changed");
|
||||||
|
}
|
||||||
|
|
||||||
|
function submitForm()
|
||||||
|
{
|
||||||
|
// Setting the values for the submit.
|
||||||
|
document.getElementById('o').value = 'foo';
|
||||||
|
document.getElementById('a').value = 'afield';
|
||||||
|
document.getElementById('b').value = 'bfield';
|
||||||
|
|
||||||
|
// This will call checkFormSubmission() which is going to call ST.finish().
|
||||||
|
document.getElementById('f').submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkFormSubmission()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* All elements values have been set just before the submission.
|
||||||
|
* The input elements values should be in the submit url but the ouput
|
||||||
|
* element value should not appear.
|
||||||
|
*/
|
||||||
|
|
||||||
|
is(frames['submit_frame'].location.href,
|
||||||
|
'http://mochi.test:8888/tests/content/html/content/test/foo?a=afield&b=bfield',
|
||||||
|
"The output element value should not be submitted");
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
var o = document.getElementsByTagName('output');
|
||||||
|
is(o.length, 1, "There should be one output element");
|
||||||
|
|
||||||
|
o = o[0];
|
||||||
|
ok(o instanceof HTMLOutputElement,
|
||||||
|
"The output should be instance of HTMLOutputElement");
|
||||||
|
|
||||||
|
o = document.getElementById('o');
|
||||||
|
ok(o instanceof HTMLOutputElement,
|
||||||
|
"The output should be instance of HTMLOutputElement");
|
||||||
|
|
||||||
|
is(o.type, "output", "Output type IDL attribute should be 'output'");
|
||||||
|
|
||||||
|
checkNameAttribute(o);
|
||||||
|
|
||||||
|
checkValueAndDefaultValueIDLAttribute(o);
|
||||||
|
|
||||||
|
checkValueModeFlag(o);
|
||||||
|
|
||||||
|
checkDescendantChanged(o);
|
||||||
|
|
||||||
|
checkFormIDLAttribute(o);
|
||||||
|
|
||||||
|
checkHtmlForIDLAttribute(o);
|
||||||
|
|
||||||
|
submitForm();
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
7
layout/reftests/forms/output/output-1.html
Normal file
7
layout/reftests/forms/output/output-1.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<!-- Test: the output shouldn't show anything when there is no content -->
|
||||||
|
<body>
|
||||||
|
<output></output>
|
||||||
|
</body>
|
||||||
|
</html>
|
7
layout/reftests/forms/output/output-2.html
Normal file
7
layout/reftests/forms/output/output-2.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<!-- Test: the output should show the textContent -->
|
||||||
|
<body>
|
||||||
|
<output>foo</output>
|
||||||
|
</body>
|
||||||
|
</html>
|
7
layout/reftests/forms/output/output-3.html
Normal file
7
layout/reftests/forms/output/output-3.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<!-- Test: the output should show its content -->
|
||||||
|
<body>
|
||||||
|
<output>foo<b>bar</b></output>
|
||||||
|
</body>
|
||||||
|
</html>
|
7
layout/reftests/forms/output/output-4.html
Normal file
7
layout/reftests/forms/output/output-4.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<!-- Test: the output should show its content -->
|
||||||
|
<body>
|
||||||
|
<output>foo<input></output>
|
||||||
|
</body>
|
||||||
|
</html>
|
18
layout/reftests/forms/output/output-5.html
Normal file
18
layout/reftests/forms/output/output-5.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="reftest-wait">
|
||||||
|
<!-- Test: the output element should show its default value -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
function setDefaultValue()
|
||||||
|
{
|
||||||
|
document.getElementById('o').defaultValue = "foo";
|
||||||
|
}
|
||||||
|
function disableReftestWait()
|
||||||
|
{
|
||||||
|
document.documentElement.className = '';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<body onload="setDefaultValue(); disableReftestWait();">
|
||||||
|
<output id="o"></output>
|
||||||
|
</body>
|
||||||
|
</html>
|
18
layout/reftests/forms/output/output-6.html
Normal file
18
layout/reftests/forms/output/output-6.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="reftest-wait">
|
||||||
|
<!-- Test: the output element should show its value -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
function setValue()
|
||||||
|
{
|
||||||
|
document.getElementById('o').value = "foo";
|
||||||
|
}
|
||||||
|
function disableReftestWait()
|
||||||
|
{
|
||||||
|
document.documentElement.className = '';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<body onload="setValue(); disableReftestWait();">
|
||||||
|
<output id="o"></output>
|
||||||
|
</body>
|
||||||
|
</html>
|
22
layout/reftests/forms/output/output-7.html
Normal file
22
layout/reftests/forms/output/output-7.html
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="reftest-wait">
|
||||||
|
<!-- Test: the output element should show its value -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
function setDefaultValue()
|
||||||
|
{
|
||||||
|
document.getElementById('o').value = "bar";
|
||||||
|
}
|
||||||
|
function setValue()
|
||||||
|
{
|
||||||
|
document.getElementById('o').value = "foo";
|
||||||
|
}
|
||||||
|
function disableReftestWait()
|
||||||
|
{
|
||||||
|
document.documentElement.className = '';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<body onload="setDefaultValue(); setValue(); disableReftestWait();">
|
||||||
|
<output id="o"></output>
|
||||||
|
</body>
|
||||||
|
</html>
|
6
layout/reftests/forms/output/output-ref-2.html
Normal file
6
layout/reftests/forms/output/output-ref-2.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
foo<b>bar</b>
|
||||||
|
</body>
|
||||||
|
</html>
|
6
layout/reftests/forms/output/output-ref-3.html
Normal file
6
layout/reftests/forms/output/output-ref-3.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
foo<input>
|
||||||
|
</body>
|
||||||
|
</html>
|
6
layout/reftests/forms/output/output-ref.html
Normal file
6
layout/reftests/forms/output/output-ref.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
foo
|
||||||
|
</body>
|
||||||
|
</html>
|
7
layout/reftests/forms/output/reftest.list
Normal file
7
layout/reftests/forms/output/reftest.list
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
== output-1.html about:blank
|
||||||
|
== output-2.html output-ref.html
|
||||||
|
== output-3.html output-ref-2.html
|
||||||
|
== output-4.html output-ref-3.html
|
||||||
|
== output-5.html output-ref.html
|
||||||
|
== output-6.html output-ref.html
|
||||||
|
== output-7.html output-ref.html
|
@ -43,3 +43,6 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") != textarea-rtl.html textarea-no-resize.ht
|
|||||||
|
|
||||||
# placeholder
|
# placeholder
|
||||||
include placeholder/reftest.list
|
include placeholder/reftest.list
|
||||||
|
|
||||||
|
# output element
|
||||||
|
include output/reftest.list
|
||||||
|
Loading…
Reference in New Issue
Block a user