mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge mozilla-central to mozilla-inbound
This commit is contained in:
commit
100b15c34b
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="4e4e579b4b1e35f863ed43ef6ba840f49bfd761c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="09642e74e250fbc62db860c808ef188628fca55d"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="230f11aff069d90d20fc2dc63b48e9ae3d4bdcd1"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="4e4e579b4b1e35f863ed43ef6ba840f49bfd761c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="09642e74e250fbc62db860c808ef188628fca55d"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="230f11aff069d90d20fc2dc63b48e9ae3d4bdcd1"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="dc5ca96695cab87b4c2fcd7c9f046ae3415a70a5"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ee6e7320bb83409ebd4685fbd87a8ae033704182"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="276ce45e78b09c4a4ee643646f691d22804754c1">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="4e4e579b4b1e35f863ed43ef6ba840f49bfd761c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="09642e74e250fbc62db860c808ef188628fca55d"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="230f11aff069d90d20fc2dc63b48e9ae3d4bdcd1"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="4e4e579b4b1e35f863ed43ef6ba840f49bfd761c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="09642e74e250fbc62db860c808ef188628fca55d"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="230f11aff069d90d20fc2dc63b48e9ae3d4bdcd1"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="4e4e579b4b1e35f863ed43ef6ba840f49bfd761c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="09642e74e250fbc62db860c808ef188628fca55d"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="230f11aff069d90d20fc2dc63b48e9ae3d4bdcd1"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="dc5ca96695cab87b4c2fcd7c9f046ae3415a70a5"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ee6e7320bb83409ebd4685fbd87a8ae033704182"/>
|
||||
|
@ -4,6 +4,6 @@
|
||||
"remote": "",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "158fb07e2e4939dddee026a33a05d65e38bb0e67",
|
||||
"revision": "056dbe15b2aac2b252a119c211a85cb14165aa81",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="4e4e579b4b1e35f863ed43ef6ba840f49bfd761c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="09642e74e250fbc62db860c808ef188628fca55d"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="230f11aff069d90d20fc2dc63b48e9ae3d4bdcd1"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="4e4e579b4b1e35f863ed43ef6ba840f49bfd761c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="09642e74e250fbc62db860c808ef188628fca55d"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="230f11aff069d90d20fc2dc63b48e9ae3d4bdcd1"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="4e4e579b4b1e35f863ed43ef6ba840f49bfd761c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="09642e74e250fbc62db860c808ef188628fca55d"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="230f11aff069d90d20fc2dc63b48e9ae3d4bdcd1"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="dc5ca96695cab87b4c2fcd7c9f046ae3415a70a5"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ee6e7320bb83409ebd4685fbd87a8ae033704182"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="4e4e579b4b1e35f863ed43ef6ba840f49bfd761c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="09642e74e250fbc62db860c808ef188628fca55d"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="230f11aff069d90d20fc2dc63b48e9ae3d4bdcd1"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -399,8 +399,6 @@
|
||||
@BINPATH@/components/DOMWifiManager.manifest
|
||||
@BINPATH@/components/DOMWifiP2pManager.js
|
||||
@BINPATH@/components/DOMWifiP2pManager.manifest
|
||||
@BINPATH@/components/EthernetManager.js
|
||||
@BINPATH@/components/EthernetManager.manifest
|
||||
@BINPATH@/components/NetworkInterfaceListService.js
|
||||
@BINPATH@/components/NetworkInterfaceListService.manifest
|
||||
@BINPATH@/components/NetworkManager.js
|
||||
|
@ -41,6 +41,9 @@ function runTests() {
|
||||
yield whenPagesUpdated(null, true);
|
||||
yield addNewTabPageTab();
|
||||
checkGrid("2,1,3,4,,,,,");
|
||||
|
||||
// Make sure these added links have the right type
|
||||
is(getCell(1).site.link.type, "history", "added link is history");
|
||||
}
|
||||
|
||||
function link(id) {
|
||||
|
@ -2,54 +2,54 @@
|
||||
skip-if = e10s # Bug ?????? - devtools tests disabled with e10s
|
||||
subsuite = devtools
|
||||
support-files =
|
||||
browser_inspector_breadcrumbs.html
|
||||
browser_inspector_bug_650804_search.html
|
||||
browser_inspector_bug_831693_search_suggestions.html
|
||||
browser_inspector_cmd_inspect.html
|
||||
browser_inspector_dead_node_exception.html
|
||||
browser_inspector_destroyselection.html
|
||||
browser_inspector_highlighter.html
|
||||
browser_inspector_infobar.html
|
||||
browser_inspector_menu.html
|
||||
browser_inspector_select_last_selected.html
|
||||
browser_inspector_select_last_selected2.html
|
||||
browser_inspector_bug_848731_reset_selection_on_delete.html
|
||||
browser_inspector_bug_958456_highlight_comments.html
|
||||
doc_inspector_breadcrumbs.html
|
||||
doc_inspector_delete-selected-node-01.html
|
||||
doc_inspector_delete-selected-node-02.html
|
||||
doc_inspector_gcli-inspect-command.html
|
||||
doc_inspector_highlighter-comments.html
|
||||
doc_inspector_highlighter.html
|
||||
doc_inspector_infobar.html
|
||||
doc_inspector_menu.html
|
||||
doc_inspector_remove-iframe-during-load.html
|
||||
doc_inspector_search.html
|
||||
doc_inspector_search-suggestions.html
|
||||
doc_inspector_select-last-selected-01.html
|
||||
doc_inspector_select-last-selected-02.html
|
||||
head.js
|
||||
|
||||
[browser_inspector_basic_highlighter.js]
|
||||
[browser_inspector_breadcrumbs.js]
|
||||
[browser_inspector_bug_650804_search.js]
|
||||
[browser_inspector_bug_665880.js]
|
||||
[browser_inspector_bug_672902_keyboard_shortcuts.js]
|
||||
[browser_inspector_bug_674871.js]
|
||||
[browser_inspector_bug_699308_iframe_navigation.js]
|
||||
[browser_inspector_bug_817558_delete_node.js]
|
||||
[browser_inspector_bug_831693_combinator_suggestions.js]
|
||||
[browser_inspector_bug_831693_input_suggestion.js]
|
||||
# [browser_inspector_bug_831693_searchbox_panel_navigation.js]
|
||||
# Disabled for too many intermittent failures (bug 851349)
|
||||
[browser_inspector_bug_840156_destroy_after_navigation.js]
|
||||
[browser_inspector_cmd_inspect.js]
|
||||
[browser_inspector_dead_node_exception.js]
|
||||
[browser_inspector_destroyselection.js]
|
||||
[browser_inspector_highlighter.js]
|
||||
[browser_inspector_iframeTest.js]
|
||||
[browser_inspector_delete-selected-node-01.js]
|
||||
[browser_inspector_delete-selected-node-02.js]
|
||||
[browser_inspector_delete-selected-node-03.js]
|
||||
[browser_inspector_destroy-after-navigation.js]
|
||||
[browser_inspector_gcli-inspect-command.js]
|
||||
[browser_inspector_highlighter-01.js]
|
||||
[browser_inspector_highlighter-02.js]
|
||||
[browser_inspector_highlighter-03.js]
|
||||
[browser_inspector_highlighter-comments.js]
|
||||
[browser_inspector_highlighter-iframes.js]
|
||||
[browser_inspector_iframe-navigation.js]
|
||||
[browser_inspector_infobar.js]
|
||||
skip-if = true # Bug 1028609
|
||||
[browser_inspector_initialization.js]
|
||||
[browser_inspector_inspect-object-element.js]
|
||||
[browser_inspector_invalidate.js]
|
||||
[browser_inspector_keyboard-shortcuts.js]
|
||||
[browser_inspector_menu.js]
|
||||
[browser_inspector_navigation.js]
|
||||
[browser_inspector_pseudoClass_menu.js]
|
||||
[browser_inspector_pseudoclass_lock.js]
|
||||
[browser_inspector_picker-stop-on-destroy.js]
|
||||
[browser_inspector_picker-stop-on-tool-change.js]
|
||||
[browser_inspector_pseudoclass-lock.js]
|
||||
[browser_inspector_pseudoclass-menu.js]
|
||||
[browser_inspector_reload.js]
|
||||
[browser_inspector_remove-iframe-during-load.js]
|
||||
[browser_inspector_scrolling.js]
|
||||
[browser_inspector_select_last_selected.js]
|
||||
[browser_inspector_search-01.js]
|
||||
[browser_inspector_search-02.js]
|
||||
[browser_inspector_search-03.js]
|
||||
[browser_inspector_select-last-selected.js]
|
||||
# [browser_inspector_search-navigation.js]
|
||||
# Disabled for too many intermittent failures (bug 851349)
|
||||
[browser_inspector_sidebarstate.js]
|
||||
[browser_inspector_bug_848731_reset_selection_on_delete.js]
|
||||
[browser_inspector_bug_922125_destroy_on_navigate.js]
|
||||
[browser_inspector_bug_958456_highlight_comments.js]
|
||||
[browser_inspector_bug_958169_switch_to_inspector_on_pick.js]
|
||||
[browser_inspector_bug_961771_picker_stops_on_tool_select.js]
|
||||
[browser_inspector_bug_962478_picker_stops_on_destroy.js]
|
||||
[browser_inspector_switch-to-inspector-on-pick.js]
|
||||
[browser_inspector_update-on-navigation.js]
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
// Test that the breadcrumbs widget content is correct.
|
||||
|
||||
const TEST_URI = TEST_URL_ROOT + "browser_inspector_breadcrumbs.html";
|
||||
const TEST_URI = TEST_URL_ROOT + "doc_inspector_breadcrumbs.html";
|
||||
const NODES = [
|
||||
{nodeId: "#i1111", result: "i1 i11 i111 i1111"},
|
||||
{nodeId: "#i22", result: "i2 i22 i221"},
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
// Test to ensure inspector handles deletion of selected node correctly.
|
||||
|
||||
const TEST_URL = TEST_URL_ROOT + "browser_inspector_destroyselection.html";
|
||||
const TEST_URL = TEST_URL_ROOT + "doc_inspector_delete-selected-node-01.html";
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
let { inspector } = yield openInspectorForURL(TEST_URL);
|
@ -10,7 +10,7 @@
|
||||
// box model view, and breadcrumbs, reset accordingly to show the right node
|
||||
|
||||
const TEST_PAGE = TEST_URL_ROOT +
|
||||
"browser_inspector_bug_848731_reset_selection_on_delete.html";
|
||||
"doc_inspector_delete-selected-node-02.html";
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
let { inspector } = yield openInspectorForURL(TEST_PAGE);
|
@ -6,7 +6,7 @@
|
||||
// Test to ensure inspector can handle destruction of selected node inside an
|
||||
// iframe.
|
||||
|
||||
const TEST_URL = TEST_URL_ROOT + "browser_inspector_destroyselection.html";
|
||||
const TEST_URL = TEST_URL_ROOT + "doc_inspector_delete-selected-node-01.html";
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
let { inspector } = yield openInspectorForURL(TEST_URL);
|
@ -5,7 +5,7 @@
|
||||
|
||||
// Testing that the gcli 'inspect' command works as it should.
|
||||
|
||||
const TEST_URI = TEST_URL_ROOT + "browser_inspector_cmd_inspect.html";
|
||||
const TEST_URI = TEST_URL_ROOT + "doc_inspector_gcli-inspect-command.html";
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
return helpers.addTabWithToolbar(TEST_URI, function(options) {
|
@ -8,7 +8,7 @@
|
||||
|
||||
// Test that the highlighter is correctly displayed over a variety of elements
|
||||
|
||||
const TEST_URI = TEST_URL_ROOT + "browser_inspector_highlighter.html";
|
||||
const TEST_URI = TEST_URL_ROOT + "doc_inspector_highlighter.html";
|
||||
|
||||
let test = asyncTest(function*() {
|
||||
let { inspector } = yield openInspectorForURL(TEST_URI);
|
@ -9,7 +9,7 @@
|
||||
// highlighter, depending on the type of node hovered over.
|
||||
|
||||
const TEST_PAGE = TEST_URL_ROOT +
|
||||
"browser_inspector_bug_958456_highlight_comments.html";
|
||||
"doc_inspector_highlighter-comments.html";
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
let { inspector } = yield openInspectorForURL(TEST_PAGE);
|
@ -5,7 +5,7 @@
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/inspector/" +
|
||||
"test/browser_inspector_infobar.html";
|
||||
"test/doc_inspector_infobar.html";
|
||||
const DOORHANGER_ARROW_HEIGHT = 5;
|
||||
|
||||
// Test that hovering over nodes in the markup-view shows the highlighter over
|
||||
|
@ -7,7 +7,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
// 1) menu items are disabled/enabled depending on the clicked node
|
||||
// 2) actions triggered by the items work correctly
|
||||
|
||||
const TEST_URL = TEST_URL_ROOT + "browser_inspector_menu.html";
|
||||
const TEST_URL = TEST_URL_ROOT + "doc_inspector_menu.html";
|
||||
const MENU_SENSITIVITY_TEST_DATA = [
|
||||
{
|
||||
desc: "doctype node",
|
||||
|
@ -8,7 +8,7 @@
|
||||
// Test that inspector updates when page is navigated.
|
||||
|
||||
const TEST_URL_FILE = "browser/browser/devtools/inspector/test/" +
|
||||
"browser_inspector_breadcrumbs.html";
|
||||
"doc_inspector_breadcrumbs.html";
|
||||
|
||||
const TEST_URL_1 = "http://test1.example.org/" + TEST_URL_FILE;
|
||||
const TEST_URL_2 = "http://test2.example.org/" + TEST_URL_FILE;
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Testing that the inspector doesn't go blank when navigating to a page that
|
||||
// deletes an iframe while loading.
|
||||
|
||||
const TEST_URL = TEST_URL_ROOT + "browser_inspector_dead_node_exception.html";
|
||||
const TEST_URL = TEST_URL_ROOT + "doc_inspector_remove-iframe-during-load.html";
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
let { inspector, toolbox } = yield openInspectorForURL("about:blank");
|
@ -6,7 +6,7 @@
|
||||
// Test that searching for nodes in the search field actually selects those
|
||||
// nodes.
|
||||
|
||||
const TEST_URL = TEST_URL_ROOT + "browser_inspector_bug_650804_search.html";
|
||||
const TEST_URL = TEST_URL_ROOT + "doc_inspector_search.html";
|
||||
|
||||
// Indexes of the keys in the KEY_STATES array that should listen to "keypress"
|
||||
// event instead of "command". These are keys that don't change the content of
|
@ -6,7 +6,7 @@
|
||||
// Testing that searching for combining selectors using the inspector search
|
||||
// field produces correct suggestions.
|
||||
|
||||
const TEST_URL = TEST_URL_ROOT + "browser_inspector_bug_831693_search_suggestions.html";
|
||||
const TEST_URL = TEST_URL_ROOT + "doc_inspector_search-suggestions.html";
|
||||
|
||||
// An array of (key, suggestions) pairs where key is a key to press and
|
||||
// suggestions is an array of suggestions that should be shown in the popup.
|
@ -6,7 +6,7 @@
|
||||
// Testing that searching for elements using the inspector search field
|
||||
// produces correct suggestions.
|
||||
|
||||
const TEST_URL = TEST_URL_ROOT + "browser_inspector_bug_650804_search.html";
|
||||
const TEST_URL = TEST_URL_ROOT + "doc_inspector_search.html";
|
||||
|
||||
// An array of (key, suggestions) pairs where key is a key to press and
|
||||
// suggestions is an array of suggestions that should be shown in the popup.
|
@ -67,7 +67,7 @@ function test()
|
||||
waitForFocus(setupTest, content);
|
||||
}, true);
|
||||
|
||||
content.location = "http://mochi.test:8888/browser/browser/devtools/inspector/test/browser_inspector_bug_831693_search_suggestions.html";
|
||||
content.location = "http://mochi.test:8888/browser/browser/devtools/inspector/test/doc_inspector_search-suggestions.html";
|
||||
|
||||
function $(id) {
|
||||
if (id == null) return null;
|
@ -6,8 +6,8 @@
|
||||
|
||||
// Checks that the expected default node is selected after a page navigation or
|
||||
// a reload.
|
||||
let PAGE_1 = TEST_URL_ROOT + "browser_inspector_select_last_selected.html";
|
||||
let PAGE_2 = TEST_URL_ROOT + "browser_inspector_select_last_selected2.html";
|
||||
let PAGE_1 = TEST_URL_ROOT + "doc_inspector_select-last-selected-01.html";
|
||||
let PAGE_2 = TEST_URL_ROOT + "doc_inspector_select-last-selected-02.html";
|
||||
|
||||
// An array of test cases with following properties:
|
||||
// - url: URL to navigate to. If URL == content.location, reload instead.
|
@ -14,6 +14,7 @@ let {OutputParser} = devtools.require("devtools/output-parser");
|
||||
|
||||
const COLOR_CLASS = "color-class";
|
||||
const URL_CLASS = "url-class";
|
||||
const CUBIC_BEZIER_CLASS = "bezier-class";
|
||||
|
||||
function test() {
|
||||
function countAll(fragment) {
|
||||
@ -25,12 +26,18 @@ function test() {
|
||||
function countUrls(fragment) {
|
||||
return fragment.querySelectorAll("." + URL_CLASS).length;
|
||||
}
|
||||
function countCubicBeziers(fragment) {
|
||||
return fragment.querySelectorAll("." + CUBIC_BEZIER_CLASS).length;
|
||||
}
|
||||
function getColor(fragment, index) {
|
||||
return fragment.querySelectorAll("." + COLOR_CLASS)[index||0].textContent;
|
||||
}
|
||||
function getUrl(fragment, index) {
|
||||
return fragment.querySelectorAll("." + URL_CLASS)[index||0].textContent;
|
||||
}
|
||||
function getCubicBezier(fragment, index) {
|
||||
return fragment.querySelectorAll("." + CUBIC_BEZIER_CLASS)[index||0].textContent;
|
||||
}
|
||||
|
||||
let testData = [
|
||||
{
|
||||
@ -225,6 +232,67 @@ function test() {
|
||||
is(countAll(fragment), 1);
|
||||
is(getUrl(fragment), "../../../look/at/this/folder/structure/../../red.blue.green.svg");
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "transition-timing-function",
|
||||
value: "linear",
|
||||
test: fragment => {
|
||||
is(countCubicBeziers(fragment), 1);
|
||||
is(getCubicBezier(fragment), "linear");
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "animation-timing-function",
|
||||
value: "ease-in-out",
|
||||
test: fragment => {
|
||||
is(countCubicBeziers(fragment), 1);
|
||||
is(getCubicBezier(fragment), "ease-in-out");
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "animation-timing-function",
|
||||
value: "cubic-bezier(.1, 0.55, .9, -3.45)",
|
||||
test: fragment => {
|
||||
is(countCubicBeziers(fragment), 1);
|
||||
is(getCubicBezier(fragment), "cubic-bezier(.1, 0.55, .9, -3.45)");
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "animation",
|
||||
value: "move 3s cubic-bezier(.1, 0.55, .9, -3.45)",
|
||||
test: fragment => {
|
||||
is(countCubicBeziers(fragment), 1);
|
||||
is(getCubicBezier(fragment), "cubic-bezier(.1, 0.55, .9, -3.45)");
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "transition",
|
||||
value: "top 1s ease-in",
|
||||
test: fragment => {
|
||||
is(countCubicBeziers(fragment), 1);
|
||||
is(getCubicBezier(fragment), "ease-in");
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "transition",
|
||||
value: "top 3s steps(4, end)",
|
||||
test: fragment => {
|
||||
is(countAll(fragment), 0);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "transition",
|
||||
value: "top 3s step-start",
|
||||
test: fragment => {
|
||||
is(countAll(fragment), 0);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "transition",
|
||||
value: "top 3s step-end",
|
||||
test: fragment => {
|
||||
is(countAll(fragment), 0);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@ -235,6 +303,7 @@ function test() {
|
||||
data.test(parser.parseCssProperty(data.name, data.value, {
|
||||
colorClass: COLOR_CLASS,
|
||||
urlClass: URL_CLASS,
|
||||
bezierClass: CUBIC_BEZIER_CLASS,
|
||||
defaultColorType: false
|
||||
}));
|
||||
}
|
||||
|
@ -309,7 +309,6 @@ function CreateSocialMarkWidget(aId, aProvider) {
|
||||
node.setAttribute('type', "socialmark");
|
||||
node.style.listStyleImage = "url(" + (aProvider.unmarkedIcon || aProvider.icon32URL || aProvider.iconURL) + ")";
|
||||
node.setAttribute("origin", aProvider.origin);
|
||||
node.setAttribute("oncommand", "this.markCurrentPage();");
|
||||
|
||||
let window = aDocument.defaultView;
|
||||
let menuLabel = window.gNavigatorBundle.getFormattedString("social.markpageMenu.label", [aProvider.name]);
|
||||
|
@ -199,6 +199,14 @@ a {
|
||||
border-color: #777;
|
||||
}
|
||||
|
||||
.theme-light .message:hover {
|
||||
background-color: rgba(76, 158, 217, 0.23) !important;
|
||||
}
|
||||
|
||||
.theme-dark .message:hover {
|
||||
background-color: rgba(29, 79, 115, 0.5) !important;
|
||||
}
|
||||
|
||||
.theme-light .message[severity=error] {
|
||||
background-color: rgba(255, 150, 150, 0.3);
|
||||
}
|
||||
|
14
configure.in
14
configure.in
@ -3903,7 +3903,6 @@ MOZ_SAFE_BROWSING=
|
||||
MOZ_HELP_VIEWER=
|
||||
MOZ_SPELLCHECK=1
|
||||
MOZ_ANDROID_OMTC=
|
||||
MOZ_NATIVE_CASTING=1
|
||||
MOZ_TOOLKIT_SEARCH=1
|
||||
MOZ_UI_LOCALE=en-US
|
||||
MOZ_UNIVERSALCHARDET=1
|
||||
@ -7682,19 +7681,6 @@ else
|
||||
OMNIJAR_NAME=omni.ja
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = --disable-native-casting
|
||||
dnl ========================================================
|
||||
|
||||
MOZ_ARG_DISABLE_BOOL(native-casting,
|
||||
[ --disable-native-casting Disable native casting devices],
|
||||
MOZ_NATIVE_CASTING=,
|
||||
MOZ_NATIVE_CASTING=1)
|
||||
if test "$MOZ_NATIVE_CASTING"; then
|
||||
AC_DEFINE(MOZ_NATIVE_CASTING)
|
||||
fi
|
||||
|
||||
AC_SUBST(MOZ_NATIVE_CASTING)
|
||||
AC_SUBST(OMNIJAR_NAME)
|
||||
AC_SUBST(MOZ_OMNIJAR)
|
||||
AC_SUBST(MOZ_PACKAGER_FORMAT)
|
||||
|
@ -1515,6 +1515,25 @@ Navigator::GetFeature(const nsAString& aName)
|
||||
return p.forget();
|
||||
} // hardware.memory
|
||||
#endif
|
||||
|
||||
// Hardcoded manifest features. Some are still b2g specific.
|
||||
const char manifestFeatures[][64] = {
|
||||
"manifest.origin"
|
||||
, "manifest.redirects"
|
||||
#ifdef MOZ_B2G
|
||||
, "manifest.chrome.navigation"
|
||||
, "manifest.precompile"
|
||||
#endif
|
||||
};
|
||||
|
||||
nsAutoCString feature = NS_ConvertUTF16toUTF8(aName);
|
||||
for (uint32_t i = 0; i < MOZ_ARRAY_LENGTH(manifestFeatures); i++) {
|
||||
if (feature.Equals(manifestFeatures[i])) {
|
||||
p->MaybeResolve(true);
|
||||
return p.forget();
|
||||
}
|
||||
}
|
||||
|
||||
// resolve with <undefined> because the feature name is not supported
|
||||
p->MaybeResolve(JS::UndefinedHandleValue);
|
||||
|
||||
|
@ -38,7 +38,7 @@ function testSupported() {
|
||||
ok(typeof mem === 'undefined', "hardware.memory is not support on this platform");
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
runNextTest();
|
||||
|
||||
},function(mem) {
|
||||
ok(false, "The Promise should not be rejected");
|
||||
@ -49,17 +49,56 @@ function testNotSupported() {
|
||||
var tv;
|
||||
navigator.getFeature("hardware.tv").then(function(tv) {
|
||||
ok(typeof tv === 'undefined', "Resolve the Promise with undefined value (hardware.tv)");
|
||||
testSupported();
|
||||
runNextTest();
|
||||
},function(tv) {
|
||||
ok(false, "The Promise should not be rejected")
|
||||
});
|
||||
}
|
||||
|
||||
function createManifestTest(aFeature) {
|
||||
return function() {
|
||||
var res;
|
||||
navigator.getFeature(aFeature).then(function(res) {
|
||||
ok(res === true, "Resolve the Promise with 'true' for " + aFeature);
|
||||
runNextTest();
|
||||
},function(tv) {
|
||||
ok(false, "The Promise should not be rejected")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var currentTest = -1;
|
||||
var tests = [
|
||||
testNotSupported,
|
||||
testSupported,
|
||||
createManifestTest("manifest.origin"),
|
||||
createManifestTest("manifest.redirects")
|
||||
];
|
||||
|
||||
function runNextTest() {
|
||||
currentTest++;
|
||||
if (currentTest < tests.length) {
|
||||
tests[currentTest]();
|
||||
} else {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
info("About to run " + tests.length + " tests");
|
||||
|
||||
SpecialPowers.pushPermissions([
|
||||
{type: "feature-detection", allow: 1, context: document}
|
||||
], function() {
|
||||
ok('getFeature' in navigator, "navigator.getFeature should exist");
|
||||
testNotSupported();
|
||||
// B2G specific manifest features.
|
||||
// Touching navigator before pushPermissions makes it fail.
|
||||
if (!navigator.userAgent.contains("Android") &&
|
||||
/Mobile|Tablet/.test(navigator.userAgent)) {
|
||||
info("Adding B2G specific tests");
|
||||
tests.push(createManifestTest("manifest.chrome.navigation"));
|
||||
tests.push(createManifestTest("manifest.precompile"));
|
||||
}
|
||||
runNextTest();
|
||||
ok(true, "Test DONE");
|
||||
});
|
||||
|
||||
|
@ -173,6 +173,10 @@ DOMInterfaces = {
|
||||
'nativeType': 'mozilla::dom::bluetooth::BluetoothDiscoveryHandle',
|
||||
},
|
||||
|
||||
'BluetoothClassOfDevice': {
|
||||
'nativeType': 'mozilla::dom::bluetooth::BluetoothClassOfDevice',
|
||||
},
|
||||
|
||||
'CameraCapabilities': {
|
||||
'nativeType': 'mozilla::dom::CameraCapabilities',
|
||||
'headerFile': 'DOMCameraCapabilities.h'
|
||||
|
105
dom/bluetooth2/BluetoothClassOfDevice.cpp
Normal file
105
dom/bluetooth2/BluetoothClassOfDevice.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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/. */
|
||||
|
||||
#include "BluetoothClassOfDevice.h"
|
||||
|
||||
#include "mozilla/dom/BluetoothClassOfDeviceBinding.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(BluetoothClassOfDevice, mOwnerWindow)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(BluetoothClassOfDevice)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(BluetoothClassOfDevice)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BluetoothClassOfDevice)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
/*
|
||||
* Class of Device(CoD): 32-bit unsigned integer
|
||||
*
|
||||
* 31 24 23 13 12 8 7 2 1 0
|
||||
* | | Major | Major | Minor | |
|
||||
* | | service | device | device | |
|
||||
* | | class | class | class | |
|
||||
* | |<- 11 ->|<- 5 ->|<- 6 ->| |
|
||||
*
|
||||
* https://www.bluetooth.org/en-us/specification/assigned-numbers/baseband
|
||||
*/
|
||||
|
||||
// Bit 23 ~ Bit 13: Major service class
|
||||
#define GET_MAJOR_SERVICE_CLASS(cod) (((cod) & 0xffe000) >> 13)
|
||||
|
||||
// Bit 12 ~ Bit 8: Major device class
|
||||
#define GET_MAJOR_DEVICE_CLASS(cod) (((cod) & 0x1f00) >> 8)
|
||||
|
||||
// Bit 7 ~ Bit 2: Minor device class
|
||||
#define GET_MINOR_DEVICE_CLASS(cod) (((cod) & 0xfc) >> 2)
|
||||
|
||||
BluetoothClassOfDevice::BluetoothClassOfDevice(nsPIDOMWindow* aOwner)
|
||||
: mOwnerWindow(aOwner)
|
||||
{
|
||||
MOZ_ASSERT(aOwner);
|
||||
SetIsDOMBinding();
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
BluetoothClassOfDevice::~BluetoothClassOfDevice()
|
||||
{}
|
||||
|
||||
void
|
||||
BluetoothClassOfDevice::Reset()
|
||||
{
|
||||
mMajorServiceClass = 0x1; // LIMITED_DISCOVERABILITY
|
||||
mMajorDeviceClass = 0x1F; // UNCATEGORIZED
|
||||
mMinorDeviceClass = 0;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothClassOfDevice::Equals(const uint32_t aValue)
|
||||
{
|
||||
return (mMajorServiceClass == GET_MAJOR_SERVICE_CLASS(aValue) &&
|
||||
mMajorDeviceClass == GET_MAJOR_DEVICE_CLASS(aValue) &&
|
||||
mMinorDeviceClass == GET_MINOR_DEVICE_CLASS(aValue));
|
||||
}
|
||||
|
||||
uint32_t
|
||||
BluetoothClassOfDevice::ToUint32()
|
||||
{
|
||||
return (mMajorServiceClass & 0x7ff) << 13 |
|
||||
(mMajorDeviceClass & 0x1f) << 8 |
|
||||
(mMinorDeviceClass & 0x3f) << 2;
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothClassOfDevice::Update(const uint32_t aValue)
|
||||
{
|
||||
mMajorServiceClass = GET_MAJOR_SERVICE_CLASS(aValue);
|
||||
mMajorDeviceClass = GET_MAJOR_DEVICE_CLASS(aValue);
|
||||
mMinorDeviceClass = GET_MINOR_DEVICE_CLASS(aValue);
|
||||
|
||||
BT_API2_LOGR("aValue %x => majorService %x majorDevice %x minorDevice %x",
|
||||
aValue, mMajorServiceClass, mMajorDeviceClass, mMinorDeviceClass);
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<BluetoothClassOfDevice>
|
||||
BluetoothClassOfDevice::Create(nsPIDOMWindow* aOwner)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aOwner);
|
||||
|
||||
nsRefPtr<BluetoothClassOfDevice> cod = new BluetoothClassOfDevice(aOwner);
|
||||
return cod.forget();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
BluetoothClassOfDevice::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return BluetoothClassOfDeviceBinding::Wrap(aCx, this);
|
||||
}
|
92
dom/bluetooth2/BluetoothClassOfDevice.h
Normal file
92
dom/bluetooth2/BluetoothClassOfDevice.h
Normal file
@ -0,0 +1,92 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_bluetooth_bluetoothclassofdevice_h
|
||||
#define mozilla_dom_bluetooth_bluetoothclassofdevice_h
|
||||
|
||||
#include "BluetoothCommon.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
struct JSContext;
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothClassOfDevice MOZ_FINAL : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BluetoothClassOfDevice)
|
||||
|
||||
static already_AddRefed<BluetoothClassOfDevice>
|
||||
Create(nsPIDOMWindow* aOwner);
|
||||
|
||||
uint16_t MajorServiceClass() const
|
||||
{
|
||||
return mMajorServiceClass;
|
||||
}
|
||||
|
||||
uint8_t MajorDeviceClass() const
|
||||
{
|
||||
return mMajorDeviceClass;
|
||||
}
|
||||
|
||||
uint8_t MinorDeviceClass() const
|
||||
{
|
||||
return mMinorDeviceClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare whether CoD equals to CoD value.
|
||||
*
|
||||
* @param aValue [in] CoD value to compare
|
||||
*/
|
||||
bool Equals(const uint32_t aValue);
|
||||
|
||||
/**
|
||||
* Convert CoD to uint32_t CoD value.
|
||||
*
|
||||
* TODO: Remove this function once we replace uint32_t cod value with
|
||||
* BluetoothClassOfDevice in BluetoothProfileController.
|
||||
*/
|
||||
uint32_t ToUint32();
|
||||
|
||||
/**
|
||||
* Update CoD.
|
||||
*
|
||||
* @param aValue [in] CoD value to update
|
||||
*/
|
||||
void Update(const uint32_t aValue);
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return mOwnerWindow;
|
||||
}
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
BluetoothClassOfDevice(nsPIDOMWindow* aOwner);
|
||||
~BluetoothClassOfDevice();
|
||||
|
||||
/**
|
||||
* Reset CoD to default value.
|
||||
*/
|
||||
void Reset();
|
||||
|
||||
uint16_t mMajorServiceClass;
|
||||
uint8_t mMajorDeviceClass;
|
||||
uint8_t mMinorDeviceClass;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> mOwnerWindow;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
||||
#endif // mozilla_dom_bluetooth_bluetoothclassofdevice_h
|
@ -27,19 +27,19 @@ BEGIN_BLUETOOTH_NAMESPACE
|
||||
*/
|
||||
|
||||
// Bit 23 ~ Bit 13: Major service class
|
||||
#define GET_MAJOR_SERVICE_CLASS(cod) ((cod & 0xffe000) >> 13)
|
||||
#define GET_MAJOR_SERVICE_CLASS(cod) (((cod) & 0xffe000) >> 13)
|
||||
|
||||
// Bit 12 ~ Bit 8: Major device class
|
||||
#define GET_MAJOR_DEVICE_CLASS(cod) ((cod & 0x1f00) >> 8)
|
||||
#define GET_MAJOR_DEVICE_CLASS(cod) (((cod) & 0x1f00) >> 8)
|
||||
|
||||
// Bit 7 ~ Bit 2: Minor device class
|
||||
#define GET_MINOR_DEVICE_CLASS(cod) ((cod & 0xfc) >> 2)
|
||||
#define GET_MINOR_DEVICE_CLASS(cod) (((cod) & 0xfc) >> 2)
|
||||
|
||||
// Audio: Major service class = 0x100 (Bit 21 is set)
|
||||
#define HAS_AUDIO(cod) (cod & 0x200000)
|
||||
#define HAS_AUDIO(cod) ((cod) & 0x200000)
|
||||
|
||||
// Rendering: Major service class = 0x20 (Bit 18 is set)
|
||||
#define HAS_RENDERING(cod) (cod & 0x40000)
|
||||
#define HAS_RENDERING(cod) ((cod) & 0x40000)
|
||||
|
||||
// Peripheral: Major device class = 0x5
|
||||
#define IS_PERIPHERAL(cod) (GET_MAJOR_DEVICE_CLASS(cod) == 0x5)
|
||||
|
@ -7,6 +7,7 @@
|
||||
if CONFIG['MOZ_B2G_BT']:
|
||||
SOURCES += [
|
||||
'BluetoothAdapter.cpp',
|
||||
'BluetoothClassOfDevice.cpp',
|
||||
'BluetoothDevice.cpp',
|
||||
'BluetoothDiscoveryHandle.cpp',
|
||||
'BluetoothHidManager.cpp',
|
||||
@ -93,6 +94,7 @@ EXPORTS.mozilla.dom.bluetooth.ipc += [
|
||||
|
||||
EXPORTS.mozilla.dom.bluetooth += [
|
||||
'BluetoothAdapter.h',
|
||||
'BluetoothClassOfDevice.h',
|
||||
'BluetoothCommon.h',
|
||||
'BluetoothDevice.h',
|
||||
'BluetoothDiscoveryHandle.h',
|
||||
|
@ -18,7 +18,6 @@ XPIDL_SOURCES += [
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMNetworkStatsManager.idl',
|
||||
'nsIEthernetManager.idl',
|
||||
'nsINetworkStatsServiceProxy.idl',
|
||||
]
|
||||
|
||||
|
@ -1,137 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, function, uuid(2a3ad56c-edc0-439f-8aae-900b331ddf49)]
|
||||
interface nsIEthernetManagerCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
* Callback function used to report the success of different operations.
|
||||
*
|
||||
* @param success
|
||||
* Boolean value indicates the success of an operation.
|
||||
* @prarm message
|
||||
* Message reported in the end of operation.
|
||||
*/
|
||||
void notify(in boolean success, in DOMString message);
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(1746e7dd-92d4-43fa-8ef4-bc13d0b60353)]
|
||||
interface nsIEthernetManagerScanCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
* Callback function used to report the result of scan function.
|
||||
*
|
||||
* @param list
|
||||
* List of available ethernet interfaces.
|
||||
*/
|
||||
void notify(in jsval list);
|
||||
};
|
||||
|
||||
/**
|
||||
* An internal idl provides control to ethernet interfaces.
|
||||
*/
|
||||
[scriptable, uuid(a96441dd-36b3-4f7f-963b-2c032e28a039)]
|
||||
interface nsIEthernetManager : nsISupports
|
||||
{
|
||||
/**
|
||||
* List of exisiting interface name.
|
||||
*/
|
||||
readonly attribute jsval interfaceList;
|
||||
|
||||
/**
|
||||
* Scan available ethernet interfaces on device.
|
||||
*
|
||||
* @param callback
|
||||
* Callback function.
|
||||
*/
|
||||
void scan(in nsIEthernetManagerScanCallback callback);
|
||||
|
||||
/**
|
||||
* Add a new interface to the interface list.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name. Should be the form of "eth*".
|
||||
* @param callback
|
||||
* Callback function.
|
||||
*/
|
||||
void addInterface(in DOMString ifname,
|
||||
in nsIEthernetManagerCallback callback);
|
||||
|
||||
/**
|
||||
* Remove an existing interface from the interface list.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
* @param Callback
|
||||
* Callback function.
|
||||
*/
|
||||
void removeInterface(in DOMString ifname,
|
||||
in nsIEthernetManagerCallback callback);
|
||||
|
||||
/**
|
||||
* Update a conifg of an existing interface in the interface list.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
* @param config
|
||||
* .ip: ip address.
|
||||
* .prefixLength: mask length.
|
||||
* .gateway: gateway.
|
||||
* .dnses: dnses.
|
||||
* .httpProxyHost: http proxy host.
|
||||
* .httpProxyPort: http porxy port.
|
||||
* .ipMode: ip mode, can be 'dhcp' or 'static'.
|
||||
* @param callback
|
||||
* Callback function.
|
||||
*/
|
||||
void updateInterfaceConfig(in DOMString ifname,
|
||||
in jsval config,
|
||||
in nsIEthernetManagerCallback callback);
|
||||
|
||||
/**
|
||||
* Enable networking of an existing interface in the interface list.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
* @param callback
|
||||
* Callback function.
|
||||
*/
|
||||
void enable(in DOMString ifname,
|
||||
in nsIEthernetManagerCallback callback);
|
||||
|
||||
/**
|
||||
* Disable networking of an existing interface in the interface list.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
* @param callback
|
||||
* Callback function.
|
||||
*/
|
||||
void disable(in DOMString ifname,
|
||||
in nsIEthernetManagerCallback callback);
|
||||
|
||||
/**
|
||||
* Make an existing interface connect to network.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
* @param callback
|
||||
* Callback function.
|
||||
*/
|
||||
void connect(in DOMString ifname,
|
||||
in nsIEthernetManagerCallback callback);
|
||||
|
||||
/**
|
||||
* Disconnect a connected interface in the interface list.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
* @param callback
|
||||
* Callback function.
|
||||
*/
|
||||
void disconnect(in DOMString ifname,
|
||||
in nsIEthernetManagerCallback callback);
|
||||
};
|
@ -1,619 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* 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 DEBUG = false;
|
||||
function debug(s) {
|
||||
if (DEBUG) {
|
||||
dump("-*- EthernetManager: " + s + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
const TOPIC_INTERFACE_STATE_CHANGED = "network-interface-state-changed";
|
||||
|
||||
const ETHERNET_NETWORK_IFACE_PREFIX = "eth";
|
||||
const DEFAULT_ETHERNET_NETWORK_IFACE = "eth0";
|
||||
|
||||
const INTERFACE_IPADDR_NULL = "0.0.0.0";
|
||||
const INTERFACE_GATEWAY_NULL = "0.0.0.0";
|
||||
const INTERFACE_PREFIX_NULL = 0;
|
||||
const INTERFACE_MACADDR_NULL = "00:00:00:00:00:00";
|
||||
|
||||
const NETWORK_INTERFACE_UP = "up";
|
||||
const NETWORK_INTERFACE_DOWN = "down";
|
||||
|
||||
const IP_MODE_DHCP = "dhcp";
|
||||
const IP_MODE_STATIC = "static";
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gNetworkManager",
|
||||
"@mozilla.org/network/manager;1",
|
||||
"nsINetworkManager");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gNetworkService",
|
||||
"@mozilla.org/network/service;1",
|
||||
"nsINetworkService");
|
||||
|
||||
|
||||
// nsINetworkInterface
|
||||
|
||||
function EthernetInterface(attr) {
|
||||
this.state = attr.state;
|
||||
this.type = attr.type;
|
||||
this.name = attr.name;
|
||||
this.ipMode = attr.ipMode;
|
||||
this.ips = [attr.ip];
|
||||
this.prefixLengths = [attr.prefixLength];
|
||||
this.gateways = [attr.gateway];
|
||||
this.dnses = attr.dnses;
|
||||
this.httpProxyHost = "";
|
||||
this.httpProxyPort = 0;
|
||||
}
|
||||
EthernetInterface.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInterface]),
|
||||
|
||||
updateConfig: function(config) {
|
||||
debug("Interface " + this.name + " updateConfig " + JSON.stringify(config));
|
||||
this.state = (config.state != undefined) ?
|
||||
config.state : this.state;
|
||||
this.ips = (config.ip != undefined) ? [config.ip] : this.ips;
|
||||
this.prefixLengths = (config.prefixLength != undefined) ?
|
||||
[config.prefixLength] : this.prefixLengths;
|
||||
this.gateways = (config.gateway != undefined) ?
|
||||
[config.gateway] : this.gateways;
|
||||
this.dnses = (config.dnses != undefined) ? config.dnses : this.dnses;
|
||||
this.httpProxyHost = (config.httpProxyHost != undefined) ?
|
||||
config.httpProxyHost : this.httpProxyHost;
|
||||
this.httpProxyPort = (config.httpProxyPort != undefined) ?
|
||||
config.httpProxyPort : this.httpProxyPort;
|
||||
this.ipMode = (config.ipMode != undefined) ?
|
||||
config.ipMode : this.ipMode;
|
||||
},
|
||||
|
||||
getAddresses: function(ips, prefixLengths) {
|
||||
ips.value = this.ips.slice();
|
||||
prefixLengths.value = this.prefixLengths.slice();
|
||||
|
||||
return this.ips.length;
|
||||
},
|
||||
|
||||
getGateways: function(count) {
|
||||
if (count) {
|
||||
count.value = this.gateways.length;
|
||||
}
|
||||
return this.gateways.slice();
|
||||
},
|
||||
|
||||
getDnses: function(count) {
|
||||
if (count) {
|
||||
count.value = this.dnses.length;
|
||||
}
|
||||
return this.dnses.slice();
|
||||
}
|
||||
};
|
||||
|
||||
// nsIEthernetManager
|
||||
|
||||
/*
|
||||
* Network state transition diagram
|
||||
*
|
||||
* ---------- enable --------- connect ----------- disconnect --------------
|
||||
* | Disabled | -----> | Enabled | -------> | Connected | <----------> | Disconnected |
|
||||
* ---------- --------- ----------- connect --------------
|
||||
* ^ | | |
|
||||
* | disable | | |
|
||||
* -----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
function EthernetManager() {
|
||||
debug("EthernetManager start");
|
||||
|
||||
// Interface list.
|
||||
this.ethernetInterfaces = {};
|
||||
|
||||
// Used to memorize last connection information.
|
||||
this.lastStaticConfig = {};
|
||||
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
}
|
||||
|
||||
EthernetManager.prototype = {
|
||||
classID: Components.ID("a96441dd-36b3-4f7f-963b-2c032e28a039"),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIEthernetManager]),
|
||||
|
||||
ethernetInterfaces: null,
|
||||
lastStaticConfig: null,
|
||||
|
||||
observer: function(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "xpcom-shutdown":
|
||||
debug("xpcom-shutdown");
|
||||
|
||||
this._shutdown();
|
||||
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_shutdown: function() {
|
||||
debug("shuting down.");
|
||||
(function onRemove(ifnameList) {
|
||||
if (!ifnameList.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
let ifname = ifnameList.shift();
|
||||
this.removeInterface(ifname, { notify: onRemove.bind(this, ifnameList) });
|
||||
}).call(this, Object.keys(this.ethernetInterfaces));
|
||||
},
|
||||
|
||||
get interfaceList() {
|
||||
return Object.keys(this.ethernetInterfaces);
|
||||
},
|
||||
|
||||
scan: function(callback) {
|
||||
debug("scan");
|
||||
|
||||
gNetworkService.getInterfaces(function(success, list) {
|
||||
let ethList = [];
|
||||
|
||||
if (!success) {
|
||||
if (callback) {
|
||||
callback.notify(ethList);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
debug("Found interface " + list[i]);
|
||||
if (!list[i].startsWith(ETHERNET_NETWORK_IFACE_PREFIX)) {
|
||||
continue;
|
||||
}
|
||||
ethList.push(list[i]);
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback.notify(ethList);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
addInterface: function(ifname, callback) {
|
||||
debug("addInterfaces " + ifname);
|
||||
|
||||
if (!ifname || !ifname.startsWith(ETHERNET_NETWORK_IFACE_PREFIX)) {
|
||||
if (callback) {
|
||||
callback.notify(false, "Invalid interface.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.ethernetInterfaces[ifname]) {
|
||||
if (callback) {
|
||||
callback.notify(true, "Interface already exists.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
gNetworkService.getInterfaceConfig(ifname, function(success, result) {
|
||||
if (!success) {
|
||||
if (callback) {
|
||||
callback.notify(false, "Netd error.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Since the operation may still succeed with an invalid interface name,
|
||||
// check the mac address as well.
|
||||
if (result.macAddr == INTERFACE_MACADDR_NULL) {
|
||||
if (callback) {
|
||||
callback.notify(false, "Interface not found.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.ethernetInterfaces[ifname] = new EthernetInterface({
|
||||
state: result.link == NETWORK_INTERFACE_UP ?
|
||||
Ci.nsINetworkInterface.NETWORK_STATE_DISABLED :
|
||||
Ci.nsINetworkInterface.NETWORK_STATE_ENABLED,
|
||||
name: ifname,
|
||||
type: Ci.nsINetworkInterface.NETWORK_TYPE_ETHERNET,
|
||||
ip: result.ip,
|
||||
prefixLength: result.prefix,
|
||||
ipMode: IP_MODE_DHCP
|
||||
});
|
||||
|
||||
// Register the interface to NetworkManager.
|
||||
gNetworkManager.registerNetworkInterface(this.ethernetInterfaces[ifname]);
|
||||
|
||||
debug("Add interface " + ifname + " success with " +
|
||||
JSON.stringify(this.ethernetInterfaces[ifname]));
|
||||
|
||||
if (callback) {
|
||||
callback.notify(true, "ok");
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
removeInterface: function(ifname, callback) {
|
||||
debug("removeInterface");
|
||||
|
||||
if (!ifname || !ifname.startsWith(ETHERNET_NETWORK_IFACE_PREFIX)) {
|
||||
if (callback) {
|
||||
callback.notify(false, "Invalid interface.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.ethernetInterfaces[ifname]) {
|
||||
if (callback) {
|
||||
callback.notify(true, "Interface does not exist.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure interface is disable before removing.
|
||||
this.disable(ifname, { notify: function(success, message) {
|
||||
// Unregister the interface from NetworkManager and also remove it from
|
||||
// the interface list.
|
||||
gNetworkManager.unregisterNetworkInterface(this.ethernetInterfaces[ifname]);
|
||||
delete this.ethernetInterfaces[ifname];
|
||||
|
||||
debug("Remove interface " + ifname + " success.");
|
||||
|
||||
if (callback) {
|
||||
callback.notify(true, "ok");
|
||||
}
|
||||
}.bind(this)});
|
||||
},
|
||||
|
||||
updateInterfaceConfig: function(ifname, config, callback) {
|
||||
debug("interfaceConfigUpdate with " + ifname);
|
||||
|
||||
this._ensureIfname(ifname, callback, function(iface) {
|
||||
if (!config) {
|
||||
if (callback) {
|
||||
callback.notify(false, "No config to update.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Network state can not be modified externally.
|
||||
if (config.state) {
|
||||
delete config.state;
|
||||
}
|
||||
|
||||
let currentIpMode = iface.ipMode;
|
||||
|
||||
// Update config.
|
||||
this.ethernetInterfaces[iface.name].updateConfig(config);
|
||||
|
||||
// Do not automatically re-connect if the interface is not in connected
|
||||
// state.
|
||||
if (iface.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
|
||||
if (callback) {
|
||||
callback.notify(true, "ok");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let newIpMode = this.ethernetInterfaces[iface.name].ipMode;
|
||||
if (newIpMode == IP_MODE_STATIC) {
|
||||
this._setStaticIP(iface.name, callback);
|
||||
return;
|
||||
}
|
||||
if ((currentIpMode == IP_MODE_STATIC) && (newIpMode == IP_MODE_DHCP)) {
|
||||
gNetworkService.stopDhcp(iface.name);
|
||||
// Clear the current network settings before do dhcp request, otherwise
|
||||
// dhcp settings could fail.
|
||||
this.disconnect(iface.name, { notify: function(success, message) {
|
||||
if (!success) {
|
||||
if (callback) {
|
||||
callback.notify("Disconnect failed.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
this._runDhcp(iface.name, callback);
|
||||
}.bind(this) });
|
||||
return;
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback.notify(true, "ok");
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
enable: function(ifname, callback) {
|
||||
debug("enable with " + ifname);
|
||||
|
||||
this._ensureIfname(ifname, callback, function(iface) {
|
||||
// Interface can be only enabled in the state of disabled.
|
||||
if (iface.state != Ci.nsINetworkInterface.NETWORK_STATE_DISABLED) {
|
||||
if (callback) {
|
||||
callback.notify(true, "already enabled.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let ips = {};
|
||||
let prefixLengths = {};
|
||||
iface.getAddresses(ips, prefixLengths);
|
||||
let config = { ifname: iface.name,
|
||||
ip: ips.value[0],
|
||||
prefix: prefixLengths.value[0],
|
||||
link: NETWORK_INTERFACE_UP };
|
||||
gNetworkService.setInterfaceConfig(config, function(success) {
|
||||
if (!success) {
|
||||
if (callback) {
|
||||
callback.notify(false, "Netd Error.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.ethernetInterfaces[iface.name].updateConfig({
|
||||
state: Ci.nsINetworkInterface.NETWORK_STATE_ENABLED
|
||||
});
|
||||
|
||||
debug("Interface " + iface.name + " enable success.");
|
||||
|
||||
if (callback) {
|
||||
callback.notify(true, "ok");
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
disable: function(ifname, callback) {
|
||||
debug("disable with " + ifname);
|
||||
|
||||
this._ensureIfname(ifname, callback, function(iface) {
|
||||
if (iface.state == Ci.nsINetworkInterface.NETWORK_STATE_DISABLED) {
|
||||
if (callback) {
|
||||
callback.notify(true, "Interface is already disabled.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (iface.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
|
||||
gNetworkService.stopDhcp(iface.name);
|
||||
}
|
||||
|
||||
let ips = {};
|
||||
let prefixLengths = {};
|
||||
iface.getAddresses(ips, prefixLengths);
|
||||
let config = { ifname: iface.name,
|
||||
ip: ips.value[0],
|
||||
prefix: prefixLengths.value[0],
|
||||
link: NETWORK_INTERFACE_DOWN };
|
||||
gNetworkService.setInterfaceConfig(config, function(success) {
|
||||
if (!success) {
|
||||
if (callback) {
|
||||
callback.notify(false, "Netd Error.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.ethernetInterfaces[iface.name].updateConfig({
|
||||
state: Ci.nsINetworkInterface.NETWORK_STATE_DISABLED
|
||||
});
|
||||
|
||||
debug("Disable interface " + iface.name + " success.");
|
||||
|
||||
if (callback) {
|
||||
callback.notify(true, "ok");
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
connect: function(ifname, callback) {
|
||||
debug("connect wtih " + ifname);
|
||||
|
||||
this._ensureIfname(ifname, callback, function(iface) {
|
||||
// Interface can only be connected in the state of enabled or
|
||||
// disconnected.
|
||||
if (iface.state == Ci.nsINetworkInterface.NETWORK_STATE_DISABLED ||
|
||||
iface.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
|
||||
if (callback) {
|
||||
callback.notify(true, "Interface " + ifname + " is not available or "
|
||||
+ " already connected.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (iface.ipMode == IP_MODE_DHCP) {
|
||||
this._runDhcp(iface.name, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
if (iface.ipMode == IP_MODE_STATIC) {
|
||||
if (this._checkConfigNull(iface) && this.lastStaticConfig[iface.name]) {
|
||||
debug("connect with lastStaticConfig " +
|
||||
JSON.stringify(this.lastStaticConfig[iface.name]));
|
||||
this.ethernetInterfaces[iface.name].updateConfig(
|
||||
this.lastStaticConfig[iface.name]);
|
||||
}
|
||||
this._setStaticIP(iface.name, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback.notify(false, "Ip mode is wrong or not set.");
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
disconnect: function(ifname, callback) {
|
||||
debug("disconnect");
|
||||
|
||||
this._ensureIfname(ifname, callback, function(iface) {
|
||||
// Interface can be only disconnected in the state of connected.
|
||||
if (iface.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
|
||||
if (callback) {
|
||||
callback.notify(true, "interface is already disconnected");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let config = { ifname: iface.name,
|
||||
ip: INTERFACE_IPADDR_NULL,
|
||||
prefix: INTERFACE_PREFIX_NULL,
|
||||
link: NETWORK_INTERFACE_UP };
|
||||
gNetworkService.setInterfaceConfig(config, function(success) {
|
||||
if (!success) {
|
||||
if (callback) {
|
||||
callback.notify(false, "Netd error.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop dhcp daemon.
|
||||
gNetworkService.stopDhcp(iface.name);
|
||||
|
||||
this.ethernetInterfaces[iface.name].updateConfig({
|
||||
state: Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED,
|
||||
ip: INTERFACE_IPADDR_NULL,
|
||||
prefixLength: INTERFACE_PREFIX_NULL,
|
||||
gateway: INTERFACE_GATEWAY_NULL
|
||||
});
|
||||
|
||||
Services.obs.notifyObservers(this.ethernetInterfaces[iface.name],
|
||||
TOPIC_INTERFACE_STATE_CHANGED,
|
||||
null);
|
||||
|
||||
debug("Disconnect interface " + iface.name + " success.");
|
||||
|
||||
if (callback) {
|
||||
callback.notify(true, "ok");
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_checkConfigNull: function(iface) {
|
||||
let ips = {};
|
||||
let prefixLengths = {};
|
||||
let gateways = iface.getGateways();
|
||||
iface.getAddresses(ips, prefixLengths);
|
||||
|
||||
if (ips.value[0] == INTERFACE_IPADDR_NULL &&
|
||||
prefixLengths.value[0] == INTERFACE_PREFIX_NULL &&
|
||||
gateways[0] == INTERFACE_GATEWAY_NULL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
_ensureIfname: function(ifname, callback, func) {
|
||||
// If no given ifname, use the default one.
|
||||
if (!ifname) {
|
||||
ifname = DEFAULT_ETHERNET_NETWORK_IFACE;
|
||||
}
|
||||
|
||||
let iface = this.ethernetInterfaces[ifname];
|
||||
if (!iface) {
|
||||
if (callback) {
|
||||
callback.notify(true, "Interface " + ifname + " is not available.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
func.call(this, iface);
|
||||
},
|
||||
|
||||
_runDhcp: function(ifname, callback) {
|
||||
debug("runDhcp with " + ifname);
|
||||
|
||||
if (!this.ethernetInterfaces[ifname]) {
|
||||
callback.notify(false, "Invalid interface.");
|
||||
return
|
||||
}
|
||||
|
||||
gNetworkService.runDhcp(ifname, function(success, result) {
|
||||
if (!success) {
|
||||
callback.notify(false, "Dhcp failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
debug("Dhcp success with " + JSON.stringify(result));
|
||||
|
||||
// Clear last static network information when connecting with dhcp mode.
|
||||
if (this.lastStaticConfig[ifname]) {
|
||||
this.lastStaticConfig[ifname] = null;
|
||||
}
|
||||
|
||||
this.ethernetInterfaces[ifname].updateConfig({
|
||||
state: Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED,
|
||||
ip: result.ip,
|
||||
gateway: result.gateway,
|
||||
prefixLength: result.prefix,
|
||||
dnses: [result.dns1, result.dns2]
|
||||
});
|
||||
|
||||
Services.obs.notifyObservers(this.ethernetInterfaces[ifname],
|
||||
TOPIC_INTERFACE_STATE_CHANGED,
|
||||
null);
|
||||
|
||||
debug("Connect interface " + ifname + "with dhcp success.");
|
||||
|
||||
callback.notify(true, "ok");
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_setStaticIP: function(ifname, callback) {
|
||||
let iface = this.ethernetInterfaces[ifname];
|
||||
if (!iface) {
|
||||
callback.notify(false, "Invalid interface.");
|
||||
return;
|
||||
}
|
||||
|
||||
let ips = {};
|
||||
let prefixLengths = {};
|
||||
iface.getAddresses(ips, prefixLengths);
|
||||
|
||||
let config = { ifname: iface.name,
|
||||
ip: ips.value[0],
|
||||
prefix: prefixLengths.value[0],
|
||||
link: NETWORK_INTERFACE_UP };
|
||||
gNetworkService.setInterfaceConfig(config, function(success) {
|
||||
if (!success) {
|
||||
callback.notify(false, "Netd Error.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Keep the lastest static network information.
|
||||
let ips = {};
|
||||
let prefixLengths = {};
|
||||
let gateways = iface.getGateways();
|
||||
iface.getAddresses(ips, prefixLengths);
|
||||
|
||||
this.lastStaticConfig[iface.name] = {
|
||||
ip: ips.value[0],
|
||||
prefixLength: prefixLengths.value[0],
|
||||
gateway: gateways[0]
|
||||
};
|
||||
|
||||
this.ethernetInterfaces[ifname].updateConfig({
|
||||
state: Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED,
|
||||
});
|
||||
|
||||
Services.obs.notifyObservers(this.ethernetInterfaces[ifname],
|
||||
TOPIC_INTERFACE_STATE_CHANGED,
|
||||
null);
|
||||
|
||||
debug("Connect interface " + ifname + "with static ip success.");
|
||||
|
||||
callback.notify(true, "ok");
|
||||
}.bind(this));
|
||||
},
|
||||
}
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([EthernetManager]);
|
@ -1,2 +0,0 @@
|
||||
component {a96441dd-36b3-4f7f-963b-2c032e28a039} EthernetManager.js
|
||||
contract @mozilla.org/ethernetManager;1 {a96441dd-36b3-4f7f-963b-2c032e28a039}
|
@ -44,8 +44,6 @@ EXTRA_PP_COMPONENTS += [
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
EXTRA_COMPONENTS += [
|
||||
'EthernetManager.js',
|
||||
'EthernetManager.manifest',
|
||||
'NetworkStatsManager.js',
|
||||
'NetworkStatsManager.manifest',
|
||||
'NetworkStatsServiceProxy.js',
|
||||
|
@ -1,551 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
let Promise = SpecialPowers.Cu.import("resource://gre/modules/Promise.jsm").Promise;
|
||||
|
||||
const ETHERNET_MANAGER_CONTRACT_ID = "@mozilla.org/ethernetManager;1";
|
||||
|
||||
const INTERFACE_UP = "UP";
|
||||
const INTERFACE_DOWN = "DOWN";
|
||||
|
||||
let gTestSuite = (function() {
|
||||
let suite = {};
|
||||
|
||||
// Private member variables of the returned object |suite|.
|
||||
let ethernetManager = SpecialPowers.Cc[ETHERNET_MANAGER_CONTRACT_ID]
|
||||
.getService(SpecialPowers.Ci.nsIEthernetManager);
|
||||
let pendingEmulatorShellCount = 0;
|
||||
|
||||
/**
|
||||
* Send emulator shell command with safe guard.
|
||||
*
|
||||
* We should only call |finish()| after all emulator command transactions
|
||||
* end, so here comes with the pending counter. Resolve when the emulator
|
||||
* gives positive response, and reject otherwise.
|
||||
*
|
||||
* Fulfill params: an array of emulator response lines.
|
||||
* Reject params: an array of emulator response lines.
|
||||
*
|
||||
* @param command
|
||||
* A string command to be passed to emulator through its telnet console.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function runEmulatorShellSafe(command) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
++pendingEmulatorShellCount;
|
||||
runEmulatorShell(command, function(aResult) {
|
||||
--pendingEmulatorShellCount;
|
||||
|
||||
ok(true, "Emulator shell response: " + JSON.stringify(aResult));
|
||||
if (Array.isArray(aResult)) {
|
||||
deferred.resolve(aResult);
|
||||
} else {
|
||||
deferred.reject(aResult);
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the system network conifg by the given interface name.
|
||||
*
|
||||
* Use shell command 'netcfg' to get the list of network cofig.
|
||||
*
|
||||
* Fulfill params: An object of { name, flag, ip }
|
||||
*
|
||||
* @parm ifname
|
||||
* Interface name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function getNetworkConfig(ifname) {
|
||||
return runEmulatorShellSafe(['netcfg'])
|
||||
.then(result => {
|
||||
// Sample 'netcfg' output:
|
||||
//
|
||||
// lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00
|
||||
// eth0 UP 10.0.2.15/24 0x00001043 52:54:00:12:34:56
|
||||
// eth1 DOWN 0.0.0.0/0 0x00001002 52:54:00:12:34:57
|
||||
// rmnet1 DOWN 0.0.0.0/0 0x00001002 52:54:00:12:34:59
|
||||
|
||||
let config;
|
||||
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
let tokens = result[i].split(/\s+/);
|
||||
let name = tokens[0];
|
||||
let flag = tokens[1];
|
||||
let ip = tokens[2].split(/\/+/)[0];
|
||||
if (name == ifname) {
|
||||
config = { name: name, flag: flag, ip: ip };
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ip assigned by dhcp server of a given interface name.
|
||||
*
|
||||
* Get the ip from android property 'dhcp.[ifname].ipaddress'.
|
||||
*
|
||||
* Fulfill params: A string of ip address.
|
||||
*
|
||||
* @parm ifname
|
||||
* Interface name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function getDhcpIpAddr(ifname) {
|
||||
return runEmulatorShellSafe(['getprop', 'dhcp.' + ifname + '.ipaddress'])
|
||||
.then(function(ipAddr) {
|
||||
return ipAddr[0];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the gateway assigned by dhcp server of a given interface name.
|
||||
*
|
||||
* Get the ip from android property 'dhcp.[ifname].gateway'.
|
||||
*
|
||||
* Fulfill params: A string of gateway.
|
||||
*
|
||||
* @parm ifname
|
||||
* Interface name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function getDhcpGateway(ifname) {
|
||||
return runEmulatorShellSafe(['getprop', 'dhcp.' + ifname + '.gateway'])
|
||||
.then(function(gateway) {
|
||||
return gateway[0];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default route.
|
||||
*
|
||||
* Use shell command 'ip route' to get the default of device.
|
||||
*
|
||||
* Fulfill params: An array of { name, gateway }
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function getDefaultRoute() {
|
||||
return runEmulatorShellSafe(['ip', 'route'])
|
||||
.then(result => {
|
||||
// Sample 'ip route' output:
|
||||
//
|
||||
// 10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15
|
||||
// default via 10.0.2.2 dev eth0 metric 2
|
||||
|
||||
let routeInfo = [];
|
||||
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
if (!result[i].match('default')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let tokens = result[i].split(/\s+/);
|
||||
let name = tokens[4];
|
||||
let gateway = tokens[2];
|
||||
routeInfo.push({ name: name, gateway: gateway });
|
||||
}
|
||||
|
||||
return routeInfo;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a specific interface is enabled or not.
|
||||
*
|
||||
* @parm ifname
|
||||
* Interface name.
|
||||
* @parm enabled
|
||||
* A boolean value used to check interface is disable or not.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function checkInterfaceIsEnabled(ifname, enabled) {
|
||||
return getNetworkConfig(ifname)
|
||||
.then(function(config) {
|
||||
if (enabled) {
|
||||
is(config.flag, INTERFACE_UP, "Interface is enabled as expectation.");
|
||||
} else {
|
||||
is(config.flag, INTERFACE_DOWN, "Interface is disabled as expectation.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the ip of a specific interface is equal to given ip or not.
|
||||
*
|
||||
* @parm ifname
|
||||
* Interface name.
|
||||
* @parm ip
|
||||
* Given ip address.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function checkInterfaceIpAddr(ifname, ip) {
|
||||
return getNetworkConfig(ifname)
|
||||
.then(function(config) {
|
||||
is(config.ip, ip, "IP is right as expectation.");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the default gateway of a specific interface is equal to given gateway
|
||||
* or not.
|
||||
*
|
||||
* @parm ifname
|
||||
* Interface name.
|
||||
* @parm gateway
|
||||
* Given gateway.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function checkDefaultRoute(ifname, gateway) {
|
||||
return getDefaultRoute()
|
||||
.then(function(routeInfo) {
|
||||
for (let i = 0; i < routeInfo.length; i++) {
|
||||
if (routeInfo[i].name == ifname) {
|
||||
is(routeInfo[i].gateway, gateway,
|
||||
"Default gateway is right as expectation.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!gateway) {
|
||||
ok(true, "Default route is cleared.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the length of interface list in EthernetManager is equal to given
|
||||
* length or not.
|
||||
*
|
||||
* @parm length
|
||||
* Given length.
|
||||
*/
|
||||
function checkInterfaceListLength(length) {
|
||||
let list = ethernetManager.interfaceList;
|
||||
is(length, list.length, "List length is equal as expectation.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the given interface exists on device or not.
|
||||
*
|
||||
* @parm ifname
|
||||
* Interface name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function checkInterfaceExist(ifname) {
|
||||
return scanInterfaces()
|
||||
.then(list => {
|
||||
let index = list.indexOf(ifname);
|
||||
if (index < 0) {
|
||||
throw "Interface " + ifname + " not found.";
|
||||
}
|
||||
|
||||
ok(true, ifname + " exists.")
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan for available ethernet interfaces.
|
||||
*
|
||||
* Fulfill params: A list of available interfaces found in device.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function scanInterfaces() {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
ethernetManager.scan(function onScan(list) {
|
||||
deferred.resolve(list);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an interface into interface list.
|
||||
*
|
||||
* Fulfill params: A boolean value indicates success or not.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function addInterface(ifname) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
ethernetManager.addInterface(ifname, function onAdd(success, message) {
|
||||
ok(success, "Add interface " + ifname + " success.");
|
||||
is(message, "ok", "Message is as expectation.");
|
||||
|
||||
deferred.resolve(success);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an interface form the interface list.
|
||||
*
|
||||
* Fulfill params: A boolean value indicates success or not.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function removeInterface(ifname) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
ethernetManager.removeInterface(ifname, function onRemove(success, message) {
|
||||
ok(success, "Remove interface " + ifname + " success.");
|
||||
is(message, "ok", "Message is as expectation.");
|
||||
|
||||
deferred.resolve(success);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable networking of an interface in the interface list.
|
||||
*
|
||||
* Fulfill params: A boolean value indicates success or not.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function enableInterface(ifname) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
ethernetManager.enable(ifname, function onEnable(success, message) {
|
||||
ok(success, "Enable interface " + ifname + " success.");
|
||||
is(message, "ok", "Message is as expectation.");
|
||||
|
||||
deferred.resolve(success);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable networking of an interface in the interface list.
|
||||
*
|
||||
* Fulfill params: A boolean value indicates success or not.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function disableInterface(ifname) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
ethernetManager.disable(ifname, function onDisable(success, message) {
|
||||
ok(success, "Disable interface " + ifname + " success.");
|
||||
is(message, "ok", "Message is as expectation.");
|
||||
|
||||
deferred.resolve(success);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an interface connect to network.
|
||||
*
|
||||
* Fulfill params: A boolean value indicates success or not.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function makeInterfaceConnect(ifname) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
ethernetManager.connect(ifname, function onConnect(success, message) {
|
||||
ok(success, "Interface " + ifname + " is connected successfully.");
|
||||
is(message, "ok", "Message is as expectation.");
|
||||
|
||||
deferred.resolve(success);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an interface disconnect to network.
|
||||
*
|
||||
* Fulfill params: A boolean value indicates success or not.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function makeInterfaceDisconnect(ifname) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
ethernetManager.disconnect(ifname, function onDisconnect(success, message) {
|
||||
ok(success, "Interface " + ifname + " is disconnected successfully.");
|
||||
is(message, "ok", "Message is as expectation.");
|
||||
|
||||
deferred.resolve(success);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the config the an interface in the interface list.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
* @param config
|
||||
* .ip: ip address.
|
||||
* .prefixLength: mask length.
|
||||
* .gateway: gateway.
|
||||
* .dnses: dnses.
|
||||
* .httpProxyHost: http proxy host.
|
||||
* .httpProxyPort: http porxy port.
|
||||
* .usingDhcp: an boolean value indicates using dhcp or not.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function updateInterfaceConfig(ifname, config) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
ethernetManager.updateInterfaceConfig(ifname, config,
|
||||
function onUpdated(success, message) {
|
||||
ok(success, "Interface " + ifname + " config is updated successfully " +
|
||||
" with " + JSON.stringify(config));
|
||||
is(message, "ok", "Message is as expectation.");
|
||||
|
||||
deferred.resolve(success);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for timeout.
|
||||
*
|
||||
* @param timeout
|
||||
* Time in ms.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function waitForTimeout(timeout) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
setTimeout(function() {
|
||||
ok(true, "waitForTimeout " + timeout);
|
||||
deferred.resolve();
|
||||
}, timeout);
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for default route of a specific interface being set and
|
||||
* check.
|
||||
*
|
||||
* @param ifname
|
||||
* Interface name.
|
||||
* @param gateway
|
||||
* Target gateway.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function waitForDefaultRouteSet(ifname, gateway) {
|
||||
return gTestSuite.waitForTimeout(500)
|
||||
.then(() => gTestSuite.checkDefaultRoute(ifname, gateway))
|
||||
.then(success => {
|
||||
if (success) {
|
||||
ok(true, "Default route is set as expectation " + gateway);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(true, "Default route is not set yet, check again. " + success);
|
||||
return waitForDefaultRouteSet(ifname, gateway);
|
||||
});
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// Public test suite functions
|
||||
//---------------------------------------------------
|
||||
suite.scanInterfaces = scanInterfaces;
|
||||
suite.addInterface = addInterface;
|
||||
suite.removeInterface = removeInterface;
|
||||
suite.enableInterface = enableInterface;
|
||||
suite.disableInterface = disableInterface;
|
||||
suite.makeInterfaceConnect = makeInterfaceConnect;
|
||||
suite.makeInterfaceDisconnect = makeInterfaceDisconnect;
|
||||
suite.updateInterfaceConfig = updateInterfaceConfig;
|
||||
suite.getDhcpIpAddr = getDhcpIpAddr;
|
||||
suite.getDhcpGateway = getDhcpGateway;
|
||||
suite.checkInterfaceExist = checkInterfaceExist;
|
||||
suite.checkInterfaceIsEnabled = checkInterfaceIsEnabled;
|
||||
suite.checkInterfaceIpAddr = checkInterfaceIpAddr;
|
||||
suite.checkDefaultRoute = checkDefaultRoute;
|
||||
suite.checkInterfaceListLength = checkInterfaceListLength;
|
||||
suite.waitForTimeout = waitForTimeout;
|
||||
suite.waitForDefaultRouteSet = waitForDefaultRouteSet;
|
||||
|
||||
/**
|
||||
* End up the test run.
|
||||
*
|
||||
* Wait until all pending emulator shell commands are done and then |finish|
|
||||
* will be called in the end.
|
||||
*/
|
||||
function cleanUp() {
|
||||
waitFor(finish, function() {
|
||||
return pendingEmulatorShellCount === 0;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Common test routine.
|
||||
*
|
||||
* Start a test with the given test case chain. The test environment will be
|
||||
* settled down before the test. After the test, all the affected things will
|
||||
* be restored.
|
||||
*
|
||||
* @param aTestCaseChain
|
||||
* The test case entry point, which can be a function or a promise.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
suite.doTest = function(aTestCaseChain) {
|
||||
return Promise.resolve()
|
||||
.then(aTestCaseChain)
|
||||
.then(function onresolve() {
|
||||
cleanUp();
|
||||
}, function onreject(aReason) {
|
||||
ok(false, 'Promise rejects during test' + (aReason ? '(' + aReason + ')' : ''));
|
||||
cleanUp();
|
||||
});
|
||||
};
|
||||
|
||||
return suite;
|
||||
})();
|
@ -1,15 +0,0 @@
|
||||
[DEFAULT]
|
||||
b2g = true
|
||||
browser = false
|
||||
qemu = true
|
||||
|
||||
[test_ethernet_add_interface.js]
|
||||
[test_ethernet_remove_interface.js]
|
||||
[test_ethernet_enable.js]
|
||||
[test_ethernet_disable.js]
|
||||
[test_ethernet_connect_with_dhcp.js]
|
||||
[test_ethernet_connect_with_static_ip.js]
|
||||
[test_ethernet_reconnect_with_dhcp.js]
|
||||
[test_ethernet_reconnect_with_static_ip.js]
|
||||
[test_ethernet_ip_mode_change.js]
|
||||
[test_ethernet_disconnect.js]
|
@ -1,16 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const ETHERNET_INTERFACE_NAME = "eth1";
|
||||
|
||||
gTestSuite.doTest(function() {
|
||||
return Promise.resolve()
|
||||
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.checkInterfaceListLength(0))
|
||||
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.checkInterfaceListLength(1))
|
||||
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
|
||||
});
|
@ -1,26 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const ETHERNET_INTERFACE_NAME = "eth1";
|
||||
|
||||
function checkDhcpResult(ifname) {
|
||||
return gTestSuite.getDhcpIpAddr(ifname)
|
||||
.then(ip => gTestSuite.checkInterfaceIpAddr(ifname, ip))
|
||||
.then(() => gTestSuite.getDhcpGateway(ifname))
|
||||
.then(gateway => gTestSuite.waitForDefaultRouteSet(ifname, gateway));
|
||||
}
|
||||
|
||||
gTestSuite.doTest(function() {
|
||||
return Promise.resolve()
|
||||
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => checkDhcpResult(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
|
||||
});
|
@ -1,33 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const ETHERNET_INTERFACE_NAME = "eth1";
|
||||
|
||||
let staticConfig = {
|
||||
ip: "1.2.3.4",
|
||||
gateway: "1.2.3.5",
|
||||
prefixLength: 24,
|
||||
dnses: ["1.2.3.6"],
|
||||
ipMode: "static"
|
||||
};
|
||||
|
||||
function checkStaticResult(ifname) {
|
||||
return gTestSuite.checkInterfaceIpAddr(ifname, staticConfig.ip)
|
||||
.then(() => gTestSuite.checkDefaultRoute(ifname, staticConfig.gateway));
|
||||
}
|
||||
|
||||
gTestSuite.doTest(function() {
|
||||
return Promise.resolve()
|
||||
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.updateInterfaceConfig(ETHERNET_INTERFACE_NAME, staticConfig))
|
||||
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => checkStaticResult(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
|
||||
});
|
@ -1,17 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const ETHERNET_INTERFACE_NAME = "eth1";
|
||||
|
||||
gTestSuite.doTest(function() {
|
||||
return Promise.resolve()
|
||||
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.checkInterfaceIsEnabled(ETHERNET_INTERFACE_NAME, false))
|
||||
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
|
||||
});
|
@ -1,25 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const ETHERNET_INTERFACE_NAME = "eth1";
|
||||
const INTERFACE_IP_NONE = "0.0.0.0";
|
||||
|
||||
function checkIpAddrIsReset(ifname) {
|
||||
return gTestSuite.checkInterfaceIpAddr(ifname, INTERFACE_IP_NONE)
|
||||
.then(() => gTestSuite.checkDefaultRoute(ifname));
|
||||
}
|
||||
|
||||
gTestSuite.doTest(function() {
|
||||
return Promise.resolve()
|
||||
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => checkIpAddrIsReset(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
|
||||
});
|
@ -1,17 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const ETHERNET_INTERFACE_NAME = "eth1";
|
||||
|
||||
gTestSuite.doTest(function() {
|
||||
return Promise.resolve()
|
||||
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.checkInterfaceIsEnabled(ETHERNET_INTERFACE_NAME, true))
|
||||
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
|
||||
});
|
@ -1,43 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const ETHERNET_INTERFACE_NAME = "eth1";
|
||||
|
||||
let staticConfig = {
|
||||
ip: "1.2.3.4",
|
||||
gateway: "1.2.3.5",
|
||||
prefixLength: 24,
|
||||
dnses: ["1.2.3.6"],
|
||||
ipMode: "static"
|
||||
};
|
||||
|
||||
function checkStaticResult(ifname) {
|
||||
return gTestSuite.checkInterfaceIpAddr(ifname, staticConfig.ip)
|
||||
.then(() => gTestSuite.waitForDefaultRouteSet(ifname, staticConfig.gateway));
|
||||
}
|
||||
|
||||
function checkDhcpResult(ifname) {
|
||||
return gTestSuite.getDhcpIpAddr(ifname)
|
||||
.then(ip => gTestSuite.checkInterfaceIpAddr(ifname, ip))
|
||||
.then(() => gTestSuite.getDhcpGateway(ifname))
|
||||
.then(gateway => gTestSuite.waitForDefaultRouteSet(ifname, gateway));
|
||||
}
|
||||
|
||||
gTestSuite.doTest(function() {
|
||||
return Promise.resolve()
|
||||
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => checkDhcpResult(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.updateInterfaceConfig(ETHERNET_INTERFACE_NAME, staticConfig))
|
||||
.then(() => checkStaticResult(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.updateInterfaceConfig(ETHERNET_INTERFACE_NAME, { ipMode: "dhcp"}))
|
||||
.then(() => checkDhcpResult(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
|
||||
});
|
@ -1,28 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const ETHERNET_INTERFACE_NAME = "eth1";
|
||||
|
||||
function checkDhcpResult(ifname) {
|
||||
return gTestSuite.getDhcpIpAddr(ifname)
|
||||
.then(ip => gTestSuite.checkInterfaceIpAddr(ifname, ip))
|
||||
.then(() => gTestSuite.getDhcpGateway(ifname))
|
||||
.then(gateway => gTestSuite.waitForDefaultRouteSet(ifname, gateway));
|
||||
}
|
||||
|
||||
gTestSuite.doTest(function() {
|
||||
return Promise.resolve()
|
||||
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => checkDhcpResult(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => checkDhcpResult(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
|
||||
});
|
@ -1,36 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const ETHERNET_INTERFACE_NAME = "eth1";
|
||||
|
||||
let staticConfig = {
|
||||
ip: "1.2.3.4",
|
||||
gateway: "1.2.3.5",
|
||||
prefixLength: 24,
|
||||
dnses: ["1.2.3.6"],
|
||||
ipMode: "static"
|
||||
};
|
||||
|
||||
function checkStaticResult(ifname) {
|
||||
return gTestSuite.checkInterfaceIpAddr(ifname, staticConfig.ip)
|
||||
.then(() => gTestSuite.checkDefaultRoute(ifname, staticConfig.gateway));
|
||||
}
|
||||
|
||||
gTestSuite.doTest(function() {
|
||||
return Promise.resolve()
|
||||
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.updateInterfaceConfig(ETHERNET_INTERFACE_NAME, staticConfig))
|
||||
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => checkStaticResult(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => checkStaticResult(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
|
||||
});
|
@ -1,16 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const ETHERNET_INTERFACE_NAME = "eth1";
|
||||
|
||||
gTestSuite.doTest(function() {
|
||||
return Promise.resolve()
|
||||
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.checkInterfaceListLength(1))
|
||||
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME))
|
||||
.then(() => gTestSuite.checkInterfaceListLength(0));
|
||||
});
|
@ -13,9 +13,9 @@ Cu.import("resource://gre/modules/systemlibs.js");
|
||||
|
||||
const NETWORKMANAGER_CONTRACTID = "@mozilla.org/network/manager;1";
|
||||
const NETWORKMANAGER_CID =
|
||||
Components.ID("{1ba9346b-53b5-4660-9dc6-58f0b258d0a6}");
|
||||
Components.ID("{33901e46-33b8-11e1-9869-f46d04d25bcc}");
|
||||
|
||||
const DEFAULT_PREFERRED_NETWORK_TYPE = Ci.nsINetworkInterface.NETWORK_TYPE_ETHERNET;
|
||||
const DEFAULT_PREFERRED_NETWORK_TYPE = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
|
||||
"@mozilla.org/settingsService;1",
|
||||
@ -276,8 +276,7 @@ NetworkManager.prototype = {
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
|
||||
gNetworkService.resetRoutingTable(network);
|
||||
#ifdef MOZ_B2G_RIL
|
||||
} else if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
|
||||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_ETHERNET) {
|
||||
} else if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
|
||||
gNetworkService.removeDefaultRoute(network);
|
||||
#endif
|
||||
}
|
||||
@ -368,9 +367,7 @@ NetworkManager.prototype = {
|
||||
getNetworkId: function(network) {
|
||||
let id = "device";
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (this.isNetworkTypeEthernet(network.type)) {
|
||||
id = network.name.substring(3);
|
||||
} else if (this.isNetworkTypeMobile(network.type)) {
|
||||
if (this.isNetworkTypeMobile(network.type)) {
|
||||
if (!(network instanceof Ci.nsIRilNetworkInterface)) {
|
||||
throw Components.Exception("Mobile network not an nsIRilNetworkInterface",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
@ -422,51 +419,17 @@ NetworkManager.prototype = {
|
||||
|
||||
_dataDefaultServiceId: null,
|
||||
|
||||
_networkTypePriorityList: [Ci.nsINetworkInterface.NETWORK_TYPE_ETHERNET,
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE],
|
||||
get networkTypePriorityList() {
|
||||
return this._networkTypePriorityList;
|
||||
},
|
||||
set networkTypePriorityList(val) {
|
||||
if (val.length != this._networkTypePriorityList.length) {
|
||||
throw "Priority list length should equal to " +
|
||||
this._networkTypePriorityList.length;
|
||||
}
|
||||
|
||||
// Check if types in new priority list are valid and also make sure there
|
||||
// are no duplicate types.
|
||||
let list = [Ci.nsINetworkInterface.NETWORK_TYPE_ETHERNET,
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE];
|
||||
while (list.length) {
|
||||
let type = list.shift();
|
||||
if (val.indexOf(type) == -1) {
|
||||
throw "There is missing network type";
|
||||
}
|
||||
}
|
||||
|
||||
this._networkTypePriorityList = val;
|
||||
},
|
||||
|
||||
getPriority: function(type) {
|
||||
if (this._networkTypePriorityList.indexOf(type) == -1) {
|
||||
// 0 indicates the lowest priority.
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this._networkTypePriorityList.length -
|
||||
this._networkTypePriorityList.indexOf(type);
|
||||
},
|
||||
|
||||
_preferredNetworkType: DEFAULT_PREFERRED_NETWORK_TYPE,
|
||||
get preferredNetworkType() {
|
||||
return this._preferredNetworkType;
|
||||
},
|
||||
set preferredNetworkType(val) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE,
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_ETHERNET].indexOf(val) == -1) {
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
|
||||
#else
|
||||
if (val != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
|
||||
#endif
|
||||
throw "Invalid network type";
|
||||
}
|
||||
this._preferredNetworkType = val;
|
||||
@ -498,10 +461,6 @@ NetworkManager.prototype = {
|
||||
this.isNetworkTypeSecondaryMobile(type));
|
||||
},
|
||||
|
||||
isNetworkTypeEthernet: function(type) {
|
||||
return (type == Ci.nsINetworkInterface.NETWORK_TYPE_ETHERNET);
|
||||
},
|
||||
|
||||
setExtraHostRoute: function(network) {
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
|
||||
if (!(network instanceof Ci.nsIRilNetworkInterface)) {
|
||||
@ -642,23 +601,11 @@ NetworkManager.prototype = {
|
||||
defaultDataNetwork = network;
|
||||
}
|
||||
#endif
|
||||
this.active = network;
|
||||
if (network.type == this.preferredNetworkType) {
|
||||
this.active = network;
|
||||
debug("Found our preferred type of network: " + network.name);
|
||||
break;
|
||||
}
|
||||
|
||||
// Initialize the active network with the first connected network.
|
||||
if (!this.active) {
|
||||
this.active = network;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Compare the prioriy between two network types. If found incoming
|
||||
// network with higher priority, replace the active network.
|
||||
if (this.getPriority(this.active.type) < this.getPriority(network.type)) {
|
||||
this.active = network;
|
||||
}
|
||||
}
|
||||
if (this.active) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
@ -733,8 +680,7 @@ NetworkManager.prototype = {
|
||||
// the function will return null so that it won't trigger type change event
|
||||
// in NetworkInformation API.
|
||||
if (network.type != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI &&
|
||||
network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE &&
|
||||
network.type != Ci.nsINetworkInterface.NETWORK_TYPE_ETHERNET) {
|
||||
network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -747,8 +693,6 @@ NetworkManager.prototype = {
|
||||
return CONNECTION_TYPE_WIFI;
|
||||
case Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE:
|
||||
return CONNECTION_TYPE_CULLULAR;
|
||||
case Ci.nsINetworkInterface.NETWORK_TYPE_ETHERNET:
|
||||
return CONNECTION_TYPE_ETHERNET;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
# NetworkManager.js
|
||||
component {1ba9346b-53b5-4660-9dc6-58f0b258d0a6} NetworkManager.js
|
||||
contract @mozilla.org/network/manager;1 {1ba9346b-53b5-4660-9dc6-58f0b258d0a6}
|
||||
component {33901e46-33b8-11e1-9869-f46d04d25bcc} NetworkManager.js
|
||||
contract @mozilla.org/network/manager;1 {33901e46-33b8-11e1-9869-f46d04d25bcc}
|
||||
|
@ -12,7 +12,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
|
||||
const NETWORKSERVICE_CONTRACTID = "@mozilla.org/network/service;1";
|
||||
const NETWORKSERVICE_CID = Components.ID("{48c13741-aec9-4a86-8962-432011708261}");
|
||||
const NETWORKSERVICE_CID = Components.ID("{baec696c-c78d-42db-8b44-603f8fbfafb4}");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gNetworkWorker",
|
||||
"@mozilla.org/network/worker;1",
|
||||
@ -542,81 +542,6 @@ NetworkService.prototype = {
|
||||
});
|
||||
},
|
||||
|
||||
getInterfaces: function(callback) {
|
||||
let params = {
|
||||
cmd: "getInterfaces",
|
||||
isAsync: true
|
||||
};
|
||||
|
||||
this.controlMessage(params, function(data) {
|
||||
if(DEBUG) debug("getInterfaces result: " + JSON.stringify(data));
|
||||
let success = !isError(data.resultCode);
|
||||
callback.getInterfacesResult(success, data.interfaceList);
|
||||
});
|
||||
},
|
||||
|
||||
setInterfaceConfig: function(config, callback) {
|
||||
config.cmd = "setInterfaceConfig";
|
||||
config.isAsync = true;
|
||||
|
||||
this.controlMessage(config, function(data) {
|
||||
if(DEBUG) debug("setInterfaceConfig result: " + JSON.stringify(data));
|
||||
let success = !isError(data.resultCode);
|
||||
callback.setInterfaceConfigResult(success);
|
||||
});
|
||||
},
|
||||
|
||||
getInterfaceConfig: function(ifname, callback) {
|
||||
let params = {
|
||||
cmd: "getInterfaceConfig",
|
||||
ifname: ifname,
|
||||
isAsync: true
|
||||
};
|
||||
|
||||
this.controlMessage(params, function(data) {
|
||||
if(DEBUG) debug("getInterfaceConfig result: " + JSON.stringify(data));
|
||||
let success = !isError(data.resultCode);
|
||||
let result = { ip: data.ipAddr,
|
||||
prefix: data.maskLength,
|
||||
link: data.flag,
|
||||
mac: data.macAddr };
|
||||
callback.getInterfaceConfigResult(success, result);
|
||||
});
|
||||
},
|
||||
|
||||
runDhcp: function(ifname, callback) {
|
||||
let params = {
|
||||
cmd: "runDhcp",
|
||||
ifname: ifname,
|
||||
isBlocking: true
|
||||
};
|
||||
|
||||
this.controlMessage(params, function(data) {
|
||||
if(DEBUG) debug("runDhcp result: " + JSON.stringify(data));
|
||||
let success = data.success;
|
||||
let result = {
|
||||
ip: data.ipAddr,
|
||||
gateway: data.gateway,
|
||||
dns1: data.dns1,
|
||||
dns2: data.dns2,
|
||||
prefix: data.maskLength,
|
||||
server: data.server
|
||||
};
|
||||
|
||||
callback.runDhcpResult(success, result);
|
||||
});
|
||||
},
|
||||
|
||||
stopDhcp: function(ifname) {
|
||||
let params = {
|
||||
cmd: "stopDhcp",
|
||||
ifname: ifname,
|
||||
isAsync: true
|
||||
};
|
||||
|
||||
this.controlMessage(params);
|
||||
},
|
||||
|
||||
shutdown: false,
|
||||
|
||||
observe: function observe(aSubject, aTopic, aData) {
|
||||
|
@ -1,3 +1,3 @@
|
||||
# NetworkService.js
|
||||
component {48c13741-aec9-4a86-8962-432011708261} NetworkService.js
|
||||
contract @mozilla.org/network/service;1 {48c13741-aec9-4a86-8962-432011708261}
|
||||
component {baec696c-c78d-42db-8b44-603f8fbfafb4} NetworkService.js
|
||||
contract @mozilla.org/network/service;1 {baec696c-c78d-42db-8b44-603f8fbfafb4}
|
||||
|
@ -111,7 +111,7 @@ CommandFunc NetworkUtils::sWifiEnableChain[] = {
|
||||
NetworkUtils::startAccessPointDriver,
|
||||
NetworkUtils::setAccessPoint,
|
||||
NetworkUtils::startSoftAP,
|
||||
NetworkUtils::setConfig,
|
||||
NetworkUtils::setInterfaceUp,
|
||||
NetworkUtils::tetherInterface,
|
||||
NetworkUtils::setIpForwardingEnabled,
|
||||
NetworkUtils::tetheringStatus,
|
||||
@ -152,7 +152,7 @@ CommandFunc NetworkUtils::sWifiRetryChain[] = {
|
||||
NetworkUtils::startAccessPointDriver,
|
||||
NetworkUtils::setAccessPoint,
|
||||
NetworkUtils::startSoftAP,
|
||||
NetworkUtils::setConfig,
|
||||
NetworkUtils::setInterfaceUp,
|
||||
NetworkUtils::tetherInterface,
|
||||
NetworkUtils::setIpForwardingEnabled,
|
||||
NetworkUtils::tetheringStatus,
|
||||
@ -168,7 +168,7 @@ CommandFunc NetworkUtils::sWifiOperationModeChain[] = {
|
||||
};
|
||||
|
||||
CommandFunc NetworkUtils::sUSBEnableChain[] = {
|
||||
NetworkUtils::setConfig,
|
||||
NetworkUtils::setInterfaceUp,
|
||||
NetworkUtils::enableNat,
|
||||
NetworkUtils::setIpForwardingEnabled,
|
||||
NetworkUtils::tetherInterface,
|
||||
@ -201,7 +201,7 @@ CommandFunc NetworkUtils::sUpdateUpStreamChain[] = {
|
||||
};
|
||||
|
||||
CommandFunc NetworkUtils::sStartDhcpServerChain[] = {
|
||||
NetworkUtils::setConfig,
|
||||
NetworkUtils::setInterfaceUp,
|
||||
NetworkUtils::startTethering,
|
||||
NetworkUtils::setDhcpServerSuccess
|
||||
};
|
||||
@ -240,21 +240,6 @@ CommandFunc NetworkUtils::sSetDnsChain[] = {
|
||||
NetworkUtils::setInterfaceDns
|
||||
};
|
||||
|
||||
CommandFunc NetworkUtils::sGetInterfacesChain[] = {
|
||||
NetworkUtils::getInterfaceList,
|
||||
NetworkUtils::getInterfacesSuccess
|
||||
};
|
||||
|
||||
CommandFunc NetworkUtils::sSetInterfaceConfigChain[] = {
|
||||
NetworkUtils::setConfig,
|
||||
NetworkUtils::setInterfaceConfigSuccess
|
||||
};
|
||||
|
||||
CommandFunc NetworkUtils::sGetInterfaceConfigChain[] = {
|
||||
NetworkUtils::getConfig,
|
||||
NetworkUtils::getInterfaceConfigSuccess
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to get the mask from given prefix length.
|
||||
*/
|
||||
@ -337,15 +322,6 @@ static void join(nsTArray<nsCString>& array,
|
||||
#undef CHECK_LEN
|
||||
}
|
||||
|
||||
static void convertUTF8toUTF16(nsTArray<nsCString>& narrow,
|
||||
nsTArray<nsString>& wide,
|
||||
uint32_t length)
|
||||
{
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
wide.AppendElement(NS_ConvertUTF8toUTF16(narrow[i].get()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get network interface properties from the system property table.
|
||||
*/
|
||||
@ -710,9 +686,9 @@ void NetworkUtils::setAlarm(CommandChain* aChain,
|
||||
doCommand(command, aChain, aCallback);
|
||||
}
|
||||
|
||||
void NetworkUtils::setConfig(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult)
|
||||
void NetworkUtils::setInterfaceUp(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult)
|
||||
{
|
||||
char command[MAX_COMMAND_SIZE];
|
||||
if (SDK_VERSION >= 16) {
|
||||
@ -947,26 +923,6 @@ void NetworkUtils::setInterfaceDns(CommandChain* aChain,
|
||||
doCommand(command, aChain, aCallback);
|
||||
}
|
||||
|
||||
void NetworkUtils::getInterfaceList(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult)
|
||||
{
|
||||
char command[MAX_COMMAND_SIZE];
|
||||
snprintf(command, MAX_COMMAND_SIZE - 1, "interface list");
|
||||
|
||||
doCommand(command, aChain, aCallback);
|
||||
}
|
||||
|
||||
void NetworkUtils::getConfig(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult)
|
||||
{
|
||||
char command[MAX_COMMAND_SIZE];
|
||||
snprintf(command, MAX_COMMAND_SIZE - 1, "interface getcfg %s", GET_CHAR(mIfname));
|
||||
|
||||
doCommand(command, aChain, aCallback);
|
||||
}
|
||||
|
||||
#undef GET_CHAR
|
||||
#undef GET_FIELD
|
||||
|
||||
@ -1107,75 +1063,6 @@ void NetworkUtils::setDnsFail(NetworkParams& aOptions, NetworkResultOptions& aRe
|
||||
postMessage(aOptions, aResult);
|
||||
}
|
||||
|
||||
void NetworkUtils::getInterfacesFail(NetworkParams& aOptions, NetworkResultOptions& aResult)
|
||||
{
|
||||
postMessage(aOptions, aResult);
|
||||
}
|
||||
|
||||
void NetworkUtils::getInterfacesSuccess(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult)
|
||||
{
|
||||
char buf[BUF_SIZE];
|
||||
NS_ConvertUTF16toUTF8 reason(aResult.mResultReason);
|
||||
memcpy(buf, reason.get(), strlen(reason.get()));
|
||||
|
||||
nsTArray<nsCString> result;
|
||||
split(buf, INTERFACE_DELIMIT, result);
|
||||
|
||||
nsTArray<nsString> interfaceList;
|
||||
uint32_t length = result.Length();
|
||||
convertUTF8toUTF16(result, interfaceList, length);
|
||||
|
||||
aResult.mInterfaceList.Construct();
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
aResult.mInterfaceList.Value().AppendElement(interfaceList[i]);
|
||||
}
|
||||
|
||||
postMessage(aChain->getParams(), aResult);
|
||||
}
|
||||
|
||||
void NetworkUtils::setInterfaceConfigFail(NetworkParams& aOptions, NetworkResultOptions& aResult)
|
||||
{
|
||||
postMessage(aOptions, aResult);
|
||||
}
|
||||
|
||||
void NetworkUtils::setInterfaceConfigSuccess(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult)
|
||||
{
|
||||
postMessage(aChain->getParams(), aResult);
|
||||
}
|
||||
|
||||
void NetworkUtils::getInterfaceConfigFail(NetworkParams& aOptions, NetworkResultOptions& aResult)
|
||||
{
|
||||
postMessage(aOptions, aResult);
|
||||
}
|
||||
|
||||
void NetworkUtils::getInterfaceConfigSuccess(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult)
|
||||
{
|
||||
char buf[BUF_SIZE];
|
||||
NS_ConvertUTF16toUTF8 reason(aResult.mResultReason);
|
||||
memcpy(buf, reason.get(), strlen(reason.get()));
|
||||
|
||||
nsTArray<nsCString> result;
|
||||
split(buf, NETD_MESSAGE_DELIMIT, result);
|
||||
|
||||
ASSIGN_FIELD_VALUE(mMacAddr, NS_ConvertUTF8toUTF16(result[0]))
|
||||
ASSIGN_FIELD_VALUE(mIpAddr, NS_ConvertUTF8toUTF16(result[1]))
|
||||
ASSIGN_FIELD_VALUE(mMaskLength, atof(result[2].get()))
|
||||
|
||||
if (result[3].Find("up")) {
|
||||
ASSIGN_FIELD_VALUE(mFlag, NS_ConvertUTF8toUTF16("up"))
|
||||
} else {
|
||||
ASSIGN_FIELD_VALUE(mFlag, NS_ConvertUTF8toUTF16("down"))
|
||||
}
|
||||
|
||||
postMessage(aChain->getParams(), aResult);
|
||||
}
|
||||
|
||||
#undef ASSIGN_FIELD
|
||||
#undef ASSIGN_FIELD_VALUE
|
||||
|
||||
@ -1240,14 +1127,6 @@ void NetworkUtils::ExecuteCommand(NetworkParams aOptions)
|
||||
enableUsbRndis(aOptions);
|
||||
} else if (aOptions.mCmd.EqualsLiteral("updateUpStream")) {
|
||||
updateUpStream(aOptions);
|
||||
} else if (aOptions.mCmd.EqualsLiteral("getInterfaces")) {
|
||||
getInterfaces(aOptions);
|
||||
} else if (aOptions.mCmd.EqualsLiteral("stopDhcp")) {
|
||||
stopDhcp(aOptions);
|
||||
} else if (aOptions.mCmd.EqualsLiteral("setInterfaceConfig")) {
|
||||
setInterfaceConfig(aOptions);
|
||||
} else if (aOptions.mCmd.EqualsLiteral("getInterfaceConfig")) {
|
||||
getInterfaceConfig(aOptions);
|
||||
} else {
|
||||
WARN("unknon message");
|
||||
return;
|
||||
@ -1837,7 +1716,7 @@ bool NetworkUtils::enableUsbRndis(NetworkParams& aOptions)
|
||||
}
|
||||
|
||||
/**
|
||||
* Handling upstream interface change event.
|
||||
* handling upstream interface change event.
|
||||
*/
|
||||
bool NetworkUtils::updateUpStream(NetworkParams& aOptions)
|
||||
{
|
||||
@ -1845,42 +1724,6 @@ bool NetworkUtils::updateUpStream(NetworkParams& aOptions)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop dhcp client deamon.
|
||||
*/
|
||||
bool NetworkUtils::stopDhcp(NetworkParams& aOptions)
|
||||
{
|
||||
mNetUtils->do_dhcp_stop(GET_CHAR(mIfname));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get existing network interfaces.
|
||||
*/
|
||||
bool NetworkUtils::getInterfaces(NetworkParams& aOptions)
|
||||
{
|
||||
RUN_CHAIN(aOptions, sGetInterfacesChain, getInterfacesFail)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set network config for a specified interface.
|
||||
*/
|
||||
bool NetworkUtils::setInterfaceConfig(NetworkParams& aOptions)
|
||||
{
|
||||
RUN_CHAIN(aOptions, sSetInterfaceConfigChain, setInterfaceConfigFail)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get network config of a specified interface.
|
||||
*/
|
||||
bool NetworkUtils::getInterfaceConfig(NetworkParams& aOptions)
|
||||
{
|
||||
RUN_CHAIN(aOptions, sGetInterfaceConfigChain, getInterfaceConfigFail)
|
||||
return true;
|
||||
}
|
||||
|
||||
void NetworkUtils::sendBroadcastMessage(uint32_t code, char* reason)
|
||||
{
|
||||
NetworkResultOptions result;
|
||||
|
@ -72,7 +72,6 @@ public:
|
||||
mCurInternalIfname = aOther.mCurInternalIfname;
|
||||
mCurExternalIfname = aOther.mCurExternalIfname;
|
||||
mThreshold = aOther.mThreshold;
|
||||
mIsBlocking = aOther.mIsBlocking;
|
||||
}
|
||||
|
||||
NetworkParams(const mozilla::dom::NetworkCommandOptions& aOther) {
|
||||
@ -149,7 +148,6 @@ public:
|
||||
COPY_OPT_STRING_FIELD(mCurInternalIfname, EmptyString())
|
||||
COPY_OPT_STRING_FIELD(mCurExternalIfname, EmptyString())
|
||||
COPY_OPT_FIELD(mThreshold, -1)
|
||||
COPY_OPT_FIELD(mIsBlocking, false)
|
||||
|
||||
#undef COPY_SEQUENCE_FIELD
|
||||
#undef COPY_OPT_STRING_FIELD
|
||||
@ -200,7 +198,6 @@ public:
|
||||
nsString mCurInternalIfname;
|
||||
nsString mCurExternalIfname;
|
||||
long mThreshold;
|
||||
bool mIsBlocking;
|
||||
};
|
||||
|
||||
// CommandChain store the necessary information to execute command one by one.
|
||||
@ -284,10 +281,6 @@ private:
|
||||
bool setUSBTethering(NetworkParams& aOptions);
|
||||
bool enableUsbRndis(NetworkParams& aOptions);
|
||||
bool updateUpStream(NetworkParams& aOptions);
|
||||
bool getInterfaces(NetworkParams& aOptions);
|
||||
bool stopDhcp(NetworkParams& aOptions);
|
||||
bool setInterfaceConfig(NetworkParams& aOptions);
|
||||
bool getInterfaceConfig(NetworkParams& aOptions);
|
||||
|
||||
/**
|
||||
* function pointer array holds all netd commands should be executed
|
||||
@ -309,9 +302,6 @@ private:
|
||||
static CommandFunc sNetworkInterfaceDisableAlarmChain[];
|
||||
static CommandFunc sNetworkInterfaceSetAlarmChain[];
|
||||
static CommandFunc sSetDnsChain[];
|
||||
static CommandFunc sGetInterfacesChain[];
|
||||
static CommandFunc sSetInterfaceConfigChain[];
|
||||
static CommandFunc sGetInterfaceConfigChain[];
|
||||
|
||||
/**
|
||||
* Individual netd command stored in command chain.
|
||||
@ -348,9 +338,6 @@ private:
|
||||
static void disableNat(PARAMS);
|
||||
static void setDefaultInterface(PARAMS);
|
||||
static void setInterfaceDns(PARAMS);
|
||||
static void getInterfaceList(PARAMS);
|
||||
static void setConfig(PARAMS);
|
||||
static void getConfig(PARAMS);
|
||||
static void wifiTetheringSuccess(PARAMS);
|
||||
static void usbTetheringSuccess(PARAMS);
|
||||
static void networkInterfaceStatsSuccess(PARAMS);
|
||||
@ -358,9 +345,6 @@ private:
|
||||
static void updateUpStreamSuccess(PARAMS);
|
||||
static void setDhcpServerSuccess(PARAMS);
|
||||
static void wifiOperationModeSuccess(PARAMS);
|
||||
static void getInterfacesSuccess(PARAMS);
|
||||
static void setInterfaceConfigSuccess(PARAMS);
|
||||
static void getInterfaceConfigSuccess(PARAMS);
|
||||
#undef PARAMS
|
||||
|
||||
/**
|
||||
@ -376,9 +360,6 @@ private:
|
||||
static void networkInterfaceStatsFail(PARAMS);
|
||||
static void networkInterfaceAlarmFail(PARAMS);
|
||||
static void setDnsFail(PARAMS);
|
||||
static void getInterfacesFail(PARAMS);
|
||||
static void setInterfaceConfigFail(PARAMS);
|
||||
static void getInterfaceConfigFail(PARAMS);
|
||||
#undef PARAMS
|
||||
|
||||
/**
|
||||
|
@ -18,8 +18,6 @@ using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
#define PROPERTY_VALUE_MAX 80
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
nsCOMPtr<nsIThread> gWorkerThread;
|
||||
@ -39,15 +37,6 @@ public:
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
#define COPY_FIELD(prop) mResult.prop = aResult.prop;
|
||||
#define COPY_SEQUENCE_FIELD(prop, type) \
|
||||
if (aResult.prop.WasPassed()) { \
|
||||
mozilla::dom::Sequence<type > const & currentValue = aResult.prop.InternalValue(); \
|
||||
uint32_t length = currentValue.Length(); \
|
||||
mResult.prop.Construct(); \
|
||||
for (uint32_t idx = 0; idx < length; idx++) { \
|
||||
mResult.prop.Value().AppendElement(currentValue[idx]); \
|
||||
} \
|
||||
}
|
||||
COPY_FIELD(mId)
|
||||
COPY_FIELD(mRet)
|
||||
COPY_FIELD(mBroadcast)
|
||||
@ -64,16 +53,6 @@ public:
|
||||
COPY_FIELD(mSuccess)
|
||||
COPY_FIELD(mCurExternalIfname)
|
||||
COPY_FIELD(mCurInternalIfname)
|
||||
COPY_FIELD(mIpAddr)
|
||||
COPY_FIELD(mGateway)
|
||||
COPY_FIELD(mDns1)
|
||||
COPY_FIELD(mDns2)
|
||||
COPY_FIELD(mServer)
|
||||
COPY_FIELD(mLease)
|
||||
COPY_FIELD(mVendorInfo)
|
||||
COPY_FIELD(mMaskLength)
|
||||
COPY_FIELD(mFlag)
|
||||
COPY_SEQUENCE_FIELD(mInterfaceList, nsString)
|
||||
#undef COPY_FIELD
|
||||
}
|
||||
|
||||
@ -113,66 +92,6 @@ private:
|
||||
NetworkParams mParams;
|
||||
};
|
||||
|
||||
// Runnable used for blocking command.
|
||||
class RunDhcpEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
RunDhcpEvent(const NetworkParams& aParams)
|
||||
: mParams(aParams)
|
||||
{}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
nsAutoPtr<NetUtils> netUtils;
|
||||
netUtils = new NetUtils();
|
||||
|
||||
NetworkResultOptions result;
|
||||
result.mId = mParams.mId;
|
||||
|
||||
int32_t status;
|
||||
char ipaddr[PROPERTY_VALUE_MAX];
|
||||
char gateway[PROPERTY_VALUE_MAX];
|
||||
uint32_t prefixLength;
|
||||
char dns1[PROPERTY_VALUE_MAX];
|
||||
char dns2[PROPERTY_VALUE_MAX];
|
||||
char server[PROPERTY_VALUE_MAX];
|
||||
uint32_t lease;
|
||||
char vendorinfo[PROPERTY_VALUE_MAX];
|
||||
status = netUtils->do_dhcp_do_request(NS_ConvertUTF16toUTF8(mParams.mIfname).get(),
|
||||
ipaddr,
|
||||
gateway,
|
||||
&prefixLength,
|
||||
dns1,
|
||||
dns2,
|
||||
server,
|
||||
&lease,
|
||||
vendorinfo);
|
||||
|
||||
|
||||
if (status == 0) {
|
||||
// run dhcp success.
|
||||
result.mSuccess = true;
|
||||
result.mIpAddr = NS_ConvertUTF8toUTF16(ipaddr);
|
||||
result.mGateway = NS_ConvertUTF8toUTF16(gateway);
|
||||
result.mDns1 = NS_ConvertUTF8toUTF16(dns1);
|
||||
result.mDns2 = NS_ConvertUTF8toUTF16(dns2);
|
||||
result.mServer = NS_ConvertUTF8toUTF16(server);
|
||||
result.mLease = lease;
|
||||
result.mVendorInfo = NS_ConvertUTF8toUTF16(vendorinfo);
|
||||
result.mMaskLength = prefixLength;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable = new NetworkResultDispatcher(result);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
NetworkParams mParams;
|
||||
};
|
||||
|
||||
// Runnable used dispatch netd result on the worker thread.
|
||||
class NetdEventRunnable : public nsRunnable
|
||||
{
|
||||
@ -305,14 +224,8 @@ NetworkWorker::PostMessage(JS::Handle<JS::Value> aOptions, JSContext* aCx)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NetworkParams NetworkParams(options);
|
||||
|
||||
if (NetworkParams.mIsBlocking) {
|
||||
NetworkWorker::HandleBlockingCommand(NetworkParams);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Dispatch the command to the control thread.
|
||||
NetworkParams NetworkParams(options);
|
||||
nsCOMPtr<nsIRunnable> runnable = new NetworkCommandDispatcher(NetworkParams);
|
||||
if (gWorkerThread) {
|
||||
gWorkerThread->Dispatch(runnable, nsIEventTarget::DISPATCH_NORMAL);
|
||||
@ -320,24 +233,6 @@ NetworkWorker::PostMessage(JS::Handle<JS::Value> aOptions, JSContext* aCx)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
NetworkWorker::HandleBlockingCommand(NetworkParams& aOptions)
|
||||
{
|
||||
if (aOptions.mCmd.EqualsLiteral("runDhcp")) {
|
||||
NetworkWorker::RunDhcp(aOptions);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetworkWorker::RunDhcp(NetworkParams& aOptions)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable = new RunDhcpEvent(aOptions);
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
NS_NewThread(getter_AddRefs(thread), runnable);
|
||||
}
|
||||
|
||||
void
|
||||
NetworkWorker::DispatchNetworkResult(const NetworkResultOptions& aOptions)
|
||||
{
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsThread.h"
|
||||
|
||||
class NetworkParams;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class NetworkWorker MOZ_FINAL : public nsINetworkWorker
|
||||
@ -31,9 +29,6 @@ private:
|
||||
|
||||
static void NotifyResult(mozilla::dom::NetworkResultOptions& aResult);
|
||||
|
||||
void HandleBlockingCommand(NetworkParams& aParams);
|
||||
void RunDhcp(NetworkParams& aParams);
|
||||
|
||||
nsCOMPtr<nsINetworkEventListener> mListener;
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,7 @@ interface nsIWifiTetheringCallback;
|
||||
/**
|
||||
* Information about networks that is exposed to network manager API consumers.
|
||||
*/
|
||||
[scriptable, uuid(8f9ab9e0-72c1-4874-80c7-8143353b979f)]
|
||||
[scriptable, uuid(cb62ae03-6bda-43ff-9560-916d60203d33)]
|
||||
interface nsINetworkInterface : nsISupports
|
||||
{
|
||||
const long NETWORK_STATE_UNKNOWN = -1;
|
||||
@ -17,8 +17,6 @@ interface nsINetworkInterface : nsISupports
|
||||
const long NETWORK_STATE_CONNECTED = 1;
|
||||
const long NETWORK_STATE_DISCONNECTING = 2;
|
||||
const long NETWORK_STATE_DISCONNECTED = 3;
|
||||
const long NETWORK_STATE_ENABLED = 4;
|
||||
const long NETWORK_STATE_DISABLED = 5;
|
||||
|
||||
/**
|
||||
* Current network state, one of the NETWORK_STATE_* constants.
|
||||
@ -36,7 +34,6 @@ interface nsINetworkInterface : nsISupports
|
||||
const long NETWORK_TYPE_WIFI_P2P = 4;
|
||||
const long NETWORK_TYPE_MOBILE_IMS = 5;
|
||||
const long NETWORK_TYPE_MOBILE_DUN = 6;
|
||||
const long NETWORK_TYPE_ETHERNET = 7;
|
||||
|
||||
/**
|
||||
* Network type. One of the NETWORK_TYPE_* constants.
|
||||
@ -100,7 +97,7 @@ interface nsINetworkInterface : nsISupports
|
||||
/**
|
||||
* Manage network interfaces.
|
||||
*/
|
||||
[scriptable, uuid(1ba9346b-53b5-4660-9dc6-58f0b258d0a6)]
|
||||
[scriptable, uuid(3ea50550-4b3c-11e3-8f96-0800200c9a66)]
|
||||
interface nsINetworkManager : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -138,15 +135,6 @@ interface nsINetworkManager : nsISupports
|
||||
*/
|
||||
readonly attribute jsval networkInterfaces;
|
||||
|
||||
/**
|
||||
* Priority list of network types. An array of
|
||||
* nsINetworkInterface::NETWORK_TYPE_* constants.
|
||||
*
|
||||
* The piror position of the type indicates the higher priority. The priority
|
||||
* is used to determine route when there are multiple connected networks.
|
||||
*/
|
||||
attribute jsval networkTypePriorityList;
|
||||
|
||||
/**
|
||||
* The preferred network type. One of the
|
||||
* nsINetworkInterface::NETWORK_TYPE_* constants.
|
||||
|
@ -101,65 +101,10 @@ interface nsIUpdateUpStreamCallback : nsISupports
|
||||
void updateUpStreamResult(in boolean success, in DOMString externalIfname);
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(4a9166f3-7e4f-4d10-bb5c-b49ee21d6184)]
|
||||
interface nsIRunDhcpCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
* Callback function used to report the result of dhcp request.
|
||||
*
|
||||
* @param success
|
||||
* Boolean to indicate the operation is successful or not.
|
||||
*/
|
||||
void runDhcpResult(in boolean success, in jsval result);
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(88e3ee22-f1b3-4fa0-8a5d-793fb827c42c)]
|
||||
interface nsIGetInterfacesCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
* Callback function used to return the list of existing network interfaces.
|
||||
*
|
||||
* @param success
|
||||
* Boolean to indicate the operation is successful or not.
|
||||
* @param interfaceList
|
||||
* An array of interface name.
|
||||
*/
|
||||
void getInterfacesResult(in boolean success, in jsval interfaceList);
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(064e02a3-d2c0-42c5-a293-1efa84056100)]
|
||||
interface nsIGetInterfaceConfigCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
* Callback function used to return the network config of a given interface.
|
||||
*
|
||||
* @param success
|
||||
* Boolean to indicate the operation is successful or not.
|
||||
* @param result
|
||||
* .ip: Ip address.
|
||||
* .prefix: mask length.
|
||||
* .link: network link properties.
|
||||
* .mac: mac address.
|
||||
*/
|
||||
void getInterfaceConfigResult(in boolean success, in jsval result);
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(b370f360-6ba8-4517-a4f9-31e8f004ee91)]
|
||||
interface nsISetInterfaceConfigCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
* Callback function used to set network cofig for a specified interface.
|
||||
*
|
||||
* @param success
|
||||
* Boolean to indicate the operation is successful or not.
|
||||
*/
|
||||
void setInterfaceConfigResult(in boolean success);
|
||||
};
|
||||
|
||||
/**
|
||||
* Provide network services.
|
||||
*/
|
||||
[scriptable, uuid(48c13741-aec9-4a86-8962-432011708261)]
|
||||
[scriptable, uuid(f96461fa-e844-45d2-a6c3-8cd23ab0916b)]
|
||||
interface nsINetworkService : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -400,53 +345,4 @@ interface nsINetworkService : nsISupports
|
||||
void updateUpStream(in jsval previous,
|
||||
in jsval current,
|
||||
in nsIUpdateUpStreamCallback callback);
|
||||
|
||||
/**
|
||||
* Run Dhcp request.
|
||||
*
|
||||
* @param ifname
|
||||
* Target interface.
|
||||
* @param callback
|
||||
* Callback function to report the result.
|
||||
*/
|
||||
void runDhcp(in DOMString ifname, in nsIRunDhcpCallback callback);
|
||||
|
||||
/**
|
||||
* Stop Dhcp daemon.
|
||||
*
|
||||
* @param ifname
|
||||
* Target interface.
|
||||
*/
|
||||
void stopDhcp(in DOMString ifname);
|
||||
|
||||
/*
|
||||
* Obtain interfaces list.
|
||||
*
|
||||
* @param callback
|
||||
* Callback function to return the result.
|
||||
*/
|
||||
void getInterfaces(in nsIGetInterfacesCallback callback);
|
||||
|
||||
/**
|
||||
* Set config for a network interface.
|
||||
*
|
||||
* @param config
|
||||
* .ifname: Target interface.
|
||||
* .ip: Ip address.
|
||||
* .prefix: mask length.
|
||||
* .link: network link properties.
|
||||
* @param callback
|
||||
* Callback function to report the result.
|
||||
*/
|
||||
void setInterfaceConfig(in jsval config, in nsISetInterfaceConfigCallback callback);
|
||||
|
||||
/**
|
||||
* Get config of a network interface.
|
||||
*
|
||||
* @param ifname
|
||||
* Target interface.
|
||||
* @param callback
|
||||
* Callback function to report the result.
|
||||
*/
|
||||
void getInterfaceConfig(in DOMString ifname, in nsIGetInterfaceConfigCallback callback);
|
||||
};
|
||||
|
42
dom/webidl/BluetoothClassOfDevice.webidl
Normal file
42
dom/webidl/BluetoothClassOfDevice.webidl
Normal file
@ -0,0 +1,42 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
[CheckPermissions="bluetooth"]
|
||||
interface BluetoothClassOfDevice
|
||||
{
|
||||
/**
|
||||
* The following constants are defined in Assigned Numbers of bluetooth
|
||||
* General Access Profile (GAP) spec. For more information see
|
||||
* https://www.bluetooth.org/en-us/specification/assigned-numbers/baseband
|
||||
*/
|
||||
|
||||
// Major service class
|
||||
const unsigned short LIMITED_DISCOVERABILITY = 0x0001;
|
||||
const unsigned short POSITIONING = 0x0008;
|
||||
const unsigned short NETWORKING = 0x0010;
|
||||
const unsigned short RENDERING = 0x0020;
|
||||
const unsigned short CAPTURING = 0x0040;
|
||||
const unsigned short OBJECT_TRANSFER = 0x0080;
|
||||
const unsigned short AUDIO = 0x0100;
|
||||
const unsigned short TELEPHONY = 0x0200;
|
||||
const unsigned short INFORMATION = 0x0400;
|
||||
|
||||
// Major device class
|
||||
const octet MISC = 0x00;
|
||||
const octet COMPUTER = 0x01;
|
||||
const octet PHONE = 0x02;
|
||||
const octet NETWORK = 0x03;
|
||||
const octet AUDIO_VIDEO = 0x04;
|
||||
const octet PERIPHERAL = 0x05;
|
||||
const octet IMAGING = 0x06;
|
||||
const octet WEARABLE = 0x07;
|
||||
const octet TOY = 0x08;
|
||||
const octet HEALTH = 0x09;
|
||||
const octet UNCATEGORIZED = 0x1F;
|
||||
|
||||
readonly attribute unsigned short majorServiceClass;
|
||||
readonly attribute octet majorDeviceClass;
|
||||
readonly attribute octet minorDeviceClass;
|
||||
};
|
@ -3,7 +3,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* This dictionary holds the parameters sent to the network worker.
|
||||
* This dictionnary holds the parameters sent to the network worker.
|
||||
*/
|
||||
dictionary NetworkCommandOptions
|
||||
{
|
||||
@ -55,7 +55,6 @@ dictionary NetworkCommandOptions
|
||||
DOMString preExternalIfname; // for "updateUpStream".
|
||||
DOMString curInternalIfname; // for "updateUpStream".
|
||||
DOMString curExternalIfname; // for "updateUpStream".
|
||||
boolean isBlocking; // for "runDhcp".
|
||||
};
|
||||
|
||||
/**
|
||||
@ -82,18 +81,4 @@ dictionary NetworkResultOptions
|
||||
boolean success = false; // for "setDhcpServer".
|
||||
DOMString curExternalIfname = ""; // for "updateUpStream".
|
||||
DOMString curInternalIfname = ""; // for "updateUpStream".
|
||||
|
||||
DOMString ipAddr = ""; // for "runDhcp", "getInterfaceConfig".
|
||||
DOMString gateway = ""; // for "runDhcp".
|
||||
DOMString dns1 = ""; // for "runDhcp".
|
||||
DOMString dns2 = ""; // for "runDhcp".
|
||||
DOMString server = ""; // for "runDhcp".
|
||||
short lease = 0; // for "runDhcp".
|
||||
DOMString vendorInfo = ""; // for "runDhcp".
|
||||
short maskLength = 0; // for "runDhcp".
|
||||
|
||||
DOMString flag = "down"; // for "getInterfaceConfig".
|
||||
DOMString macAddr = ""; // for "getInterfaceConfig".
|
||||
|
||||
sequence<DOMString> interfaceList; // for "getInterfaceList".
|
||||
};
|
||||
|
@ -567,6 +567,7 @@ if CONFIG['MOZ_B2G_BT']:
|
||||
if CONFIG['MOZ_B2G_BT_API_V2']:
|
||||
WEBIDL_FILES += [
|
||||
'BluetoothAdapter2.webidl',
|
||||
'BluetoothClassOfDevice.webidl',
|
||||
'BluetoothDevice2.webidl',
|
||||
'BluetoothDiscoveryHandle.webidl',
|
||||
'BluetoothManager2.webidl',
|
||||
|
@ -92,7 +92,7 @@
|
||||
|
||||
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true"/>
|
||||
|
||||
#ifdef MOZ_NATIVE_CASTING
|
||||
#ifdef MOZ_NATIVE_DEVICES
|
||||
<!-- This resources comes from Google Play Services. Required for casting support. -->
|
||||
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
|
||||
#endif
|
||||
|
@ -164,7 +164,7 @@ public class AppConstants {
|
||||
#endif
|
||||
|
||||
public static final boolean MOZ_MEDIA_PLAYER =
|
||||
#ifdef MOZ_NATIVE_CASTING
|
||||
#ifdef MOZ_NATIVE_DEVICES
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
|
@ -550,6 +550,19 @@ public class BrowserApp extends GeckoApp
|
||||
|
||||
Distribution.init(this);
|
||||
|
||||
// Shipping Native casting is optional and dependent on whether you've downloaded the support
|
||||
// and google play libraries
|
||||
if (AppConstants.MOZ_MEDIA_PLAYER) {
|
||||
try {
|
||||
Class<?> mediaManagerClass = Class.forName("org.mozilla.gecko.MediaPlayerManager");
|
||||
Method init = mediaManagerClass.getMethod("init", Context.class);
|
||||
init.invoke(null, this);
|
||||
} catch(Exception ex) {
|
||||
// Ignore failures
|
||||
Log.i(LOGTAG, "No native casting support", ex);
|
||||
}
|
||||
}
|
||||
|
||||
JavaAddonManager.getInstance().init(getApplicationContext());
|
||||
mSharedPreferencesHelper = new SharedPreferencesHelper(getApplicationContext());
|
||||
mOrderedBroadcastHelper = new OrderedBroadcastHelper(getApplicationContext());
|
||||
|
@ -19,12 +19,10 @@ import com.google.android.gms.cast.MediaMetadata;
|
||||
import com.google.android.gms.cast.MediaStatus;
|
||||
import com.google.android.gms.cast.RemoteMediaPlayer;
|
||||
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult;
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.api.GoogleApiClient;
|
||||
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
|
||||
import com.google.android.gms.common.api.ResultCallback;
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.common.GooglePlayServicesUtil;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@ -133,11 +131,6 @@ class ChromeCast implements GeckoMediaPlayer {
|
||||
}
|
||||
|
||||
public ChromeCast(Context context, RouteInfo route) {
|
||||
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
|
||||
if (status != ConnectionResult.SUCCESS) {
|
||||
throw new IllegalStateException("Play services are required for Chromecast support (go status code " + status + ")");
|
||||
}
|
||||
|
||||
this.context = context;
|
||||
this.route = route;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user