зеркало из https://github.com/mozilla/gecko-dev.git
bug 380454, r=benjamin, sr=sicking
This commit is contained in:
Родитель
f64926e7b5
Коммит
22dc5c4af2
|
@ -13,22 +13,36 @@ function test() {
|
|||
setTimeout(iconDiscovery, 1000);
|
||||
}
|
||||
|
||||
function iconDiscovery() {
|
||||
var tests = [
|
||||
{ text: "rel icon discovered" },
|
||||
{ rel: "abcdefg icon qwerty", text: "rel may contain additional rels separated by spaces" },
|
||||
{ rel: "ICON", text: "rel is case insensitive" },
|
||||
{ rel: "shortcut-icon", pass: false, text: "rel shortcut-icon not discovered" },
|
||||
{ href: "moz.png", text: "relative href works" },
|
||||
{ href: "notthere.png", text: "404'd icon is removed properly" },
|
||||
{ href: "data:image/x-icon,%00", type: "image/x-icon", text: "data: URIs work" },
|
||||
{ type: "image/png; charset=utf-8", text: "type may have optional parameters (RFC2046)" }
|
||||
];
|
||||
var iconDiscoveryTests = [
|
||||
{ text: "rel icon discovered" },
|
||||
{ rel: "abcdefg icon qwerty", text: "rel may contain additional rels separated by spaces" },
|
||||
{ rel: "ICON", text: "rel is case insensitive" },
|
||||
{ rel: "shortcut-icon", pass: false, text: "rel shortcut-icon not discovered" },
|
||||
{ href: "moz.png", text: "relative href works" },
|
||||
{ href: "notthere.png", text: "404'd icon is removed properly" },
|
||||
{ href: "data:image/x-icon,%00", type: "image/x-icon", text: "data: URIs work" },
|
||||
{ type: "image/png; charset=utf-8", text: "type may have optional parameters (RFC2046)" }
|
||||
];
|
||||
|
||||
for (let i = 0; i < tests.length; i++) {
|
||||
function runIconDiscoveryTest() {
|
||||
var test = iconDiscoveryTests[0];
|
||||
var head = gTestPage.document.getElementById("linkparent");
|
||||
var hasSrc = gProxyFavIcon.hasAttribute("src");
|
||||
if (test.pass)
|
||||
ok(hasSrc, test.text);
|
||||
else
|
||||
ok(!hasSrc, test.text);
|
||||
|
||||
head.removeChild(head.getElementsByTagName('link')[0]);
|
||||
iconDiscoveryTests.shift();
|
||||
setTimeout(iconDiscovery, 0) // Run the next test.
|
||||
}
|
||||
|
||||
function iconDiscovery() {
|
||||
if (iconDiscoveryTests.length) {
|
||||
gProxyFavIcon.removeAttribute("src");
|
||||
|
||||
var test = tests[i];
|
||||
var test = iconDiscoveryTests[0];
|
||||
var head = gTestPage.document.getElementById("linkparent");
|
||||
var link = gTestPage.document.createElement("link");
|
||||
|
||||
|
@ -43,45 +57,68 @@ function iconDiscovery() {
|
|||
link.type = type;
|
||||
head.appendChild(link);
|
||||
|
||||
var hasSrc = gProxyFavIcon.hasAttribute("src");
|
||||
if (test.pass)
|
||||
ok(hasSrc, test.text);
|
||||
else
|
||||
ok(!hasSrc, test.text);
|
||||
|
||||
head.removeChild(link);
|
||||
setTimeout(runIconDiscoveryTest, 0);
|
||||
} else {
|
||||
searchDiscovery();
|
||||
}
|
||||
searchDiscovery();
|
||||
}
|
||||
|
||||
var searchDiscoveryTests = [
|
||||
{ text: "rel search discovered" },
|
||||
{ rel: "SEARCH", text: "rel is case insensitive" },
|
||||
{ rel: "-search-", pass: false, text: "rel -search- not discovered" },
|
||||
{ rel: "foo bar baz search quux", text: "rel may contain additional rels separated by spaces" },
|
||||
{ href: "https://not.mozilla.com", text: "HTTPS ok" },
|
||||
{ href: "ftp://not.mozilla.com", text: "FTP ok" },
|
||||
{ href: "data:text/foo,foo", pass: false, text: "data URI not permitted" },
|
||||
{ href: "javascript:alert(0)", pass: false, text: "JS URI not permitted" },
|
||||
{ type: "APPLICATION/OPENSEARCHDESCRIPTION+XML", text: "type is case insensitve" },
|
||||
{ type: " application/opensearchdescription+xml ", text: "type may contain extra whitespace" },
|
||||
{ type: "application/opensearchdescription+xml; charset=utf-8", text: "type may have optional parameters (RFC2046)" },
|
||||
{ type: "aapplication/opensearchdescription+xml", pass: false, text: "type should not be loosely matched" },
|
||||
{ rel: "search search search", count: 1, text: "only one engine should be added" }
|
||||
];
|
||||
|
||||
function runSearchDiscoveryTest() {
|
||||
var browser = gBrowser.getBrowserForDocument(gTestPage.document);
|
||||
var test = searchDiscoveryTests[0];
|
||||
var title = test.title || searchDiscoveryTests.length;
|
||||
if (browser.engines) {
|
||||
var hasEngine = (test.count) ? (browser.engines[0].title == title &&
|
||||
browser.engines.length == test.count) :
|
||||
(browser.engines[0].title == title);
|
||||
ok(hasEngine, test.text);
|
||||
browser.engines = null;
|
||||
}
|
||||
else
|
||||
ok(!test.pass, test.text);
|
||||
|
||||
searchDiscoveryTests.shift();
|
||||
setTimeout(searchDiscovery, 0) // Run the next test.
|
||||
}
|
||||
|
||||
function runMultipleEnginesTestAndFinalize() {
|
||||
var browser = gBrowser.getBrowserForDocument(gTestPage.document);
|
||||
ok(browser.engines, "has engines");
|
||||
is(browser.engines.length, 1, "only one engine");
|
||||
is(browser.engines[0].uri, "http://first.mozilla.com/search.xml", "first engine wins");
|
||||
|
||||
gTestPage.close();
|
||||
finish();
|
||||
}
|
||||
|
||||
function searchDiscovery() {
|
||||
var tests = [
|
||||
{ text: "rel search discovered" },
|
||||
{ rel: "SEARCH", text: "rel is case insensitive" },
|
||||
{ rel: "-search-", pass: false, text: "rel -search- not discovered" },
|
||||
{ rel: "foo bar baz search quux", text: "rel may contain additional rels separated by spaces" },
|
||||
{ href: "https://not.mozilla.com", text: "HTTPS ok" },
|
||||
{ href: "ftp://not.mozilla.com", text: "FTP ok" },
|
||||
{ href: "data:text/foo,foo", pass: false, text: "data URI not permitted" },
|
||||
{ href: "javascript:alert(0)", pass: false, text: "JS URI not permitted" },
|
||||
{ type: "APPLICATION/OPENSEARCHDESCRIPTION+XML", text: "type is case insensitve" },
|
||||
{ type: " application/opensearchdescription+xml ", text: "type may contain extra whitespace" },
|
||||
{ type: "application/opensearchdescription+xml; charset=utf-8", text: "type may have optional parameters (RFC2046)" },
|
||||
{ type: "aapplication/opensearchdescription+xml", pass: false, text: "type should not be loosely matched" },
|
||||
{ rel: "search search search", count: 1, text: "only one engine should be added" }
|
||||
];
|
||||
|
||||
var head = gTestPage.document.getElementById("linkparent");
|
||||
var browser = gBrowser.getBrowserForDocument(gTestPage.document);
|
||||
|
||||
for (let i = 0; i < tests.length; i++) {
|
||||
var test = tests[i];
|
||||
if (searchDiscoveryTests.length) {
|
||||
var test = searchDiscoveryTests[0];
|
||||
var link = gTestPage.document.createElement("link");
|
||||
|
||||
var rel = test.rel || "search";
|
||||
var href = test.href || "http://so.not.here.mozilla.com/search.xml";
|
||||
var type = test.type || "application/opensearchdescription+xml";
|
||||
var title = test.title || i;
|
||||
var title = test.title || searchDiscoveryTests.length;
|
||||
if (test.pass == undefined)
|
||||
test.pass = true;
|
||||
|
||||
|
@ -91,33 +128,20 @@ function searchDiscovery() {
|
|||
link.title = title;
|
||||
head.appendChild(link);
|
||||
|
||||
if (browser.engines) {
|
||||
var hasEngine = (test.count) ? (browser.engines[0].title == title &&
|
||||
browser.engines.length == test.count) :
|
||||
(browser.engines[0].title == title);
|
||||
ok(hasEngine, test.text);
|
||||
browser.engines = null;
|
||||
}
|
||||
else
|
||||
ok(!test.pass, test.text);
|
||||
setTimeout(runSearchDiscoveryTest, 0);
|
||||
} else {
|
||||
// Test multiple engines with the same title
|
||||
var link = gTestPage.document.createElement("link");
|
||||
link.rel = "search";
|
||||
link.href = "http://first.mozilla.com/search.xml";
|
||||
link.type = "application/opensearchdescription+xml";
|
||||
link.title = "Test Engine";
|
||||
var link2 = link.cloneNode(false);
|
||||
link2.href = "http://second.mozilla.com/search.xml";
|
||||
|
||||
head.appendChild(link);
|
||||
head.appendChild(link2);
|
||||
|
||||
setTimeout(runMultipleEnginesTestAndFinalize, 0);
|
||||
}
|
||||
|
||||
// Test multiple engines with the same title
|
||||
var link = gTestPage.document.createElement("link");
|
||||
link.rel = "search";
|
||||
link.href = "http://first.mozilla.com/search.xml";
|
||||
link.type = "application/opensearchdescription+xml";
|
||||
link.title = "Test Engine";
|
||||
var link2 = link.cloneNode(false);
|
||||
link2.href = "http://second.mozilla.com/search.xml";
|
||||
|
||||
head.appendChild(link);
|
||||
head.appendChild(link2);
|
||||
|
||||
ok(browser.engines, "has engines");
|
||||
is(browser.engines.length, 1, "only one engine");
|
||||
is(browser.engines[0].uri, "http://first.mozilla.com/search.xml", "first engine wins");
|
||||
|
||||
gTestPage.close();
|
||||
finish();
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "nsParserUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPLDOMEvent.h"
|
||||
|
||||
class nsHTMLLinkElement : public nsGenericHTMLElement,
|
||||
public nsIDOMHTMLLinkElement,
|
||||
|
@ -273,9 +274,10 @@ nsHTMLLinkElement::CreateAndDispatchEvent(nsIDocument* aDoc,
|
|||
strings, eIgnoreCase) != ATTR_VALUE_NO_MATCH)
|
||||
return;
|
||||
|
||||
nsContentUtils::DispatchTrustedEvent(aDoc,
|
||||
static_cast<nsIContent*>(this),
|
||||
aEventName, PR_TRUE, PR_TRUE);
|
||||
nsRefPtr<nsPLDOMEvent> event = new nsPLDOMEvent(this, aEventName);
|
||||
if (event) {
|
||||
event->PostDOMEvent();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -136,7 +136,7 @@ NS_DispatchToCurrentThread(nsIRunnable *event)
|
|||
{
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
nsIThread *thread = NS_GetCurrentThread();
|
||||
NS_ENSURE_STATE(thread);
|
||||
if (!thread) { return NS_ERROR_UNEXPECTED; }
|
||||
#else
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsresult rv = NS_GetCurrentThread(getter_AddRefs(thread));
|
||||
|
|
|
@ -200,6 +200,10 @@ nsThreadManager::GetCurrentThread()
|
|||
if (data)
|
||||
return static_cast<nsThread *>(data);
|
||||
|
||||
if (!mInitialized) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// OK, that's fine. We'll dynamically create one :-)
|
||||
nsRefPtr<nsThread> thread = new nsThread();
|
||||
if (!thread || NS_FAILED(thread->InitCurrentThread()))
|
||||
|
|
|
@ -69,7 +69,8 @@ public:
|
|||
// method must be called when the given thread is the current thread.
|
||||
void UnregisterCurrentThread(nsThread *thread);
|
||||
|
||||
// Returns the current thread. Returns null if OOM.
|
||||
// Returns the current thread. Returns null if OOM or if ThreadManager isn't
|
||||
// initialized.
|
||||
nsThread *GetCurrentThread();
|
||||
|
||||
// This needs to be public in order to support static instantiation of this
|
||||
|
|
Загрузка…
Ссылка в новой задаче