7 DOMLinkHandler.handleEvent =
function (
event) {
19 gBrowser.selectedTab = gBrowser.addTab();
20 browser = gBrowser.selectedBrowser;
22 event.currentTarget.removeEventListener(
"load",
arguments.callee,
true);
25 content.location =
"chrome://mochikit/content/browser/browser/base/content/test/discovery.html";
29 { text:
"rel icon discovered" },
30 { rel:
"abcdefg icon qwerty", text:
"rel may contain additional rels separated by spaces" },
31 { rel:
"ICON", text:
"rel is case insensitive" },
32 { rel:
"shortcut-icon", pass:
false, text:
"rel shortcut-icon not discovered" },
33 {
href:
"moz.png", text:
"relative href works" },
34 {
href:
"notthere.png", text:
"404'd icon is removed properly" },
35 {
href:
"data:image/x-icon,%00", type:
"image/x-icon", text:
"data: URIs work" },
36 { type:
"image/png; charset=utf-8", text:
"type may have optional parameters (RFC2046)" }
41 var head =
doc().getElementById(
"linkparent");
44 ok(hasSrc, test.text);
46 ok(!hasSrc, test.text);
48 head.removeChild(head.getElementsByTagName(
'link')[0]);
59 var head =
doc().getElementById(
"linkparent");
60 var link =
doc().createElement(
"link");
62 var rel = test.rel ||
"icon";
63 var
href = test.href ||
"chrome://mochikit/content/browser/browser/base/content/test/moz.png";
64 var type = test.type ||
"image/png";
65 if (test.pass == undefined)
71 head.appendChild(link);
78 { text:
"rel search discovered" },
79 { rel:
"SEARCH", text:
"rel is case insensitive" },
80 { rel:
"-search-", pass:
false, text:
"rel -search- not discovered" },
81 { rel:
"foo bar baz search quux", text:
"rel may contain additional rels separated by spaces" },
82 {
href:
"https://not.mozilla.com", text:
"HTTPS ok" },
83 {
href:
"ftp://not.mozilla.com", text:
"FTP ok" },
84 {
href:
"data:text/foo,foo", pass:
false, text:
"data URI not permitted" },
85 {
href:
"javascript:alert(0)", pass:
false, text:
"JS URI not permitted" },
86 { type:
"APPLICATION/OPENSEARCHDESCRIPTION+XML", text:
"type is case insensitve" },
87 { type:
" application/opensearchdescription+xml ", text:
"type may contain extra whitespace" },
88 { type:
"application/opensearchdescription+xml; charset=utf-8", text:
"type may have optional parameters (RFC2046)" },
89 { type:
"aapplication/opensearchdescription+xml", pass:
false, text:
"type should not be loosely matched" },
90 { rel:
"search search search",
count: 1, text:
"only one engine should be added" }
97 var hasEngine = (test.count) ? (
browser.engines[0].title == title &&
98 browser.engines.length == test.count) :
99 (
browser.engines[0].title == title);
100 ok(hasEngine, test.text);
104 ok(!test.pass, test.text);
118 ok(
browser.engines,
"has engines");
119 is(
browser.engines.length, 1,
"only one engine");
120 is(
browser.engines[0].uri,
"http://first.mozilla.com/search.xml",
"first engine wins");
122 gBrowser.removeCurrentTab();
131 var head =
doc().getElementById(
"linkparent");
136 var link =
doc().createElement(
"link");
138 var rel = test.rel ||
"search";
139 var
href = test.href ||
"http://so.not.here.mozilla.com/search.xml";
140 var type = test.type ||
"application/opensearchdescription+xml";
142 if (test.pass == undefined)
149 head.appendChild(link);
153 var link =
doc().createElement(
"link");
155 link.href =
"http://first.mozilla.com/search.xml";
156 link.type =
"application/opensearchdescription+xml";
157 link.title =
"Test Engine";
158 var link2 = link.cloneNode(
false);
159 link2.href =
"http://second.mozilla.com/search.xml";
161 head.appendChild(link);
162 head.appendChild(link2);
function doc() browser.contentDocument
function setHandlerFunc(aResultFunc)
function runIconDiscoveryTest()
function searchDiscovery()
return!aWindow arguments!aWindow arguments[0]
function runMultipleEnginesTestAndFinalize()
function runSearchDiscoveryTest()