209 lines
9.0 KiB
HTML
209 lines
9.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
|
<html>
|
|
<head>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
</head>
|
|
<body>
|
|
<p id="description"></p>
|
|
<div id="console"></div>
|
|
<script>
|
|
description('Tests the behavior of .formaction, .formenctype, .formmethod and .formtarget of HTMLInputElement and HTMLButtonElement.');
|
|
|
|
var input = document.createElement('input');
|
|
|
|
debug('Ordinary values for input:');
|
|
input.type = "submit";
|
|
shouldBe('input.formAction', 'location.href');
|
|
shouldBeEqualToString('input.formEnctype', '');
|
|
shouldBeEqualToString('input.formMethod', '');
|
|
shouldBeEqualToString('input.formTarget', '');
|
|
|
|
input.setAttribute('formAction', 'http://localhost');
|
|
shouldBeEqualToString('input.formAction', 'http://localhost/');
|
|
input.setAttribute('formAction', 'http://localhost/');
|
|
shouldBeEqualToString('input.formAction', 'http://localhost/');
|
|
input.setAttribute('formEnctype', 'text/plain');
|
|
shouldBeEqualToString('input.formEnctype', 'text/plain');
|
|
input.setAttribute('formEnctype', 'na');
|
|
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
|
|
input.setAttribute('formMethod', 'GET');
|
|
shouldBeEqualToString('input.formMethod', 'get');
|
|
input.setAttribute('formMethod', 'ni');
|
|
shouldBeEqualToString('input.formMethod', 'get');
|
|
input.setAttribute('formTarget', '_blank');
|
|
shouldBeEqualToString('input.formTarget', '_blank');
|
|
input.setAttribute('formTarget', 'nu');
|
|
shouldBeEqualToString('input.formTarget', 'nu');
|
|
|
|
input.formAction = 'http://example.com';
|
|
shouldBeEqualToString('input.formAction', 'http://example.com/');
|
|
input.formAction = 'http://example.com/';
|
|
shouldBeEqualToString('input.formAction', 'http://example.com/');
|
|
input.formEnctype = 'text/plain';
|
|
shouldBeEqualToString('input.formEnctype', 'text/plain');
|
|
input.formEnctype = 'nota';
|
|
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
|
|
input.formMethod = 'POST';
|
|
shouldBeEqualToString('input.formMethod', 'post');
|
|
input.formMethod = 'neta';
|
|
shouldBeEqualToString('input.formMethod', 'get');
|
|
input.formTarget = 'http://example.com';
|
|
shouldBeEqualToString('input.formTarget', 'http://example.com');
|
|
input.formTarget = 'nta';
|
|
shouldBeEqualToString('input.formTarget', 'nta');
|
|
|
|
debug('');
|
|
debug('Setting null for input:');
|
|
input.formEnctype = null;
|
|
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
|
|
shouldBeEqualToString('input.getAttribute("formEnctype")', 'null');
|
|
input.setAttribute('formEnctype', null);
|
|
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
|
|
input.formMethod = null;
|
|
shouldBeEqualToString('input.formMethod', 'get');
|
|
shouldBeEqualToString('input.getAttribute("formMethod")', 'null');
|
|
input.setAttribute('formMethod', null);
|
|
shouldBeEqualToString('input.formMethod', 'get');
|
|
input.formTarget = null;
|
|
shouldBeEqualToString('input.formTarget', 'null');
|
|
shouldBeEqualToString('input.getAttribute("formTarget")', 'null');
|
|
input.setAttribute('formTarget', null);
|
|
shouldBeEqualToString('input.formTarget', 'null');
|
|
|
|
debug('');
|
|
debug('Setting undefined for input:');
|
|
input.formEnctype = undefined;
|
|
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
|
|
shouldBeEqualToString('input.getAttribute("formEnctype")', 'undefined');
|
|
input.setAttribute('formEnctype', undefined);
|
|
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
|
|
input.formMethod = undefined;
|
|
shouldBeEqualToString('input.formMethod', 'get');
|
|
shouldBeEqualToString('input.getAttribute("formMethod")', 'undefined');
|
|
input.setAttribute('formMethod', undefined);
|
|
shouldBeEqualToString('input.formMethod', 'get');
|
|
input.formTarget = undefined;
|
|
shouldBeEqualToString('input.formTarget', 'undefined');
|
|
shouldBeEqualToString('input.getAttribute("formTarget")', 'undefined');
|
|
input.setAttribute('formTarget', undefined);
|
|
shouldBeEqualToString('input.formTarget', 'undefined');
|
|
|
|
debug('');
|
|
debug('Setting non-string for input:');
|
|
input.formEnctype = 256;
|
|
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
|
|
shouldBeEqualToString('input.getAttribute("formEnctype")', '256');
|
|
input.setAttribute('formEnctype', 256);
|
|
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
|
|
input.formMethod = 256;
|
|
shouldBeEqualToString('input.formMethod', 'get');
|
|
shouldBeEqualToString('input.getAttribute("formMethod")', '256');
|
|
input.setAttribute('formMethod', 256);
|
|
shouldBeEqualToString('input.formMethod', 'get');
|
|
input.formTarget = 256;
|
|
shouldBeEqualToString('input.formTarget', '256');
|
|
shouldBeEqualToString('input.getAttribute("formTarget")', '256');
|
|
input.setAttribute('formTarget', 256);
|
|
shouldBeEqualToString('input.formTarget', '256');
|
|
|
|
var button = document.createElement('button');
|
|
debug('');
|
|
debug('Ordinary values for button:');
|
|
button.type = "submit";
|
|
shouldBe('button.formAction', 'location.href');
|
|
shouldBeEqualToString('button.formEnctype', '');
|
|
shouldBeEqualToString('button.formMethod', '');
|
|
shouldBeEqualToString('button.formTarget', '');
|
|
|
|
button.setAttribute('formAction', 'http://localhost');
|
|
shouldBeEqualToString('button.formAction', 'http://localhost/');
|
|
button.setAttribute('formAction', 'http://localhost/');
|
|
shouldBeEqualToString('button.formAction', 'http://localhost/');
|
|
button.setAttribute('formEnctype', 'text/plain');
|
|
shouldBeEqualToString('button.formEnctype', 'text/plain');
|
|
button.setAttribute('formEnctype', 'na');
|
|
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
|
|
button.setAttribute('formMethod', 'GET');
|
|
shouldBeEqualToString('button.formMethod', 'get');
|
|
button.setAttribute('formMethod', 'na');
|
|
shouldBeEqualToString('button.formMethod', 'get');
|
|
button.setAttribute('formTarget', '_blank');
|
|
shouldBeEqualToString('button.formTarget', '_blank');
|
|
button.setAttribute('formTarget', 'na');
|
|
shouldBeEqualToString('button.formTarget', 'na');
|
|
|
|
button.formAction = 'http://example.com';
|
|
shouldBeEqualToString('button.formAction', 'http://example.com/');
|
|
button.formAction = 'http://example.com/';
|
|
shouldBeEqualToString('button.formAction', 'http://example.com/');
|
|
button.formEnctype = 'text/plain';
|
|
shouldBeEqualToString('button.formEnctype', 'text/plain');
|
|
button.formEnctype = 'nota';
|
|
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
|
|
button.formMethod = 'POST';
|
|
shouldBeEqualToString('button.formMethod', 'post');
|
|
button.formMethod = 'nota';
|
|
shouldBeEqualToString('button.formMethod', 'get');
|
|
button.formTarget = 'http://example.com';
|
|
shouldBeEqualToString('button.formTarget', 'http://example.com');
|
|
button.formTarget = 'nota';
|
|
shouldBeEqualToString('button.formTarget', 'nota');
|
|
|
|
debug('');
|
|
debug('Setting null for button:');
|
|
button.formEnctype = null;
|
|
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
|
|
shouldBeEqualToString('button.getAttribute("formEnctype")', 'null');
|
|
button.setAttribute('formEnctype', null);
|
|
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
|
|
button.formMethod = null;
|
|
shouldBeEqualToString('button.formMethod', 'get');
|
|
shouldBeEqualToString('button.getAttribute("formMethod")', 'null');
|
|
button.setAttribute('formMethod', null);
|
|
shouldBeEqualToString('button.formMethod', 'get');
|
|
button.formTarget = null;
|
|
shouldBeEqualToString('button.formTarget', 'null');
|
|
shouldBeEqualToString('button.getAttribute("formTarget")', 'null');
|
|
button.setAttribute('formTarget', null);
|
|
shouldBeEqualToString('button.formTarget', 'null');
|
|
|
|
debug('');
|
|
debug('Setting undefined for button:');
|
|
button.formEnctype = undefined;
|
|
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
|
|
shouldBeEqualToString('button.getAttribute("formEnctype")', 'undefined');
|
|
button.setAttribute('formEnctype', undefined);
|
|
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
|
|
button.formMethod = undefined;
|
|
shouldBeEqualToString('button.formMethod', 'get');
|
|
shouldBeEqualToString('button.getAttribute("formMethod")', 'undefined');
|
|
button.setAttribute('formMethod', undefined);
|
|
shouldBeEqualToString('button.formMethod', 'get');
|
|
button.formTarget = undefined;
|
|
shouldBeEqualToString('button.formTarget', 'undefined');
|
|
shouldBeEqualToString('button.getAttribute("formTarget")', 'undefined');
|
|
button.setAttribute('formTarget', undefined);
|
|
shouldBeEqualToString('button.formTarget', 'undefined');
|
|
|
|
debug('');
|
|
debug('Setting non-string for button:');
|
|
button.formEnctype = 256;
|
|
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
|
|
shouldBeEqualToString('button.getAttribute("formEnctype")', '256');
|
|
button.setAttribute('formEnctype', 512);
|
|
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
|
|
button.formMethod = 128;
|
|
shouldBeEqualToString('button.formMethod', 'get');
|
|
shouldBeEqualToString('button.getAttribute("formMethod")', '128');
|
|
button.setAttribute('formMethod', 17);
|
|
shouldBeEqualToString('button.formMethod', 'get');
|
|
button.formTarget = 100;
|
|
shouldBeEqualToString('button.formTarget', '100');
|
|
shouldBeEqualToString('button.getAttribute("formTarget")', '100');
|
|
button.setAttribute('formTarget', 281);
|
|
shouldBeEqualToString('button.formTarget', '281');
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|