mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 14:15:30 +00:00
Merge f-t to m-c
This commit is contained in:
commit
2cd8d1eb92
@ -637,6 +637,7 @@ public class Tab {
|
||||
clearFavicon();
|
||||
|
||||
setHasFeeds(false);
|
||||
setHasOpenSearch(false);
|
||||
updateTitle(null);
|
||||
updateIdentityData(null);
|
||||
setReaderEnabled(false);
|
||||
|
@ -18,8 +18,7 @@
|
||||
android:title="@string/contextmenu_subscribe"/>
|
||||
|
||||
<item android:id="@+id/add_search_engine"
|
||||
android:title="@string/contextmenu_add_search_engine"
|
||||
android:visible="false"/>
|
||||
android:title="@string/contextmenu_add_search_engine"/>
|
||||
|
||||
<item android:id="@+id/copyurl"
|
||||
android:title="@string/contextmenu_copyurl"/>
|
||||
|
8
mobile/android/base/tests/link_discovery.html
Normal file
8
mobile/android/base/tests/link_discovery.html
Normal file
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head id="linkparent">
|
||||
<title>Autodiscovery Test</title>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -67,6 +67,7 @@ skip-if = processor == "x86"
|
||||
# [testVkbOverlap] # see bug 907274
|
||||
|
||||
# Using JavascriptTest
|
||||
[testBrowserDiscovery]
|
||||
[testDeviceSearchEngine]
|
||||
[testJNI]
|
||||
# [testMozPay] # see bug 945675
|
||||
|
10
mobile/android/base/tests/testBrowserDiscovery.java
Normal file
10
mobile/android/base/tests/testBrowserDiscovery.java
Normal file
@ -0,0 +1,10 @@
|
||||
package org.mozilla.gecko.tests;
|
||||
|
||||
import org.mozilla.gecko.*;
|
||||
|
||||
|
||||
public class testBrowserDiscovery extends JavascriptTest {
|
||||
public testBrowserDiscovery() {
|
||||
super("testBrowserDiscovery.js");
|
||||
}
|
||||
}
|
151
mobile/android/base/tests/testBrowserDiscovery.js
Normal file
151
mobile/android/base/tests/testBrowserDiscovery.js
Normal file
@ -0,0 +1,151 @@
|
||||
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function ok(passed, text) {
|
||||
do_report_result(passed, text, Components.stack.caller, false);
|
||||
}
|
||||
|
||||
// We use a global variable to track the <browser> where the tests are happening
|
||||
let browser;
|
||||
|
||||
function setHandlerFunc(handler, test) {
|
||||
browser.addEventListener("DOMLinkAdded", function linkAdded(event) {
|
||||
browser.removeEventListener("DOMLinkAdded", linkAdded, false);
|
||||
Services.tm.mainThread.dispatch(handler.bind(this, test), Ci.nsIThread.DISPATCH_NORMAL);
|
||||
}, false);
|
||||
}
|
||||
|
||||
add_test(function setup_browser() {
|
||||
let BrowserApp = Services.wm.getMostRecentWindow("navigator:browser").BrowserApp;
|
||||
do_register_cleanup(function cleanup() {
|
||||
BrowserApp.closeTab(BrowserApp.getTabForBrowser(browser));
|
||||
});
|
||||
|
||||
let url = "http://mochi.test:8888/tests/robocop/link_discovery.html";
|
||||
browser = BrowserApp.addTab(url, { selected: true, parentId: BrowserApp.selectedTab.id }).browser;
|
||||
browser.addEventListener("load", function startTests(event) {
|
||||
browser.removeEventListener("load", startTests, true);
|
||||
Services.tm.mainThread.dispatch(run_next_test, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
}, true);
|
||||
});
|
||||
|
||||
let 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 execute_search_test(test) {
|
||||
if (browser.engines) {
|
||||
let matchCount = (!("count" in test) || browser.engines.length === test.count);
|
||||
let matchTitle = (test.title == browser.engines[0].title);
|
||||
ok(matchCount && matchTitle, test.text);
|
||||
browser.engines = null;
|
||||
} else {
|
||||
ok(!test.pass, test.text);
|
||||
}
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
function prep_search_test(test) {
|
||||
setHandlerFunc(execute_search_test, test);
|
||||
|
||||
let rel = test.rel || "search";
|
||||
let href = test.href || "http://so.not.here.mozilla.com/search.xml";
|
||||
let type = test.type || "application/opensearchdescription+xml";
|
||||
let title = test.title;
|
||||
if (!("pass" in test)) {
|
||||
test.pass = true;
|
||||
}
|
||||
|
||||
let head = browser.contentDocument.getElementById("linkparent");
|
||||
let link = browser.contentDocument.createElement("link");
|
||||
link.rel = rel;
|
||||
link.href = href;
|
||||
link.type = type;
|
||||
link.title = title;
|
||||
head.appendChild(link);
|
||||
}
|
||||
|
||||
let feedDiscoveryTests = [
|
||||
{ text: "rel feed discovered" },
|
||||
{ rel: "ALTERNATE", text: "rel is case insensitive" },
|
||||
{ rel: "-alternate-", pass: false, text: "rel -alternate- not discovered" },
|
||||
{ rel: "foo bar baz alternate 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/rss+xml", text: "type can be RSS" },
|
||||
{ type: "aPPliCAtion/RSS+xml", text: "type is case insensitve" },
|
||||
{ type: " application/atom+xml ", text: "type may contain extra whitespace" },
|
||||
{ type: "application/atom+xml; charset=utf-8", text: "type may have optional parameters (RFC2046)" },
|
||||
{ type: "aapplication/atom+xml", pass: false, text: "type should not be loosely matched" },
|
||||
{ rel: "alternate alternate alternate", count: 1, text: "only one feed should be added" }
|
||||
];
|
||||
|
||||
function execute_feed_test(test) {
|
||||
if (browser.feeds) {
|
||||
let matchCount = (!("count" in test) || browser.feeds.length === test.count);
|
||||
let matchTitle = (test.title == browser.feeds[0].title);
|
||||
ok(matchCount && matchTitle, test.text);
|
||||
browser.feeds = null;
|
||||
} else {
|
||||
ok(!test.pass, test.text);
|
||||
}
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
function prep_feed_test(test) {
|
||||
setHandlerFunc(execute_feed_test, test);
|
||||
|
||||
let rel = test.rel || "alternate";
|
||||
let href = test.href || "http://so.not.here.mozilla.com/feed.xml";
|
||||
let type = test.type || "application/atom+xml";
|
||||
let title = test.title;
|
||||
if (!("pass" in test)) {
|
||||
test.pass = true;
|
||||
}
|
||||
|
||||
let head = browser.contentDocument.getElementById("linkparent");
|
||||
let link = browser.contentDocument.createElement("link");
|
||||
link.rel = rel;
|
||||
link.href = href;
|
||||
link.type = type;
|
||||
link.title = title;
|
||||
head.appendChild(link);
|
||||
}
|
||||
|
||||
let searchTest;
|
||||
while ((searchTest = searchDiscoveryTests.shift())) {
|
||||
let title = searchTest.title || searchDiscoveryTests.length;
|
||||
searchTest.title = title;
|
||||
add_test(prep_search_test.bind(this, searchTest));
|
||||
}
|
||||
|
||||
let feedTest;
|
||||
while ((feedTest = feedDiscoveryTests.shift())) {
|
||||
let title = feedTest.title || feedDiscoveryTests.length;
|
||||
feedTest.title = title;
|
||||
add_test(prep_feed_test.bind(this, feedTest));
|
||||
}
|
||||
|
||||
run_next_test();
|
@ -365,10 +365,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
menu.findItem(R.id.add_to_launcher).setVisible(false);
|
||||
}
|
||||
|
||||
if (!tab.hasFeeds()) {
|
||||
menu.findItem(R.id.subscribe).setVisible(false);
|
||||
}
|
||||
|
||||
menu.findItem(R.id.subscribe).setVisible(tab.hasFeeds());
|
||||
menu.findItem(R.id.add_search_engine).setVisible(tab.hasOpenSearch());
|
||||
} else {
|
||||
// if there is no tab, remove anything tab dependent
|
||||
|
@ -3777,18 +3777,8 @@ Tab.prototype = {
|
||||
|
||||
// Clear page-specific opensearch engines and feeds for a new request.
|
||||
if (aStateFlags & Ci.nsIWebProgressListener.STATE_START && aRequest && aWebProgress.isTopLevel) {
|
||||
this.browser.engines = null;
|
||||
|
||||
// Send message to clear search engine option in context menu.
|
||||
let newEngineMessage = {
|
||||
type: "Link:OpenSearch",
|
||||
tabID: this.id,
|
||||
visible: false
|
||||
};
|
||||
|
||||
sendMessageToJava(newEngineMessage);
|
||||
|
||||
this.browser.feeds = null;
|
||||
this.browser.engines = null;
|
||||
this.browser.feeds = null;
|
||||
}
|
||||
|
||||
// true if the page loaded successfully (i.e., no 404s or other errors)
|
||||
|
Loading…
Reference in New Issue
Block a user