diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index cfae304f654..73aec6155cf 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 077e18fad91..ec2025975c1 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index b93196ab29f..17a2b850b2c 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index cfae304f654..73aec6155cf 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 3b05dd290e2..633e09cf0e1 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 71097bfae3b..c2532c1545d 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "158fb07e2e4939dddee026a33a05d65e38bb0e67", + "revision": "056dbe15b2aac2b252a119c211a85cb14165aa81", "repo_path": "/integration/gaia-central" } diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 4b556d4576f..338c3a8467a 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index d9065fcb04d..6ab19db9a71 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 2883aa9c3bb..a5f6250601f 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 55eb13ace04..9af3aab7125 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index 8f4ae949030..92e8f9486e4 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -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 diff --git a/browser/base/content/test/newtab/browser_newtab_update.js b/browser/base/content/test/newtab/browser_newtab_update.js index d08750cf29e..bf03a5a8c89 100644 --- a/browser/base/content/test/newtab/browser_newtab_update.js +++ b/browser/base/content/test/newtab/browser_newtab_update.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) { diff --git a/browser/devtools/inspector/test/browser.ini b/browser/devtools/inspector/test/browser.ini index 399513e8379..0851bb73995 100644 --- a/browser/devtools/inspector/test/browser.ini +++ b/browser/devtools/inspector/test/browser.ini @@ -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] diff --git a/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js b/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js index b055bb24340..41821c1ec14 100644 --- a/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js +++ b/browser/devtools/inspector/test/browser_inspector_breadcrumbs.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"}, diff --git a/browser/devtools/inspector/test/browser_inspector_bug_817558_delete_node.js b/browser/devtools/inspector/test/browser_inspector_delete-selected-node-01.js similarity index 91% rename from browser/devtools/inspector/test/browser_inspector_bug_817558_delete_node.js rename to browser/devtools/inspector/test/browser_inspector_delete-selected-node-01.js index 1a87c77a7d5..4d4f5f0238e 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_817558_delete_node.js +++ b/browser/devtools/inspector/test/browser_inspector_delete-selected-node-01.js @@ -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); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js b/browser/devtools/inspector/test/browser_inspector_delete-selected-node-02.js similarity index 98% rename from browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js rename to browser/devtools/inspector/test/browser_inspector_delete-selected-node-02.js index 48e8e99f7d4..8abe92737ba 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js +++ b/browser/devtools/inspector/test/browser_inspector_delete-selected-node-02.js @@ -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); diff --git a/browser/devtools/inspector/test/browser_inspector_destroyselection.js b/browser/devtools/inspector/test/browser_inspector_delete-selected-node-03.js similarity index 90% rename from browser/devtools/inspector/test/browser_inspector_destroyselection.js rename to browser/devtools/inspector/test/browser_inspector_delete-selected-node-03.js index 1a880127900..5d468f5921d 100644 --- a/browser/devtools/inspector/test/browser_inspector_destroyselection.js +++ b/browser/devtools/inspector/test/browser_inspector_delete-selected-node-03.js @@ -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); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_840156_destroy_after_navigation.js b/browser/devtools/inspector/test/browser_inspector_destroy-after-navigation.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_840156_destroy_after_navigation.js rename to browser/devtools/inspector/test/browser_inspector_destroy-after-navigation.js diff --git a/browser/devtools/inspector/test/browser_inspector_cmd_inspect.js b/browser/devtools/inspector/test/browser_inspector_gcli-inspect-command.js similarity index 97% rename from browser/devtools/inspector/test/browser_inspector_cmd_inspect.js rename to browser/devtools/inspector/test/browser_inspector_gcli-inspect-command.js index dcf1961f1d5..da84b088021 100644 --- a/browser/devtools/inspector/test/browser_inspector_cmd_inspect.js +++ b/browser/devtools/inspector/test/browser_inspector_gcli-inspect-command.js @@ -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) { diff --git a/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js b/browser/devtools/inspector/test/browser_inspector_highlighter-01.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_basic_highlighter.js rename to browser/devtools/inspector/test/browser_inspector_highlighter-01.js diff --git a/browser/devtools/inspector/test/browser_inspector_highlighter.js b/browser/devtools/inspector/test/browser_inspector_highlighter-02.js similarity index 97% rename from browser/devtools/inspector/test/browser_inspector_highlighter.js rename to browser/devtools/inspector/test/browser_inspector_highlighter-02.js index 70e9324fdf2..46dcc2f5b2e 100644 --- a/browser/devtools/inspector/test/browser_inspector_highlighter.js +++ b/browser/devtools/inspector/test/browser_inspector_highlighter-02.js @@ -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); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_674871.js b/browser/devtools/inspector/test/browser_inspector_highlighter-03.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_674871.js rename to browser/devtools/inspector/test/browser_inspector_highlighter-03.js diff --git a/browser/devtools/inspector/test/browser_inspector_bug_958456_highlight_comments.js b/browser/devtools/inspector/test/browser_inspector_highlighter-comments.js similarity index 97% rename from browser/devtools/inspector/test/browser_inspector_bug_958456_highlight_comments.js rename to browser/devtools/inspector/test/browser_inspector_highlighter-comments.js index 88c8ea0644a..4e08cb3171f 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_958456_highlight_comments.js +++ b/browser/devtools/inspector/test/browser_inspector_highlighter-comments.js @@ -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); diff --git a/browser/devtools/inspector/test/browser_inspector_iframeTest.js b/browser/devtools/inspector/test/browser_inspector_highlighter-iframes.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_iframeTest.js rename to browser/devtools/inspector/test/browser_inspector_highlighter-iframes.js diff --git a/browser/devtools/inspector/test/browser_inspector_bug_699308_iframe_navigation.js b/browser/devtools/inspector/test/browser_inspector_iframe-navigation.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_699308_iframe_navigation.js rename to browser/devtools/inspector/test/browser_inspector_iframe-navigation.js diff --git a/browser/devtools/inspector/test/browser_inspector_infobar.js b/browser/devtools/inspector/test/browser_inspector_infobar.js index 4845918a4ac..2ad6b591c2f 100644 --- a/browser/devtools/inspector/test/browser_inspector_infobar.js +++ b/browser/devtools/inspector/test/browser_inspector_infobar.js @@ -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 diff --git a/browser/devtools/inspector/test/browser_inspector_bug_665880.js b/browser/devtools/inspector/test/browser_inspector_inspect-object-element.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_665880.js rename to browser/devtools/inspector/test/browser_inspector_inspect-object-element.js diff --git a/browser/devtools/inspector/test/browser_inspector_bug_672902_keyboard_shortcuts.js b/browser/devtools/inspector/test/browser_inspector_keyboard-shortcuts.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_672902_keyboard_shortcuts.js rename to browser/devtools/inspector/test/browser_inspector_keyboard-shortcuts.js diff --git a/browser/devtools/inspector/test/browser_inspector_menu.js b/browser/devtools/inspector/test/browser_inspector_menu.js index 161343070ff..4c53a60449a 100644 --- a/browser/devtools/inspector/test/browser_inspector_menu.js +++ b/browser/devtools/inspector/test/browser_inspector_menu.js @@ -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", diff --git a/browser/devtools/inspector/test/browser_inspector_navigation.js b/browser/devtools/inspector/test/browser_inspector_navigation.js index e28885e98ca..a9949cae7ef 100644 --- a/browser/devtools/inspector/test/browser_inspector_navigation.js +++ b/browser/devtools/inspector/test/browser_inspector_navigation.js @@ -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; diff --git a/browser/devtools/inspector/test/browser_inspector_bug_962478_picker_stops_on_destroy.js b/browser/devtools/inspector/test/browser_inspector_picker-stop-on-destroy.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_962478_picker_stops_on_destroy.js rename to browser/devtools/inspector/test/browser_inspector_picker-stop-on-destroy.js diff --git a/browser/devtools/inspector/test/browser_inspector_bug_961771_picker_stops_on_tool_select.js b/browser/devtools/inspector/test/browser_inspector_picker-stop-on-tool-change.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_961771_picker_stops_on_tool_select.js rename to browser/devtools/inspector/test/browser_inspector_picker-stop-on-tool-change.js diff --git a/browser/devtools/inspector/test/browser_inspector_pseudoclass_lock.js b/browser/devtools/inspector/test/browser_inspector_pseudoclass-lock.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_pseudoclass_lock.js rename to browser/devtools/inspector/test/browser_inspector_pseudoclass-lock.js diff --git a/browser/devtools/inspector/test/browser_inspector_pseudoClass_menu.js b/browser/devtools/inspector/test/browser_inspector_pseudoclass-menu.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_pseudoClass_menu.js rename to browser/devtools/inspector/test/browser_inspector_pseudoclass-menu.js diff --git a/browser/devtools/inspector/test/browser_inspector_dead_node_exception.js b/browser/devtools/inspector/test/browser_inspector_remove-iframe-during-load.js similarity index 94% rename from browser/devtools/inspector/test/browser_inspector_dead_node_exception.js rename to browser/devtools/inspector/test/browser_inspector_remove-iframe-during-load.js index 06874c3a80f..db72a0b35ed 100644 --- a/browser/devtools/inspector/test/browser_inspector_dead_node_exception.js +++ b/browser/devtools/inspector/test/browser_inspector_remove-iframe-during-load.js @@ -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"); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_650804_search.js b/browser/devtools/inspector/test/browser_inspector_search-01.js similarity index 97% rename from browser/devtools/inspector/test/browser_inspector_bug_650804_search.js rename to browser/devtools/inspector/test/browser_inspector_search-01.js index 12aa741ebeb..419979669a2 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_650804_search.js +++ b/browser/devtools/inspector/test/browser_inspector_search-01.js @@ -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 diff --git a/browser/devtools/inspector/test/browser_inspector_bug_831693_combinator_suggestions.js b/browser/devtools/inspector/test/browser_inspector_search-02.js similarity index 97% rename from browser/devtools/inspector/test/browser_inspector_bug_831693_combinator_suggestions.js rename to browser/devtools/inspector/test/browser_inspector_search-02.js index dc4f15c18d7..89b58fc1589 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_831693_combinator_suggestions.js +++ b/browser/devtools/inspector/test/browser_inspector_search-02.js @@ -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. diff --git a/browser/devtools/inspector/test/browser_inspector_bug_831693_input_suggestion.js b/browser/devtools/inspector/test/browser_inspector_search-03.js similarity index 98% rename from browser/devtools/inspector/test/browser_inspector_bug_831693_input_suggestion.js rename to browser/devtools/inspector/test/browser_inspector_search-03.js index e949d322fdc..f69540232bc 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_831693_input_suggestion.js +++ b/browser/devtools/inspector/test/browser_inspector_search-03.js @@ -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. diff --git a/browser/devtools/inspector/test/browser_inspector_bug_831693_searchbox_panel_navigation.js b/browser/devtools/inspector/test/browser_inspector_search-navigation.js similarity index 98% rename from browser/devtools/inspector/test/browser_inspector_bug_831693_searchbox_panel_navigation.js rename to browser/devtools/inspector/test/browser_inspector_search-navigation.js index 4ff05f1493e..ffeed0b88bb 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_831693_searchbox_panel_navigation.js +++ b/browser/devtools/inspector/test/browser_inspector_search-navigation.js @@ -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; diff --git a/browser/devtools/inspector/test/browser_inspector_select_last_selected.js b/browser/devtools/inspector/test/browser_inspector_select-last-selected.js similarity index 93% rename from browser/devtools/inspector/test/browser_inspector_select_last_selected.js rename to browser/devtools/inspector/test/browser_inspector_select-last-selected.js index 3e5620aa0d8..63e4d4d570d 100644 --- a/browser/devtools/inspector/test/browser_inspector_select_last_selected.js +++ b/browser/devtools/inspector/test/browser_inspector_select-last-selected.js @@ -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. diff --git a/browser/devtools/inspector/test/browser_inspector_bug_958169_switch_to_inspector_on_pick.js b/browser/devtools/inspector/test/browser_inspector_switch-to-inspector-on-pick.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_958169_switch_to_inspector_on_pick.js rename to browser/devtools/inspector/test/browser_inspector_switch-to-inspector-on-pick.js diff --git a/browser/devtools/inspector/test/browser_inspector_bug_922125_destroy_on_navigate.js b/browser/devtools/inspector/test/browser_inspector_update-on-navigation.js similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_922125_destroy_on_navigate.js rename to browser/devtools/inspector/test/browser_inspector_update-on-navigation.js diff --git a/browser/devtools/inspector/test/browser_inspector_breadcrumbs.html b/browser/devtools/inspector/test/doc_inspector_breadcrumbs.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_breadcrumbs.html rename to browser/devtools/inspector/test/doc_inspector_breadcrumbs.html diff --git a/browser/devtools/inspector/test/browser_inspector_destroyselection.html b/browser/devtools/inspector/test/doc_inspector_delete-selected-node-01.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_destroyselection.html rename to browser/devtools/inspector/test/doc_inspector_delete-selected-node-01.html diff --git a/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.html b/browser/devtools/inspector/test/doc_inspector_delete-selected-node-02.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.html rename to browser/devtools/inspector/test/doc_inspector_delete-selected-node-02.html diff --git a/browser/devtools/inspector/test/browser_inspector_cmd_inspect.html b/browser/devtools/inspector/test/doc_inspector_gcli-inspect-command.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_cmd_inspect.html rename to browser/devtools/inspector/test/doc_inspector_gcli-inspect-command.html diff --git a/browser/devtools/inspector/test/browser_inspector_bug_958456_highlight_comments.html b/browser/devtools/inspector/test/doc_inspector_highlighter-comments.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_958456_highlight_comments.html rename to browser/devtools/inspector/test/doc_inspector_highlighter-comments.html diff --git a/browser/devtools/inspector/test/browser_inspector_highlighter.html b/browser/devtools/inspector/test/doc_inspector_highlighter.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_highlighter.html rename to browser/devtools/inspector/test/doc_inspector_highlighter.html diff --git a/browser/devtools/inspector/test/browser_inspector_infobar.html b/browser/devtools/inspector/test/doc_inspector_infobar.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_infobar.html rename to browser/devtools/inspector/test/doc_inspector_infobar.html diff --git a/browser/devtools/inspector/test/browser_inspector_menu.html b/browser/devtools/inspector/test/doc_inspector_menu.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_menu.html rename to browser/devtools/inspector/test/doc_inspector_menu.html diff --git a/browser/devtools/inspector/test/browser_inspector_dead_node_exception.html b/browser/devtools/inspector/test/doc_inspector_remove-iframe-during-load.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_dead_node_exception.html rename to browser/devtools/inspector/test/doc_inspector_remove-iframe-during-load.html diff --git a/browser/devtools/inspector/test/browser_inspector_bug_831693_search_suggestions.html b/browser/devtools/inspector/test/doc_inspector_search-suggestions.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_831693_search_suggestions.html rename to browser/devtools/inspector/test/doc_inspector_search-suggestions.html diff --git a/browser/devtools/inspector/test/browser_inspector_bug_650804_search.html b/browser/devtools/inspector/test/doc_inspector_search.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_bug_650804_search.html rename to browser/devtools/inspector/test/doc_inspector_search.html diff --git a/browser/devtools/inspector/test/browser_inspector_select_last_selected.html b/browser/devtools/inspector/test/doc_inspector_select-last-selected-01.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_select_last_selected.html rename to browser/devtools/inspector/test/doc_inspector_select-last-selected-01.html diff --git a/browser/devtools/inspector/test/browser_inspector_select_last_selected2.html b/browser/devtools/inspector/test/doc_inspector_select-last-selected-02.html similarity index 100% rename from browser/devtools/inspector/test/browser_inspector_select_last_selected2.html rename to browser/devtools/inspector/test/doc_inspector_select-last-selected-02.html diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_output-parser.js b/browser/devtools/styleinspector/test/browser_styleinspector_output-parser.js index 0bf9db457b3..30ebb0e7485 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_output-parser.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_output-parser.js @@ -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 })); } diff --git a/browser/modules/Social.jsm b/browser/modules/Social.jsm index 244d5493f98..2376af6acdd 100644 --- a/browser/modules/Social.jsm +++ b/browser/modules/Social.jsm @@ -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]); diff --git a/browser/themes/shared/devtools/webconsole.inc.css b/browser/themes/shared/devtools/webconsole.inc.css index ef1b67c1428..f56ebbeba1b 100644 --- a/browser/themes/shared/devtools/webconsole.inc.css +++ b/browser/themes/shared/devtools/webconsole.inc.css @@ -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); } diff --git a/configure.in b/configure.in index 42ea04f4700..6640aa13753 100644 --- a/configure.in +++ b/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) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index f626fc625b8..387d971edb0 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -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 because the feature name is not supported p->MaybeResolve(JS::UndefinedHandleValue); diff --git a/dom/base/test/test_getFeature_with_perm.html b/dom/base/test/test_getFeature_with_perm.html index 9501c02d3ae..af31a4fec32 100644 --- a/dom/base/test/test_getFeature_with_perm.html +++ b/dom/base/test/test_getFeature_with_perm.html @@ -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"); }); diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 9ce79be09e0..dcabf2bacae 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -173,6 +173,10 @@ DOMInterfaces = { 'nativeType': 'mozilla::dom::bluetooth::BluetoothDiscoveryHandle', }, +'BluetoothClassOfDevice': { + 'nativeType': 'mozilla::dom::bluetooth::BluetoothClassOfDevice', +}, + 'CameraCapabilities': { 'nativeType': 'mozilla::dom::CameraCapabilities', 'headerFile': 'DOMCameraCapabilities.h' diff --git a/dom/bluetooth2/BluetoothClassOfDevice.cpp b/dom/bluetooth2/BluetoothClassOfDevice.cpp new file mode 100644 index 00000000000..fb8abb9a271 --- /dev/null +++ b/dom/bluetooth2/BluetoothClassOfDevice.cpp @@ -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::Create(nsPIDOMWindow* aOwner) +{ + MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(aOwner); + + nsRefPtr cod = new BluetoothClassOfDevice(aOwner); + return cod.forget(); +} + +JSObject* +BluetoothClassOfDevice::WrapObject(JSContext* aCx) +{ + return BluetoothClassOfDeviceBinding::Wrap(aCx, this); +} diff --git a/dom/bluetooth2/BluetoothClassOfDevice.h b/dom/bluetooth2/BluetoothClassOfDevice.h new file mode 100644 index 00000000000..fe8376d7404 --- /dev/null +++ b/dom/bluetooth2/BluetoothClassOfDevice.h @@ -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 + 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 mOwnerWindow; +}; + +END_BLUETOOTH_NAMESPACE + +#endif // mozilla_dom_bluetooth_bluetoothclassofdevice_h diff --git a/dom/bluetooth2/BluetoothProfileController.h b/dom/bluetooth2/BluetoothProfileController.h index 214918dc660..1b5534fa9fb 100644 --- a/dom/bluetooth2/BluetoothProfileController.h +++ b/dom/bluetooth2/BluetoothProfileController.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) diff --git a/dom/bluetooth2/moz.build b/dom/bluetooth2/moz.build index d322f137a42..e41eb706a71 100644 --- a/dom/bluetooth2/moz.build +++ b/dom/bluetooth2/moz.build @@ -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', diff --git a/dom/network/interfaces/moz.build b/dom/network/interfaces/moz.build index fb243fba1be..a078c7b1be2 100644 --- a/dom/network/interfaces/moz.build +++ b/dom/network/interfaces/moz.build @@ -18,7 +18,6 @@ XPIDL_SOURCES += [ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': XPIDL_SOURCES += [ 'nsIDOMNetworkStatsManager.idl', - 'nsIEthernetManager.idl', 'nsINetworkStatsServiceProxy.idl', ] diff --git a/dom/network/interfaces/nsIEthernetManager.idl b/dom/network/interfaces/nsIEthernetManager.idl deleted file mode 100644 index 0fcb30fe309..00000000000 --- a/dom/network/interfaces/nsIEthernetManager.idl +++ /dev/null @@ -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); -}; diff --git a/dom/network/src/EthernetManager.js b/dom/network/src/EthernetManager.js deleted file mode 100644 index 5b7a50ed9a1..00000000000 --- a/dom/network/src/EthernetManager.js +++ /dev/null @@ -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]); diff --git a/dom/network/src/EthernetManager.manifest b/dom/network/src/EthernetManager.manifest deleted file mode 100644 index d25a069e129..00000000000 --- a/dom/network/src/EthernetManager.manifest +++ /dev/null @@ -1,2 +0,0 @@ -component {a96441dd-36b3-4f7f-963b-2c032e28a039} EthernetManager.js -contract @mozilla.org/ethernetManager;1 {a96441dd-36b3-4f7f-963b-2c032e28a039} diff --git a/dom/network/src/moz.build b/dom/network/src/moz.build index d818c5b3562..a3b6096f060 100644 --- a/dom/network/src/moz.build +++ b/dom/network/src/moz.build @@ -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', diff --git a/dom/network/tests/marionette/head.js b/dom/network/tests/marionette/head.js deleted file mode 100644 index cec6ac7d579..00000000000 --- a/dom/network/tests/marionette/head.js +++ /dev/null @@ -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; -})(); \ No newline at end of file diff --git a/dom/network/tests/marionette/manifest.ini b/dom/network/tests/marionette/manifest.ini deleted file mode 100644 index 2273a34b300..00000000000 --- a/dom/network/tests/marionette/manifest.ini +++ /dev/null @@ -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] diff --git a/dom/network/tests/marionette/test_ethernet_add_interface.js b/dom/network/tests/marionette/test_ethernet_add_interface.js deleted file mode 100644 index d628e77054b..00000000000 --- a/dom/network/tests/marionette/test_ethernet_add_interface.js +++ /dev/null @@ -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)); -}); \ No newline at end of file diff --git a/dom/network/tests/marionette/test_ethernet_connect_with_dhcp.js b/dom/network/tests/marionette/test_ethernet_connect_with_dhcp.js deleted file mode 100644 index 57c2df9c2ec..00000000000 --- a/dom/network/tests/marionette/test_ethernet_connect_with_dhcp.js +++ /dev/null @@ -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)); -}); \ No newline at end of file diff --git a/dom/network/tests/marionette/test_ethernet_connect_with_static_ip.js b/dom/network/tests/marionette/test_ethernet_connect_with_static_ip.js deleted file mode 100644 index 3adc37b23ca..00000000000 --- a/dom/network/tests/marionette/test_ethernet_connect_with_static_ip.js +++ /dev/null @@ -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)); -}); \ No newline at end of file diff --git a/dom/network/tests/marionette/test_ethernet_disable.js b/dom/network/tests/marionette/test_ethernet_disable.js deleted file mode 100644 index 9c3525faa34..00000000000 --- a/dom/network/tests/marionette/test_ethernet_disable.js +++ /dev/null @@ -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)); -}); \ No newline at end of file diff --git a/dom/network/tests/marionette/test_ethernet_disconnect.js b/dom/network/tests/marionette/test_ethernet_disconnect.js deleted file mode 100644 index 73f6aa3c5e8..00000000000 --- a/dom/network/tests/marionette/test_ethernet_disconnect.js +++ /dev/null @@ -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)); -}); \ No newline at end of file diff --git a/dom/network/tests/marionette/test_ethernet_enable.js b/dom/network/tests/marionette/test_ethernet_enable.js deleted file mode 100644 index f5578a44f80..00000000000 --- a/dom/network/tests/marionette/test_ethernet_enable.js +++ /dev/null @@ -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)); -}); \ No newline at end of file diff --git a/dom/network/tests/marionette/test_ethernet_ip_mode_change.js b/dom/network/tests/marionette/test_ethernet_ip_mode_change.js deleted file mode 100644 index 5db2049bef7..00000000000 --- a/dom/network/tests/marionette/test_ethernet_ip_mode_change.js +++ /dev/null @@ -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)); -}); \ No newline at end of file diff --git a/dom/network/tests/marionette/test_ethernet_reconnect_with_dhcp.js b/dom/network/tests/marionette/test_ethernet_reconnect_with_dhcp.js deleted file mode 100644 index 4ecc8f09ef5..00000000000 --- a/dom/network/tests/marionette/test_ethernet_reconnect_with_dhcp.js +++ /dev/null @@ -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)); -}); \ No newline at end of file diff --git a/dom/network/tests/marionette/test_ethernet_reconnect_with_static_ip.js b/dom/network/tests/marionette/test_ethernet_reconnect_with_static_ip.js deleted file mode 100644 index 91f25a4710d..00000000000 --- a/dom/network/tests/marionette/test_ethernet_reconnect_with_static_ip.js +++ /dev/null @@ -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)); -}); \ No newline at end of file diff --git a/dom/network/tests/marionette/test_ethernet_remove_interface.js b/dom/network/tests/marionette/test_ethernet_remove_interface.js deleted file mode 100644 index c7fb0e81b88..00000000000 --- a/dom/network/tests/marionette/test_ethernet_remove_interface.js +++ /dev/null @@ -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)); -}); \ No newline at end of file diff --git a/dom/system/gonk/NetworkManager.js b/dom/system/gonk/NetworkManager.js index e440a2344b9..8a087e1b551 100644 --- a/dom/system/gonk/NetworkManager.js +++ b/dom/system/gonk/NetworkManager.js @@ -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; } }, diff --git a/dom/system/gonk/NetworkManager.manifest b/dom/system/gonk/NetworkManager.manifest index 995fa65598e..172af047fa6 100644 --- a/dom/system/gonk/NetworkManager.manifest +++ b/dom/system/gonk/NetworkManager.manifest @@ -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} diff --git a/dom/system/gonk/NetworkService.js b/dom/system/gonk/NetworkService.js index f5a4b39a0a8..b81b7feb857 100644 --- a/dom/system/gonk/NetworkService.js +++ b/dom/system/gonk/NetworkService.js @@ -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) { diff --git a/dom/system/gonk/NetworkService.manifest b/dom/system/gonk/NetworkService.manifest index caf8f2554ff..1e7164d537c 100644 --- a/dom/system/gonk/NetworkService.manifest +++ b/dom/system/gonk/NetworkService.manifest @@ -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} diff --git a/dom/system/gonk/NetworkUtils.cpp b/dom/system/gonk/NetworkUtils.cpp index fbaadbb05eb..59534d31735 100644 --- a/dom/system/gonk/NetworkUtils.cpp +++ b/dom/system/gonk/NetworkUtils.cpp @@ -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& array, #undef CHECK_LEN } -static void convertUTF8toUTF16(nsTArray& narrow, - nsTArray& 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 result; - split(buf, INTERFACE_DELIMIT, result); - - nsTArray 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 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; diff --git a/dom/system/gonk/NetworkUtils.h b/dom/system/gonk/NetworkUtils.h index 7046e400b58..bd722fad261 100644 --- a/dom/system/gonk/NetworkUtils.h +++ b/dom/system/gonk/NetworkUtils.h @@ -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 /** diff --git a/dom/system/gonk/NetworkWorker.cpp b/dom/system/gonk/NetworkWorker.cpp index f2e1c77f928..8d7dfe8be2a 100644 --- a/dom/system/gonk/NetworkWorker.cpp +++ b/dom/system/gonk/NetworkWorker.cpp @@ -18,8 +18,6 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::ipc; -#define PROPERTY_VALUE_MAX 80 - namespace mozilla { nsCOMPtr 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 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 = 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 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 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 runnable = new NetworkCommandDispatcher(NetworkParams); if (gWorkerThread) { gWorkerThread->Dispatch(runnable, nsIEventTarget::DISPATCH_NORMAL); @@ -320,24 +233,6 @@ NetworkWorker::PostMessage(JS::Handle 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 runnable = new RunDhcpEvent(aOptions); - nsCOMPtr thread; - NS_NewThread(getter_AddRefs(thread), runnable); -} - void NetworkWorker::DispatchNetworkResult(const NetworkResultOptions& aOptions) { diff --git a/dom/system/gonk/NetworkWorker.h b/dom/system/gonk/NetworkWorker.h index aa670405236..32b3ae34b08 100644 --- a/dom/system/gonk/NetworkWorker.h +++ b/dom/system/gonk/NetworkWorker.h @@ -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 mListener; }; diff --git a/dom/system/gonk/nsINetworkManager.idl b/dom/system/gonk/nsINetworkManager.idl index 0c33984a2c1..3bf98b60faa 100644 --- a/dom/system/gonk/nsINetworkManager.idl +++ b/dom/system/gonk/nsINetworkManager.idl @@ -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. diff --git a/dom/system/gonk/nsINetworkService.idl b/dom/system/gonk/nsINetworkService.idl index b1680851dc7..eb6cdbf07aa 100644 --- a/dom/system/gonk/nsINetworkService.idl +++ b/dom/system/gonk/nsINetworkService.idl @@ -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); }; diff --git a/dom/webidl/BluetoothClassOfDevice.webidl b/dom/webidl/BluetoothClassOfDevice.webidl new file mode 100644 index 00000000000..c7d3c876d95 --- /dev/null +++ b/dom/webidl/BluetoothClassOfDevice.webidl @@ -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; +}; diff --git a/dom/webidl/NetworkOptions.webidl b/dom/webidl/NetworkOptions.webidl index 47796cdd830..88b149eaf99 100644 --- a/dom/webidl/NetworkOptions.webidl +++ b/dom/webidl/NetworkOptions.webidl @@ -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 interfaceList; // for "getInterfaceList". }; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index ad97ce7324c..167f9170204 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -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', diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in index 41f94d7349c..c7af00fa20c 100644 --- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -92,7 +92,7 @@ -#ifdef MOZ_NATIVE_CASTING +#ifdef MOZ_NATIVE_DEVICES #endif diff --git a/mobile/android/base/AppConstants.java.in b/mobile/android/base/AppConstants.java.in index 4a208026d52..8aca4537d6b 100644 --- a/mobile/android/base/AppConstants.java.in +++ b/mobile/android/base/AppConstants.java.in @@ -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; diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index c7d56426cc6..e4a58399758 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -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()); diff --git a/mobile/android/base/ChromeCast.java b/mobile/android/base/ChromeCast.java index bc327f61479..9e0a1b6ce81 100644 --- a/mobile/android/base/ChromeCast.java +++ b/mobile/android/base/ChromeCast.java @@ -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; } diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index 0258c122fa5..99c9dc54c4c 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -67,7 +67,7 @@ JAVA_BOOTCLASSPATH = \ JAVA_BOOTCLASSPATH := $(subst $(NULL) ,:,$(strip $(JAVA_BOOTCLASSPATH))) # If native devices are enabled, add Google Play Services and some of the v7 compat libraries -ifdef MOZ_NATIVE_CASTING +ifdef MOZ_NATIVE_DEVICES JAVA_CLASSPATH += \ $(GOOGLE_PLAY_SERVICES_LIB) \ $(ANDROID_MEDIAROUTER_LIB) \ @@ -304,7 +304,7 @@ generated/android/support/v7/appcompat/R.java: .aapt.deps ; generated/android/support/v7/mediarouter/R.java: .aapt.deps ; generated/com/google/android/gms/R.java: .aapt.deps ; -ifdef MOZ_NATIVE_CASTING +ifdef MOZ_NATIVE_DEVICES extra_packages += android.support.v7.appcompat extra_res_dirs += $(ANDROID_APPCOMPAT_RES) diff --git a/mobile/android/base/MediaPlayerManager.java b/mobile/android/base/MediaPlayerManager.java index 6107f0b5f2b..878d0c1f76d 100644 --- a/mobile/android/base/MediaPlayerManager.java +++ b/mobile/android/base/MediaPlayerManager.java @@ -5,7 +5,6 @@ package org.mozilla.gecko; import org.mozilla.gecko.util.EventCallback; -import org.mozilla.gecko.mozglue.JNITarget; import org.mozilla.gecko.util.NativeEventListener; import org.mozilla.gecko.util.NativeJSObject; @@ -37,7 +36,7 @@ interface GeckoMediaPlayer { * from Gecko to the correct caster based on the id of the display */ class MediaPlayerManager implements NativeEventListener, - GeckoAppShell.AppStateListener { + GeckoAppShell.AppStateListener { private static final String LOGTAG = "GeckoMediaPlayerManager"; private static final boolean SHOW_DEBUG = false; @@ -59,7 +58,6 @@ class MediaPlayerManager implements NativeEventListener, private final HashMap displays = new HashMap(); private static MediaPlayerManager instance; - @JNITarget public static void init(Context context) { if (instance != null) { debug("MediaPlayerManager initialized twice"); @@ -86,7 +84,6 @@ class MediaPlayerManager implements NativeEventListener, "MediaPlayer:End"); } - @JNITarget public static void onDestroy() { if (instance == null) { return; diff --git a/mobile/android/base/db/BrowserContract.java b/mobile/android/base/db/BrowserContract.java index 0273f49573e..8b4a9348260 100644 --- a/mobile/android/base/db/BrowserContract.java +++ b/mobile/android/base/db/BrowserContract.java @@ -33,6 +33,9 @@ public class BrowserContract { public static final String READING_LIST_AUTHORITY = AppConstants.ANDROID_PACKAGE_NAME + ".db.readinglist"; public static final Uri READING_LIST_AUTHORITY_URI = Uri.parse("content://" + READING_LIST_AUTHORITY); + public static final String SEARCH_HISTORY_AUTHORITY = AppConstants.ANDROID_PACKAGE_NAME + ".db.searchhistory"; + public static final Uri SEARCH_HISTORY_AUTHORITY_URI = Uri.parse("content://" + SEARCH_HISTORY_AUTHORITY); + public static final String PARAM_PROFILE = "profile"; public static final String PARAM_PROFILE_PATH = "profilePath"; public static final String PARAM_LIMIT = "limit"; @@ -433,6 +436,17 @@ public class BrowserContract { public static final String TYPE = "type"; } + @RobocopTarget + public static final class SearchHistory implements CommonColumns, HistoryColumns { + private SearchHistory() {} + + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/searchhistory"; + public static final String QUERY = "query"; + public static final String TABLE_NAME = "searchhistory"; + + public static final Uri CONTENT_URI = Uri.withAppendedPath(SEARCH_HISTORY_AUTHORITY_URI, "searchhistory"); + } + @RobocopTarget public static final class SuggestedSites implements CommonColumns, URLColumns { private SuggestedSites() {} diff --git a/mobile/android/base/db/BrowserDatabaseHelper.java b/mobile/android/base/db/BrowserDatabaseHelper.java index a0cf3d3720e..f0f3a8277a2 100644 --- a/mobile/android/base/db/BrowserDatabaseHelper.java +++ b/mobile/android/base/db/BrowserDatabaseHelper.java @@ -16,6 +16,7 @@ import org.mozilla.gecko.db.BrowserContract.Favicons; import org.mozilla.gecko.db.BrowserContract.History; import org.mozilla.gecko.db.BrowserContract.Obsolete; import org.mozilla.gecko.db.BrowserContract.ReadingListItems; +import org.mozilla.gecko.db.BrowserContract.SearchHistory; import org.mozilla.gecko.db.BrowserContract.Thumbnails; import org.mozilla.gecko.sync.Utils; @@ -34,7 +35,7 @@ import android.util.Log; final class BrowserDatabaseHelper extends SQLiteOpenHelper { private static final String LOGTAG = "GeckoBrowserDBHelper"; - public static final int DATABASE_VERSION = 19; + public static final int DATABASE_VERSION = 20; public static final String DATABASE_NAME = "browser.db"; final protected Context mContext; @@ -758,6 +759,20 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper { createOrUpdateAllSpecialFolders(db); createReadingListTable(db); + createSearchHistoryTable(db); + } + + private void createSearchHistoryTable(SQLiteDatabase db) { + debug("Creating " + SearchHistory.TABLE_NAME + " table"); + + db.execSQL("CREATE TABLE " + SearchHistory.TABLE_NAME + "(" + + SearchHistory._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + SearchHistory.QUERY + " TEXT UNIQUE NOT NULL, " + + SearchHistory.DATE_LAST_VISITED + " INTEGER, " + + SearchHistory.VISITS + " INTEGER ) "); + + db.execSQL("CREATE INDEX idx_search_history_last_visited ON " + + SearchHistory.TABLE_NAME + "(" + SearchHistory.DATE_LAST_VISITED + ")"); } private void createReadingListTable(SQLiteDatabase db) { @@ -1400,6 +1415,10 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper { " WHERE " + Bookmarks.TYPE + " IS NULL"); } + private void upgradeDatabaseFrom19to20(SQLiteDatabase db) { + createSearchHistoryTable(db); + } + private void createV19CombinedView(SQLiteDatabase db) { db.execSQL("DROP VIEW IF EXISTS " + VIEW_COMBINED); db.execSQL("DROP VIEW IF EXISTS " + VIEW_COMBINED_WITH_FAVICONS); @@ -1487,6 +1506,10 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper { case 19: upgradeDatabaseFrom18to19(db); break; + + case 20: + upgradeDatabaseFrom19to20(db); + break; } } @@ -1600,3 +1623,4 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper { } } } + diff --git a/mobile/android/base/db/SearchHistoryProvider.java b/mobile/android/base/db/SearchHistoryProvider.java new file mode 100644 index 00000000000..723187beffb --- /dev/null +++ b/mobile/android/base/db/SearchHistoryProvider.java @@ -0,0 +1,124 @@ +/* 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/. */ + +package org.mozilla.gecko.db; + +import org.mozilla.gecko.db.BrowserContract.SearchHistory; + +import android.content.ContentUris; +import android.content.ContentValues; +import android.database.Cursor; +import android.database.SQLException; +import android.database.sqlite.SQLiteDatabase; +import android.net.Uri; +import android.text.TextUtils; +import android.util.Log; + +public class SearchHistoryProvider extends SharedBrowserDatabaseProvider { + private static final String LOG_TAG = "GeckoSearchProvider"; + private static final boolean DEBUG_ENABLED = false; + + /** + * Collapse whitespace. + */ + private String stripWhitespace(String query) { + if (TextUtils.isEmpty(query)) { + return ""; + } + + // Collapse whitespace + return query.trim().replaceAll("\\s+", " "); + } + + + @Override + public Uri insertInTransaction(Uri uri, ContentValues cv) { + final String query = stripWhitespace(cv.getAsString(SearchHistory.QUERY)); + + // We don't support inserting empty search queries. + if (TextUtils.isEmpty(query)) { + return null; + } + + final SQLiteDatabase db = getWritableDatabase(uri); + long id = -1; + + /* + * Attempt to insert the query. The catch block handles the case when + * the query already exists in the DB. + */ + try { + cv.put(SearchHistory.QUERY, query); + cv.put(SearchHistory.VISITS, 1); + cv.put(SearchHistory.DATE_LAST_VISITED, System.currentTimeMillis()); + + id = db.insertOrThrow(SearchHistory.TABLE_NAME, null, cv); + + if (id > 0) { + return ContentUris.withAppendedId(uri, id); + } + } catch (SQLException e) { + // This happens when the column already exists for this term. + if (DEBUG_ENABLED) { + Log.w(LOG_TAG, String.format("Query `%s` already in db", query)); + } + } + + /* + * Increment the VISITS counter and update the DATE_LAST_VISITED. + */ + final String sql = "UPDATE " + SearchHistory.TABLE_NAME + " SET " + + SearchHistory.VISITS + " = " + SearchHistory.VISITS + " + 1, " + + SearchHistory.DATE_LAST_VISITED + " = " + System.currentTimeMillis() + + " WHERE " + SearchHistory.QUERY + " = ?"; + + final Cursor c = db.rawQuery(sql, new String[] { query }); + + try { + if (c.getCount() > 1) { + // There is a UNIQUE constraint on the QUERY column, + // so there should only be one match. + return null; + } + if (c.moveToFirst()) { + return ContentUris.withAppendedId(uri, c.getInt(c.getColumnIndex(SearchHistory._ID))); + } + } finally { + c.close(); + } + + return null; + } + + @Override + public int deleteInTransaction(Uri uri, String selection, String[] selectionArgs) { + return getWritableDatabase(uri).delete(SearchHistory.TABLE_NAME, + selection, selectionArgs); + } + + /** + * Since we are managing counts and the full-text db, an update + * could mangle the internal state. So we disable it. + */ + @Override + public int updateInTransaction(Uri uri, ContentValues values, String selection, + String[] selectionArgs) { + throw new UnsupportedOperationException("This content provider does not support updating items"); + } + + @Override + public Cursor query(Uri uri, String[] projection, String selection, + String[] selectionArgs, String sortOrder) { + String groupBy = null; + String having = null; + return getReadableDatabase(uri).query(SearchHistory.TABLE_NAME, projection, + selection, selectionArgs, + groupBy, having, sortOrder); + } + + @Override + public String getType(Uri uri) { + return SearchHistory.CONTENT_TYPE; + } +} diff --git a/mobile/android/base/fxa/authenticator/FxAccountAuthenticatorService.java b/mobile/android/base/fxa/authenticator/FxAccountAuthenticatorService.java index b493516c14e..d66163a8161 100644 --- a/mobile/android/base/fxa/authenticator/FxAccountAuthenticatorService.java +++ b/mobile/android/base/fxa/authenticator/FxAccountAuthenticatorService.java @@ -16,7 +16,7 @@ public class FxAccountAuthenticatorService extends Service { // Lazily initialized by getAuthenticator. protected FxAccountAuthenticator accountAuthenticator = null; - protected FxAccountAuthenticator getAuthenticator() { + protected synchronized FxAccountAuthenticator getAuthenticator() { if (accountAuthenticator == null) { accountAuthenticator = new FxAccountAuthenticator(this); } @@ -35,10 +35,21 @@ public class FxAccountAuthenticatorService extends Service { public IBinder onBind(Intent intent) { Logger.debug(LOG_TAG, "onBind"); - if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT)) { - return getAuthenticator().getIBinder(); + if (intent == null) { + // Should never happen, but can -- Bug 1025937. + return null; } - return null; + if (!android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT.equals(intent.getAction())) { + return null; + } + + final FxAccountAuthenticator authenticator = getAuthenticator(); + if (authenticator == null) { + // Should never happen. + return null; + } + + return authenticator.getIBinder(); } } diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index 613af8edfa4..9bc09810801 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -17,7 +17,7 @@ resjar.generated_sources += [ 'org/mozilla/gecko/R.java', ] -if CONFIG['MOZ_NATIVE_CASTING']: +if CONFIG['MOZ_NATIVE_DEVICES']: resjar.generated_sources += ['com/google/android/gms/R.java'] resjar.generated_sources += ['android/support/v7/appcompat/R.java'] resjar.generated_sources += ['android/support/v7/mediarouter/R.java'] @@ -150,6 +150,7 @@ gbjar.sources += [ 'db/PerProfileDatabaseProvider.java', 'db/PerProfileDatabases.java', 'db/ReadingListProvider.java', + 'db/SearchHistoryProvider.java', 'db/SharedBrowserDatabaseProvider.java', 'db/SQLiteBridgeContentProvider.java', 'db/SuggestedSites.java', @@ -473,7 +474,7 @@ gbjar.extra_jars = [ 'websockets.jar', ] -if CONFIG['MOZ_NATIVE_CASTING']: +if CONFIG['MOZ_NATIVE_DEVICES']: gbjar.extra_jars += [CONFIG['ANDROID_APPCOMPAT_LIB']] gbjar.extra_jars += [CONFIG['ANDROID_MEDIAROUTER_LIB']] gbjar.extra_jars += [CONFIG['GOOGLE_PLAY_SERVICES_LIB']] @@ -530,7 +531,7 @@ ANDROID_GENERATED_RESFILES += [ ] for var in ('MOZ_ANDROID_ANR_REPORTER', 'MOZ_LINKER_EXTRACT', 'MOZILLA_OFFICIAL', 'MOZ_DEBUG', - 'MOZ_ANDROID_SEARCH_ACTIVITY', 'MOZ_NATIVE_CASTING'): + 'MOZ_ANDROID_SEARCH_ACTIVITY', 'MOZ_NATIVE_DEVICES'): if CONFIG[var]: DEFINES[var] = 1 @@ -613,7 +614,7 @@ cpe = main.add_classpathentry('src', SRCDIR, 'org/mozilla/gecko/resources/**']) if not CONFIG['MOZ_CRASHREPORTER']: cpe.exclude_patterns += ['org/mozilla/gecko/CrashReporter.java'] -if not CONFIG['MOZ_NATIVE_CASTING']: +if not CONFIG['MOZ_NATIVE_DEVICES']: cpe.exclude_patterns += ['org/mozilla/gecko/ChromeCast.java'] cpe.exclude_patterns += ['org/mozilla/gecko/MediaPlayerManager.java'] main.add_classpathentry('generated', OBJDIR + '/generated', diff --git a/mobile/android/base/resources/layout-large-land-v11/tabs_panel.xml b/mobile/android/base/resources/layout-large-land-v11/tabs_panel.xml index aadc357c10a..e0c61502531 100644 --- a/mobile/android/base/resources/layout-large-land-v11/tabs_panel.xml +++ b/mobile/android/base/resources/layout-large-land-v11/tabs_panel.xml @@ -46,10 +46,11 @@ android:layout_height="match_parent" android:visibility="gone"/> - + diff --git a/mobile/android/base/resources/layout/remote_tabs_panel_view.xml b/mobile/android/base/resources/layout/remote_tabs_panel_view.xml deleted file mode 100644 index 4596acf9caa..00000000000 --- a/mobile/android/base/resources/layout/remote_tabs_panel_view.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/mobile/android/base/resources/layout/tabs_panel.xml b/mobile/android/base/resources/layout/tabs_panel.xml index 6db1974d0f0..efa79b274bc 100644 --- a/mobile/android/base/resources/layout/tabs_panel.xml +++ b/mobile/android/base/resources/layout/tabs_panel.xml @@ -45,11 +45,12 @@ android:layout_height="match_parent" android:visibility="gone"/> + - diff --git a/mobile/android/base/tabspanel/TabsPanel.java b/mobile/android/base/tabspanel/TabsPanel.java index c16f52c6080..b2592c1bc30 100644 --- a/mobile/android/base/tabspanel/TabsPanel.java +++ b/mobile/android/base/tabspanel/TabsPanel.java @@ -31,7 +31,6 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.ViewStub; import android.widget.Button; import android.widget.FrameLayout; import android.widget.ImageButton; @@ -118,7 +117,6 @@ public class TabsPanel extends LinearLayout public void onResume() { if (mPanel == mPanelRemote) { // Refresh the remote panel. - initializeRemotePanelView(); mPanelRemote.show(); } } @@ -143,6 +141,9 @@ public class TabsPanel extends LinearLayout mPanelPrivate = (PanelView) findViewById(R.id.private_tabs_panel); mPanelPrivate.setTabsPanel(this); + mPanelRemote = (PanelView) findViewById(R.id.remote_tabs); + mPanelRemote.setTabsPanel(this); + mFooter = (RelativeLayout) findViewById(R.id.tabs_panel_footer); mAddTab = (ImageButton) findViewById(R.id.add_tab); @@ -412,7 +413,6 @@ public class TabsPanel extends LinearLayout mPanel = mPanelPrivate; break; case REMOTE_TABS: - initializeRemotePanelView(); mPanel = mPanelRemote; break; @@ -561,11 +561,4 @@ public class TabsPanel extends LinearLayout public void setIconDrawable(Panel panel, int resource) { mTabWidget.setIconDrawable(panel.ordinal(), resource); } - - private void initializeRemotePanelView() { - if (mPanelRemote == null) { - mPanelRemote = (PanelView) ((ViewStub) findViewById(R.id.remote_tabs_panel_stub)).inflate(); - mPanelRemote.setTabsPanel(TabsPanel.this); - } - } } diff --git a/mobile/android/base/tests/robocop.ini b/mobile/android/base/tests/robocop.ini index 0c8cc015f69..a0d6b8164f2 100644 --- a/mobile/android/base/tests/robocop.ini +++ b/mobile/android/base/tests/robocop.ini @@ -73,6 +73,7 @@ skip-if = processor == "x86" skip-if = processor == "x86" # [testReaderMode] # see bug 913254, 936224 [testReadingListProvider] +[testSearchHistoryProvider] [testSearchSuggestions] # disabled on x86; bug 907768 skip-if = processor == "x86" diff --git a/mobile/android/base/tests/testSearchHistoryProvider.java b/mobile/android/base/tests/testSearchHistoryProvider.java new file mode 100644 index 00000000000..c1d487706ba --- /dev/null +++ b/mobile/android/base/tests/testSearchHistoryProvider.java @@ -0,0 +1,302 @@ +/* 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/. */ + +package org.mozilla.gecko.tests; + +import java.util.concurrent.Callable; + +import org.mozilla.gecko.db.BrowserContract; +import org.mozilla.gecko.db.BrowserContract.SearchHistory; +import org.mozilla.gecko.db.SearchHistoryProvider; + +import android.content.ContentProvider; +import android.content.ContentValues; +import android.database.Cursor; + +public class testSearchHistoryProvider extends ContentProviderTest { + + // Translations of "United Kingdom" in several different languages + private static final String[] testStrings = {"An Ríocht Aontaithe", // Irish + "Angli", // Albanian + "Britanniarum Regnum", // Latin + "Britio", // Esperanto + "Büyük Britanya", // Turkish + "Egyesült Királyság", // Hungarian + "Erresuma Batua", // Basque + "Inggris Raya", // Indonesian + "Ir-Renju Unit", // Maltese + "Iso-Britannia", // Finnish + "Jungtinė Karalystė", // Lithuanian + "Lielbritānija", // Latvian + "Regatul Unit", // Romanian + "Regne Unit", // Catalan, Valencian + "Regno Unito", // Italian + "Royaume-Uni", // French + "Spojené království", // Czech + "Spojené kráľovstvo", // Slovak + "Storbritannia", // Norwegian + "Storbritannien", // Danish + "Suurbritannia", // Estonian + "Ujedinjeno Kraljevstvo", // Bosnian + "United Alaeze", // Igbo + "United Kingdom", // English + "Vereinigtes Königreich", // German + "Verenigd Koninkrijk", // Dutch + "Verenigde Koninkryk", // Afrikaans + "Vương quốc Anh", // Vietnamese + "Wayòm Ini", // Haitian, Haitian Creole + "Y Deyrnas Unedig", // Welsh + "Združeno kraljestvo", // Slovene + "Zjednoczone Królestwo", // Polish + "Ηνωμένο Βασίλειο", // Greek (modern) + "Великобритания", // Russian + "Нэгдсэн Вант Улс", // Mongolian + "Обединетото Кралство", // Macedonian + "Уједињено Краљевство", // Serbian + "Միացյալ Թագավորություն", // Armenian + "בריטניה", // Hebrew (modern) + "פֿאַראייניקטע מלכות", // Yiddish + "المملكة المتحدة", // Arabic + "برطانیہ", // Urdu + "پادشاهی متحده", // Persian (Farsi) + "यूनाइटेड किंगडम", // Hindi + "संयुक्त राज्य", // Nepali + "যুক্তরাজ্য", // Bengali, Bangla + "યુનાઇટેડ કિંગડમ", // Gujarati + "ஐக்கிய ராஜ்யம்", // Tamil + "สหราชอาณาจักร", // Thai + "ສະ​ຫະ​ປະ​ຊາ​ຊະ​ອາ​ນາ​ຈັກ", // Lao + "გაერთიანებული სამეფო", // Georgian + "イギリス", // Japanese + "联合王国" // Chinese + }; + + + private static final String DB_NAME = "searchhistory.db"; + + /** + * Boilerplate alert. + *

