browser/base/content/test/general/browser_bug581947.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 function check(aElementName, aBarred) {
michael@0 2 let doc = gBrowser.contentDocument;
michael@0 3 let tooltip = document.getElementById("aHTMLTooltip");
michael@0 4 let content = doc.getElementById('content');
michael@0 5
michael@0 6 let e = doc.createElement(aElementName);
michael@0 7 content.appendChild(e);
michael@0 8
michael@0 9 ok(!tooltip.fillInPageTooltip(e),
michael@0 10 "No tooltip should be shown when the element is valid");
michael@0 11
michael@0 12 e.setCustomValidity('foo');
michael@0 13 if (aBarred) {
michael@0 14 ok(!tooltip.fillInPageTooltip(e),
michael@0 15 "No tooltip should be shown when the element is barred from constraint validation");
michael@0 16 } else {
michael@0 17 ok(tooltip.fillInPageTooltip(e),
michael@0 18 e.tagName + " " +"A tooltip should be shown when the element isn't valid");
michael@0 19 }
michael@0 20
michael@0 21 e.setAttribute('title', '');
michael@0 22 ok (!tooltip.fillInPageTooltip(e),
michael@0 23 "No tooltip should be shown if the title attribute is set");
michael@0 24
michael@0 25 e.removeAttribute('title');
michael@0 26 content.setAttribute('novalidate', '');
michael@0 27 ok (!tooltip.fillInPageTooltip(e),
michael@0 28 "No tooltip should be shown if the novalidate attribute is set on the form owner");
michael@0 29 content.removeAttribute('novalidate');
michael@0 30
michael@0 31 content.removeChild(e);
michael@0 32 }
michael@0 33
michael@0 34 function todo_check(aElementName, aBarred) {
michael@0 35 let doc = gBrowser.contentDocument;
michael@0 36 let tooltip = document.getElementById("aHTMLTooltip");
michael@0 37 let content = doc.getElementById('content');
michael@0 38
michael@0 39 let e = doc.createElement(aElementName);
michael@0 40 content.appendChild(e);
michael@0 41
michael@0 42 let cought = false;
michael@0 43 try {
michael@0 44 e.setCustomValidity('foo');
michael@0 45 } catch (e) {
michael@0 46 cought = true;
michael@0 47 }
michael@0 48
michael@0 49 todo(!cought, "setCustomValidity should exist for " + aElementName);
michael@0 50
michael@0 51 content.removeChild(e);
michael@0 52 }
michael@0 53
michael@0 54 function test () {
michael@0 55 waitForExplicitFinish();
michael@0 56 gBrowser.selectedTab = gBrowser.addTab();
michael@0 57 gBrowser.selectedBrowser.addEventListener("load", function () {
michael@0 58 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
michael@0 59
michael@0 60 let testData = [
michael@0 61 /* element name, barred */
michael@0 62 [ 'input', false ],
michael@0 63 [ 'textarea', false ],
michael@0 64 [ 'button', true ],
michael@0 65 [ 'select', false ],
michael@0 66 [ 'output', true ],
michael@0 67 [ 'fieldset', true ],
michael@0 68 [ 'object', true ],
michael@0 69 ];
michael@0 70
michael@0 71 for each (let data in testData) {
michael@0 72 check(data[0], data[1]);
michael@0 73 }
michael@0 74
michael@0 75 let todo_testData = [
michael@0 76 [ 'keygen', 'false' ],
michael@0 77 ];
michael@0 78
michael@0 79 for each(let data in todo_testData) {
michael@0 80 todo_check(data[0], data[1]);
michael@0 81 }
michael@0 82
michael@0 83 gBrowser.removeCurrentTab();
michael@0 84 finish();
michael@0 85 }, true);
michael@0 86
michael@0 87 content.location =
michael@0 88 "data:text/html,<!DOCTYPE html><html><body><form id='content'></form></body></html>";
michael@0 89 }
michael@0 90

mercurial