+ * Make sure this method is present and that it returns a new + * instance of your class. + */ + private static Callable sProviderFactory = + new Callable() { + @Override + public ContentProvider call() { + return new SearchHistoryProvider(); + } + }; + + @Override + public void setUp() throws Exception { + super.setUp(sProviderFactory, BrowserContract.SEARCH_HISTORY_AUTHORITY, DB_NAME); + mTests.add(new TestInsert()); + mTests.add(new TestUnicodeQuery()); + mTests.add(new TestTimestamp()); + mTests.add(new TestDelete()); + mTests.add(new TestIncrement()); + } + + public void testSearchHistory() throws Exception { + for (Runnable test : mTests) { + String testName = test.getClass().getSimpleName(); + setTestName(testName); + mAsserter.dumpLog( + "testBrowserProvider: Database empty - Starting " + testName + "."); + // Clear the db + mProvider.delete(SearchHistory.CONTENT_URI, null, null); + test.run(); + } + } + + /** + * Verify that we can insert values into the DB, including unicode. + */ + private class TestInsert extends TestCase { + @Override + public void test() throws Exception { + ContentValues cv; + for (int i = 0; i < testStrings.length; i++) { + cv = new ContentValues(); + cv.put(SearchHistory.QUERY, testStrings[i]); + mProvider.insert(SearchHistory.CONTENT_URI, cv); + } + + final Cursor c = mProvider.query(SearchHistory.CONTENT_URI, null, null, null, null); + try { + mAsserter.is(c.getCount(), testStrings.length, + "Should have one row for each insert"); + } finally { + c.close(); + } + } + } + + /** + * Verify that we can insert values into the DB, including unicode. + */ + private class TestUnicodeQuery extends TestCase { + @Override + public void test() throws Exception { + final String selection = SearchHistory.QUERY + " = ?"; + + for (int i = 0; i < testStrings.length; i++) { + final ContentValues cv = new ContentValues(); + cv.put(SearchHistory.QUERY, testStrings[i]); + mProvider.insert(SearchHistory.CONTENT_URI, cv); + + final Cursor c = mProvider.query(SearchHistory.CONTENT_URI, null, selection, + new String[]{ testStrings[i] }, null); + try { + mAsserter.is(c.getCount(), 1, + "Should have one row for insert of " + testStrings[i]); + } finally { + c.close(); + } + } + } + } + + /** + * Verify that timestamps are updated on insert. + */ + private class TestTimestamp extends TestCase { + @Override + public void test() throws Exception { + String insertedTerm = "Courtside Seats"; + long insertStart; + long insertFinish; + long t1Db; + long t2Db; + + ContentValues cv = new ContentValues(); + cv.put(SearchHistory.QUERY, insertedTerm); + + // First check that the DB has a value that is close to the + // system time. + insertStart = System.currentTimeMillis(); + mProvider.insert(SearchHistory.CONTENT_URI, cv); + insertFinish = System.currentTimeMillis(); + + final Cursor c1 = mProvider.query(SearchHistory.CONTENT_URI, null, null, null, null); + try { + c1.moveToFirst(); + t1Db = c1.getLong(c1.getColumnIndex(SearchHistory.DATE_LAST_VISITED)); + } finally { + c1.close(); + } + + mAsserter.dumpLog("First insert:"); + mAsserter.dumpLog(" insertStart " + insertStart); + mAsserter.dumpLog(" insertFinish " + insertFinish); + mAsserter.dumpLog(" t1Db " + t1Db); + mAsserter.ok(t1Db >= insertStart, "DATE_LAST_VISITED", + "Date last visited should be set on insert."); + mAsserter.ok(t1Db <= insertFinish, "DATE_LAST_VISITED", + "Date last visited should be set on insert."); + + cv = new ContentValues(); + cv.put(SearchHistory.QUERY, insertedTerm); + + insertStart = System.currentTimeMillis(); + mProvider.insert(SearchHistory.CONTENT_URI, cv); + insertFinish = System.currentTimeMillis(); + + final Cursor c2 = mProvider.query(SearchHistory.CONTENT_URI, null, null, null, null); + try { + c2.moveToFirst(); + t2Db = c2.getLong(c2.getColumnIndex(SearchHistory.DATE_LAST_VISITED)); + } finally { + c2.close(); + } + + mAsserter.dumpLog("Second insert:"); + mAsserter.dumpLog(" insertStart " + insertStart); + mAsserter.dumpLog(" insertFinish " + insertFinish); + mAsserter.dumpLog(" t2Db " + t2Db); + + mAsserter.ok(t2Db >= insertStart, "DATE_LAST_VISITED", + "Date last visited should be set on insert."); + mAsserter.ok(t2Db <= insertFinish, "DATE_LAST_VISITED", + "Date last visited should be set on insert."); + mAsserter.ok(t2Db >= t1Db, "DATE_LAST_VISITED", + "Date last visited should be updated on key increment."); + } + } + + /** + * Verify that sending a delete command empties the database. + */ + private class TestDelete extends TestCase { + @Override + public void test() throws Exception { + String insertedTerm = "Courtside Seats"; + + ContentValues cv = new ContentValues(); + cv.put(SearchHistory.QUERY, insertedTerm); + mProvider.insert(SearchHistory.CONTENT_URI, cv); + + final Cursor c1 = mProvider.query(SearchHistory.CONTENT_URI, null, null, null, null); + try { + mAsserter.is(c1.getCount(), 1, "Should have one value"); + mProvider.delete(SearchHistory.CONTENT_URI, null, null); + } finally { + c1.close(); + } + + final Cursor c2 = mProvider.query(SearchHistory.CONTENT_URI, null, null, null, null); + try { + mAsserter.is(c2.getCount(), 0, "Should be empty"); + mProvider.insert(SearchHistory.CONTENT_URI, cv); + } finally { + c2.close(); + } + + final Cursor c3 = mProvider.query(SearchHistory.CONTENT_URI, null, null, null, null); + try { + mAsserter.is(c3.getCount(), 1, "Should have one value"); + } finally { + c3.close(); + } + } + } + + + /** + * Ensure that we only increment when the case matches. + */ + private class TestIncrement extends TestCase { + @Override + public void test() throws Exception { + ContentValues cv = new ContentValues(); + cv.put(SearchHistory.QUERY, "omaha"); + mProvider.insert(SearchHistory.CONTENT_URI, cv); + + cv = new ContentValues(); + cv.put(SearchHistory.QUERY, "omaha"); + mProvider.insert(SearchHistory.CONTENT_URI, cv); + + Cursor c = mProvider.query(SearchHistory.CONTENT_URI, null, null, null, null); + try { + c.moveToFirst(); + mAsserter.is(c.getCount(), 1, "Should have one result"); + mAsserter.is(c.getInt(c.getColumnIndex(SearchHistory.VISITS)), 2, + "Counter should be 2"); + } finally { + c.close(); + } + + cv = new ContentValues(); + cv.put(SearchHistory.QUERY, "Omaha"); + mProvider.insert(SearchHistory.CONTENT_URI, cv); + c = mProvider.query(SearchHistory.CONTENT_URI, null, null, null, null); + try { + mAsserter.is(c.getCount(), 2, "Should have two results"); + } finally { + c.close(); + } + } + } +} diff --git a/mobile/android/config/mozconfigs/common b/mobile/android/config/mozconfigs/common index ffb5063e9b0..1f90a0f0e9a 100644 --- a/mobile/android/config/mozconfigs/common +++ b/mobile/android/config/mozconfigs/common @@ -32,7 +32,6 @@ ac_add_options --with-android-gnu-compiler-version=4.7 ac_add_options --with-android-version=9 ac_add_options --with-system-zlib ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL} -ac_add_options --disable-native-casting # Disable native casting support until the builders are updated # Treat warnings as errors in directories with FAIL_ON_WARNINGS. ac_add_options --enable-warnings-as-errors diff --git a/mobile/android/confvars.sh b/mobile/android/confvars.sh index ff1ea3bb972..c2f3a3a1be9 100644 --- a/mobile/android/confvars.sh +++ b/mobile/android/confvars.sh @@ -69,5 +69,8 @@ MOZ_LOCALE_SWITCHER=1 # Enable second screen and casting support for external devices. MOZ_DEVICES=1 +# Enable second screen using native Android libraries +MOZ_NATIVE_DEVICES= + # Don't enable the Search Activity. # MOZ_ANDROID_SEARCH_ACTIVITY=1 diff --git a/testing/marionette/client/marionette/tests/unit-tests.ini b/testing/marionette/client/marionette/tests/unit-tests.ini index b5acd0902b2..b8f222b818c 100644 --- a/testing/marionette/client/marionette/tests/unit-tests.ini +++ b/testing/marionette/client/marionette/tests/unit-tests.ini @@ -28,7 +28,6 @@ skip = false [include:../../../../../dom/events/test/marionette/manifest.ini] [include:../../../../../dom/wifi/test/marionette/manifest.ini] [include:../../../../../dom/cellbroadcast/tests/marionette/manifest.ini] -[include:../../../../../dom/network/tests/marionette/manifest.ini] ; layout tests [include:../../../../../layout/base/tests/marionette/manifest.ini] diff --git a/toolkit/devtools/output-parser.js b/toolkit/devtools/output-parser.js index 737fb5fff27..ea1f0085ca4 100644 --- a/toolkit/devtools/output-parser.js +++ b/toolkit/devtools/output-parser.js @@ -15,6 +15,7 @@ const REGEX_QUOTES = /^".*?"|^".*|^'.*?'|^'.*/; const REGEX_WHITESPACE = /^\s+/; const REGEX_FIRST_WORD_OR_CHAR = /^\w+|^./; const REGEX_CSS_PROPERTY_VALUE = /(^[^;]+)/; +const REGEX_CUBIC_BEZIER = /^linear|^ease-in-out|^ease-in|^ease-out|^ease|^cubic-bezier\(([0-9.\- ]+,){3}[0-9.\- ]+\)/; /** * This regex matches: @@ -92,6 +93,11 @@ OutputParser.prototype = { parseCssProperty: function(name, value, options={}) { options = this._mergeOptions(options); + // XXX: This is a quick fix that should stay until bug 977063 gets fixed. + // It avoids parsing "linear" as a timing-function in "linear-gradient(...)" + options.expectCubicBezier = ["transition", "transition-timing-function", + "animation", "animation-timing-function"].indexOf(name) !== -1; + if (this._cssPropertySupportsValue(name, value)) { return this._parse(value, options); } @@ -200,6 +206,17 @@ OutputParser.prototype = { continue; } + if (options.expectCubicBezier) { + matched = text.match(REGEX_CUBIC_BEZIER); + if (matched) { + let match = matched[0]; + text = this._trimMatchFromStart(text, match); + + this._appendCubicBezier(match, options); + continue; + } + } + matched = text.match(REGEX_ALL_CSS_PROPERTIES); if (matched) { let [match] = matched; @@ -282,6 +299,35 @@ OutputParser.prototype = { return [text, dirty]; }, + /** + * Append a cubic-bezier timing function value to the output + * + * @param {String} bezier + * The cubic-bezier timing function + * @param {Object} options + * Options object. For valid options and default values see + * _mergeOptions() + */ + _appendCubicBezier: function(bezier, options) { + let container = this._createNode("span", { + "data-bezier": bezier + }); + + if (options.bezierSwatchClass) { + let swatch = this._createNode("span", { + class: options.bezierSwatchClass + }); + container.appendChild(swatch); + } + + let value = this._createNode("span", { + class: options.bezierClass + }, bezier); + + container.appendChild(value); + this.parsed.push(container); + }, + /** * Check if a CSS property supports a specific value. * @@ -489,6 +535,9 @@ OutputParser.prototype = { * - colorSwatchClass: "" // The class to use for color swatches. * - colorClass: "" // The class to use for the color value * // that follows the swatch. + * - bezierSwatchClass: "" // The class to use for bezier swatches. + * - bezierClass: "" // The class to use for the bezier value + * // that follows the swatch. * - isHTMLAttribute: false // This property indicates whether we * // are parsing an HTML attribute value. * // When the value is passed in from an @@ -507,6 +556,8 @@ OutputParser.prototype = { defaultColorType: true, colorSwatchClass: "", colorClass: "", + bezierSwatchClass: "", + bezierClass: "", isHTMLAttribute: false, urlClass: "", baseURI: "" diff --git a/toolkit/modules/NewTabUtils.jsm b/toolkit/modules/NewTabUtils.jsm index 22ad638bd3b..7d294a04dea 100644 --- a/toolkit/modules/NewTabUtils.jsm +++ b/toolkit/modules/NewTabUtils.jsm @@ -573,9 +573,7 @@ let PlacesProvider = { title: title, frecency: frecency, lastVisitDate: lastVisitDate, - bgColor: "transparent", type: "history", - imageURI: null, }); } } @@ -650,6 +648,7 @@ let PlacesProvider = { url: aURI.spec, frecency: aNewFrecency, lastVisitDate: aLastVisitDate, + type: "history", }); } }, diff --git a/toolkit/modules/PropertyListUtils.jsm b/toolkit/modules/PropertyListUtils.jsm index e30ca3a33bf..5c21cb0fc2a 100644 --- a/toolkit/modules/PropertyListUtils.jsm +++ b/toolkit/modules/PropertyListUtils.jsm @@ -408,6 +408,14 @@ BinaryPropertyListReader.prototype = { else if (aIntSize == 2) { uints.push(this._dataView.getUint16(offset)); } + else if (aIntSize == 3) { + let int24 = Uint8Array(4); + int24[3] = 0; + int24[2] = this._dataView.getUint8(offset); + int24[1] = this._dataView.getUint8(offset + 1); + int24[0] = this._dataView.getUint8(offset + 2); + uints.push(Uint32Array(int24.buffer)[0]); + } else if (aIntSize == 4) { uints.push(this._dataView.getUint32(offset)); }