merge fx-team to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2014-12-17 12:50:10 +01:00
commit 6072d6a564
255 changed files with 5078 additions and 4672 deletions

View File

@ -404,6 +404,8 @@ pref("browser.search.order.1", "chrome://browser-region/locale/re
pref("browser.search.order.2", "chrome://browser-region/locale/region.properties");
pref("browser.search.order.3", "chrome://browser-region/locale/region.properties");
// Market-specific search defaults (US market only)
pref("browser.search.geoSpecificDefaults", true);
pref("browser.search.defaultenginename.US", "data:text/plain,browser.search.defaultenginename.US=Yahoo");
pref("browser.search.order.US.1", "data:text/plain,browser.search.order.US.1=Yahoo");
pref("browser.search.order.US.2", "data:text/plain,browser.search.order.US.2=Google");

View File

@ -133,9 +133,7 @@ var tabPreviewPanelHelper = {
host.suspendGUI();
if (host._prevFocus) {
Cc["@mozilla.org/focus-manager;1"]
.getService(Ci.nsIFocusManager)
.setFocus(host._prevFocus, Ci.nsIFocusManager.FLAG_NOSCROLL);
Services.focus.setFocus(host._prevFocus, Ci.nsIFocusManager.FLAG_NOSCROLL);
host._prevFocus = null;
} else
gBrowser.selectedBrowser.focus();
@ -503,9 +501,14 @@ var ctrlTab = {
},
filterForThumbnailExpiration: function (aCallback) {
// Save a few more thumbnails than we actually display, so that when tabs
// are closed, the previews we add instead still get thumbnails.
const extraThumbnails = 3;
const thumbnailCount = Math.min(this.tabPreviewCount + extraThumbnails,
this.tabCount);
let urls = [];
let previewCount = this.tabPreviewCount;
for (let i = 0; i < previewCount; i++)
for (let i = 0; i < thumbnailCount; i++)
urls.push(this.tabList[i].linkedBrowser.currentURI.spec);
aCallback(urls);

View File

@ -143,7 +143,7 @@ var FullScreen = {
return;
}
let focusManager = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
let focusManager = Services.focus;
if (focusManager.activeWindow != window) {
// The top-level window has lost focus since the request to enter
// full-screen was made. Cancel full-screen.

View File

@ -67,7 +67,7 @@ let gFxAccounts = {
},
get isActiveWindow() {
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
let fm = Services.focus;
return fm.activeWindow == window;
},

View File

@ -205,20 +205,20 @@ let gInitialPages = [
];
#include browser-addons.js
#include browser-ctrlTab.js
#include browser-customization.js
#include browser-devedition.js
#include browser-feeds.js
#include browser-fullScreen.js
#include browser-fullZoom.js
#include browser-gestureSupport.js
#include browser-loop.js
#include browser-places.js
#include browser-plugins.js
#include browser-safebrowsing.js
#include browser-social.js
#include browser-tabPreviews.js
#include browser-tabview.js
#include browser-thumbnails.js
#include browser-gestureSupport.js
#ifdef MOZ_DATA_REPORTING
#include browser-data-submission-info-bar.js
@ -6970,7 +6970,7 @@ var gIdentityHandler = {
// Chrome URIs however get special treatment. Some chrome URIs are
// whitelisted to provide a positive security signal to the user.
let whitelist = /^about:(accounts|addons|app-manager|config|crashes|customizing|healthreport|home|license|newaddon|permissions|preferences|privatebrowsing|rights|sessionrestore|support|welcomeback)/i;
let whitelist = /^about:(accounts|addons|app-manager|config|crashes|customizing|downloads|healthreport|home|license|newaddon|permissions|preferences|privatebrowsing|rights|sessionrestore|support|welcomeback)/i;
let isChromeUI = uri.schemeIs("about") && whitelist.test(uri.spec);
if (isChromeUI) {
this.setMode(this.IDENTITY_MODE_CHROMEUI);
@ -7463,8 +7463,10 @@ let gRemoteTabsUI = {
* This object also allows:
* - 'ignoreFragment' property to be set to true to exclude fragment-portion
* matching when comparing URIs.
* - 'ignoreQueryString' property to be set to true to exclude query string
* matching when comparing URIs.
* - 'replaceQueryString' property to be set to true to exclude query string
* matching when comparing URIs and ovewrite the initial query string with
* matching when comparing URIs and overwrite the initial query string with
* the one from the new URI.
* @return True if an existing tab was found, false otherwise
*/
@ -7476,11 +7478,13 @@ function switchToTabHavingURI(aURI, aOpenNew, aOpenParams={}) {
]);
let ignoreFragment = aOpenParams.ignoreFragment;
let ignoreQueryString = aOpenParams.ignoreQueryString;
let replaceQueryString = aOpenParams.replaceQueryString;
// This property is only used by switchToTabHavingURI and should
// These properties are only used by switchToTabHavingURI and should
// not be used as a parameter for the new load.
delete aOpenParams.ignoreFragment;
delete aOpenParams.ignoreQueryString;
// This will switch to the tab in aWindow having aURI, if present.
function switchIfURIInWindow(aWindow) {
@ -7509,12 +7513,14 @@ function switchToTabHavingURI(aURI, aOpenNew, aOpenParams={}) {
}
return true;
}
if (replaceQueryString) {
if (ignoreQueryString || replaceQueryString) {
if (browser.currentURI.spec.split("?")[0] == aURI.spec.split("?")[0]) {
// Focus the matching window & tab
aWindow.focus();
aWindow.gBrowser.tabContainer.selectedIndex = i;
browser.loadURI(aURI.spec);
if (replaceQueryString) {
browser.loadURI(aURI.spec);
}
return true;
}
}

View File

@ -1262,7 +1262,7 @@
return;
}
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
let fm = Services.focus;
let focusFlags = fm.FLAG_NOSCROLL;
if (!gMultiProcessBrowser) {

View File

@ -111,23 +111,16 @@ skip-if = os == "linux" # Bug 924307
skip-if = e10s # Bug 1093153 - no about:home support yet
[browser_aboutSyncProgress.js]
[browser_action_keyword.js]
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_action_searchengine.js]
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_action_searchengine_alias.js]
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_addKeywordSearch.js]
[browser_search_favicon.js]
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_alltabslistener.js]
[browser_autocomplete_a11y_label.js]
skip-if = e10s # Bug 1101993 - times out for unknown reasons when run in the dir (works on its own)
[browser_autocomplete_no_title.js]
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_autocomplete_autoselect.js]
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_autocomplete_oldschool_wrap.js]
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_backButtonFitts.js]
skip-if = os != "win" || e10s # The Fitts Law back button is only supported on Windows (bug 571454) / e10s - Bug 1099154: test touches content (attempts to add an event listener directly to the contentWindow)
[browser_blob-channelname.js]
@ -293,7 +286,6 @@ skip-if = e10s # Bug 1093155 - tries to use context menu from browser-chrome and
skip-if = os == 'win' || e10s # Bug 1056146 - zoom tests use FullZoomHelper and break in e10s
[browser_bug1064280_changeUrlInPinnedTab.js]
[browser_bug1070778.js]
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_canonizeURL.js]
skip-if = e10s # Bug 1094510 - test hits the network in e10s mode only
[browser_contentAreaClick.js]
@ -450,6 +442,8 @@ skip-if = e10s # Bug 1093941 - Waits indefinitely for onSearchComplete
[browser_urlbarCopying.js]
[browser_urlbarEnter.js]
skip-if = e10s # Bug 1093941 - used to cause obscure non-windows child process crashes on try
[browser_urlbarEnterAfterMouseOver.js]
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_urlbarRevert.js]
skip-if = e10s # Bug 1093941 - ESC reverted the location bar value - Got foobar, expected example.com
[browser_urlbarSearchSingleWordNotification.js]
@ -482,7 +476,7 @@ skip-if = e10s # Bug 940206 - nsIWebContentHandlerRegistrar::registerProtocolHan
skip-if = e10s
[browser_bug1024133-switchtab-override-keynav.js]
skip-if = e10s
[browser_bug1025195_switchToTabHavingURI_ignoreFragment.js]
[browser_bug1025195_switchToTabHavingURI_aOpenParams.js]
[browser_addCertException.js]
skip-if = e10s # Bug 1100687 - test directly manipulates content (content.document.getElementById)
[browser_bug1045809.js]

View File

@ -1,91 +1,88 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let gOnSearchComplete = null;
function* promise_first_result(inputText) {
gURLBar.focus();
gURLBar.value = inputText.slice(0, -1);
EventUtils.synthesizeKey(inputText.slice(-1) , {});
yield promiseSearchComplete();
let firstResult = gURLBar.popup.richlistbox.firstChild;
return firstResult;
}
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla");
let tabs = [tab];
registerCleanupFunction(() => {
for (let tab of tabs)
gBrowser.removeTab(tab);
PlacesUtils.bookmarks.removeItem(itemId);
});
yield promiseTabLoadEvent(tab);
let itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/?q=%s"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"test");
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
let result = yield promise_first_result("keyword something");
isnot(result, null, "Expect a keyword result");
is(result.getAttribute("type"), "action keyword", "Expect correct `type` attribute");
is(result.getAttribute("actiontype"), "keyword", "Expect correct `actiontype` attribute");
is(result.getAttribute("title"), "test", "Expect correct title");
// We need to make a real URI out of this to ensure it's normalised for
// comparison.
let uri = NetUtil.newURI(result.getAttribute("url"));
is(uri.spec, makeActionURI("keyword", {url: "http://example.com/?q=something", input: "keyword something"}).spec, "Expect correct url");
is_element_visible(result._title, "Title element should be visible");
is(result._title.childNodes.length, 1, "Title element should have 1 child");
is(result._title.childNodes[0].nodeName, "#text", "That child should be a text node");
is(result._title.childNodes[0].data, "test", "Node should contain the name of the bookmark");
is_element_visible(result._extra, "Extra element should be visible");
is(result._extra.childNodes.length, 1, "Title element should have 1 child");
is(result._extra.childNodes[0].nodeName, "span", "That child should be a span node");
let span = result._extra.childNodes[0];
is(span.childNodes.length, 1, "span element should have 1 child");
is(span.childNodes[0].nodeName, "#text", "That child should be a text node");
is(span.childNodes[0].data, "something", "Node should contain the query for the keyword");
is_element_hidden(result._url, "URL element should be hidden");
// Click on the result
info("Normal click on result");
let tabPromise = promiseTabLoadEvent(tab);
EventUtils.synthesizeMouseAtCenter(result, {});
let loadEvent = yield tabPromise;
is(loadEvent.target.location.href, "http://example.com/?q=something", "Tab should have loaded from clicking on result");
// Middle-click on the result
info("Middle-click on result");
result = yield promise_first_result("keyword somethingmore");
isnot(result, null, "Expect a keyword result");
// We need to make a real URI out of this to ensure it's normalised for
// comparison.
uri = NetUtil.newURI(result.getAttribute("url"));
is(uri.spec, makeActionURI("keyword", {url: "http://example.com/?q=somethingmore", input: "keyword somethingmore"}).spec, "Expect correct url");
tabPromise = promiseWaitForEvent(gBrowser.tabContainer, "TabOpen");
EventUtils.synthesizeMouseAtCenter(result, {button: 1});
let tabOpenEvent = yield tabPromise;
let newTab = tabOpenEvent.target;
tabs.push(newTab);
loadEvent = yield promiseTabLoadEvent(newTab);
is(loadEvent.target.location.href, "http://example.com/?q=somethingmore", "Tab should have loaded from middle-clicking on result");
});
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let gOnSearchComplete = null;
function* promise_first_result(inputText) {
yield promiseAutocompleteResultPopup(inputText);
let firstResult = gURLBar.popup.richlistbox.firstChild;
return firstResult;
}
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla");
let tabs = [tab];
registerCleanupFunction(() => {
for (let tab of tabs)
gBrowser.removeTab(tab);
PlacesUtils.bookmarks.removeItem(itemId);
});
yield promiseTabLoadEvent(tab);
let itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/?q=%s"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"test");
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
let result = yield promise_first_result("keyword something");
isnot(result, null, "Expect a keyword result");
is(result.getAttribute("type"), "action keyword", "Expect correct `type` attribute");
is(result.getAttribute("actiontype"), "keyword", "Expect correct `actiontype` attribute");
is(result.getAttribute("title"), "test", "Expect correct title");
// We need to make a real URI out of this to ensure it's normalised for
// comparison.
let uri = NetUtil.newURI(result.getAttribute("url"));
is(uri.spec, makeActionURI("keyword", {url: "http://example.com/?q=something", input: "keyword something"}).spec, "Expect correct url");
is_element_visible(result._title, "Title element should be visible");
is(result._title.childNodes.length, 1, "Title element should have 1 child");
is(result._title.childNodes[0].nodeName, "#text", "That child should be a text node");
is(result._title.childNodes[0].data, "test", "Node should contain the name of the bookmark");
is_element_visible(result._extra, "Extra element should be visible");
is(result._extra.childNodes.length, 1, "Title element should have 1 child");
is(result._extra.childNodes[0].nodeName, "span", "That child should be a span node");
let span = result._extra.childNodes[0];
is(span.childNodes.length, 1, "span element should have 1 child");
is(span.childNodes[0].nodeName, "#text", "That child should be a text node");
is(span.childNodes[0].data, "something", "Node should contain the query for the keyword");
is_element_hidden(result._url, "URL element should be hidden");
// Click on the result
info("Normal click on result");
let tabPromise = promiseTabLoadEvent(tab);
EventUtils.synthesizeMouseAtCenter(result, {});
let loadEvent = yield tabPromise;
is(loadEvent.target.location.href, "http://example.com/?q=something", "Tab should have loaded from clicking on result");
// Middle-click on the result
info("Middle-click on result");
result = yield promise_first_result("keyword somethingmore");
isnot(result, null, "Expect a keyword result");
// We need to make a real URI out of this to ensure it's normalised for
// comparison.
uri = NetUtil.newURI(result.getAttribute("url"));
is(uri.spec, makeActionURI("keyword", {url: "http://example.com/?q=somethingmore", input: "keyword somethingmore"}).spec, "Expect correct url");
tabPromise = promiseWaitForEvent(gBrowser.tabContainer, "TabOpen");
EventUtils.synthesizeMouseAtCenter(result, {button: 1});
let tabOpenEvent = yield tabPromise;
let newTab = tabOpenEvent.target;
tabs.push(newTab);
loadEvent = yield promiseTabLoadEvent(newTab);
is(loadEvent.target.location.href, "http://example.com/?q=somethingmore", "Tab should have loaded from middle-clicking on result");
});

View File

@ -1,58 +1,46 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let gOriginalEngine;
function* promise_first_result(inputText) {
gURLBar.focus();
gURLBar.value = inputText.slice(0, -1);
EventUtils.synthesizeKey(inputText.slice(-1) , {});
yield promiseSearchComplete();
// On Linux, the popup may or may not be open at this stage. So we need
// additional checks to ensure we wait long enough.
yield promisePopupShown(gURLBar.popup);
let firstResult = gURLBar.popup.richlistbox.firstChild;
return firstResult;
}
add_task(function* () {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET",
"http://example.com/?q={searchTerms}");
let engine = Services.search.getEngineByName("MozSearch");
gOriginalEngine = Services.search.currentEngine;
Services.search.currentEngine = engine;
let tab = gBrowser.selectedTab = gBrowser.addTab();
registerCleanupFunction(() => {
Services.search.currentEngine = gOriginalEngine;
let engine = Services.search.getEngineByName("MozSearch");
Services.search.removeEngine(engine);
try {
gBrowser.removeTab(tab);
} catch(ex) { /* tab may have already been closed in case of failure */ }
return promiseClearHistory();
});
let result = yield promise_first_result("open a search");
isnot(result, null, "Should have a result");
is(result.getAttribute("url"),
`moz-action:searchengine,{"engineName":"MozSearch","input":"open a search","searchQuery":"open a search"}`,
"Result should be a moz-action: for the correct search engine");
is(result.hasAttribute("image"), false, "Result shouldn't have an image attribute");
let tabPromise = promiseTabLoaded(gBrowser.selectedTab);
EventUtils.synthesizeMouseAtCenter(result, {});
yield tabPromise;
is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search", "Correct URL should be loaded");
});
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
add_task(function* () {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET",
"http://example.com/?q={searchTerms}");
let engine = Services.search.getEngineByName("MozSearch");
let originalEngine = Services.search.currentEngine;
Services.search.currentEngine = engine;
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(gBrowser.selectedTab);
registerCleanupFunction(() => {
Services.search.currentEngine = originalEngine;
let engine = Services.search.getEngineByName("MozSearch");
Services.search.removeEngine(engine);
try {
gBrowser.removeTab(tab);
} catch(ex) { /* tab may have already been closed in case of failure */ }
return promiseClearHistory();
});
yield promiseAutocompleteResultPopup("open a search");
let result = gURLBar.popup.richlistbox.firstChild;
isnot(result, null, "Should have a result");
is(result.getAttribute("url"),
`moz-action:searchengine,{"engineName":"MozSearch","input":"open a search","searchQuery":"open a search"}`,
"Result should be a moz-action: for the correct search engine");
is(result.hasAttribute("image"), false, "Result shouldn't have an image attribute");
let tabPromise = promiseTabLoaded(gBrowser.selectedTab);
result.click();
yield tabPromise;
is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search", "Correct URL should be loaded");
});

View File

@ -1,48 +1,44 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
**/
let gOriginalEngine;
add_task(function* () {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
let iconURI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC";
Services.search.addEngineWithDetails("MozSearch", iconURI, "moz", "", "GET",
"http://example.com/?q={searchTerms}");
let engine = Services.search.getEngineByName("MozSearch");
gOriginalEngine = Services.search.currentEngine;
Services.search.currentEngine = engine;
let tab = gBrowser.selectedTab = gBrowser.addTab();
registerCleanupFunction(() => {
Services.search.currentEngine = gOriginalEngine;
let engine = Services.search.getEngineByName("MozSearch");
Services.search.removeEngine(engine);
Services.prefs.clearUserPref("browser.urlbar.unifiedcomplete");
try {
gBrowser.removeTab(tab);
} catch(ex) { /* tab may have already been closed in case of failure */ }
return promiseClearHistory();
});
gURLBar.focus();
gURLBar.value = "moz open a searc";
EventUtils.synthesizeKey("h" , {});
yield promiseSearchComplete();
let result = gURLBar.popup.richlistbox.children[0];
ok(result.hasAttribute("image"), "Result should have an image attribute");
// Image attribute gets a suffix (-moz-resolution) added in the value.
ok(result.getAttribute("image").startsWith(engine.iconURI.spec),
"Image attribute should have the search engine's icon");
EventUtils.synthesizeKey("VK_RETURN" , { });
yield promiseTabLoaded(gBrowser.selectedTab);
is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search");
});
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
**/
add_task(function* () {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
let iconURI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC";
Services.search.addEngineWithDetails("MozSearch", iconURI, "moz", "", "GET",
"http://example.com/?q={searchTerms}");
let engine = Services.search.getEngineByName("MozSearch");
let originalEngine = Services.search.currentEngine;
Services.search.currentEngine = engine;
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(gBrowser.selectedTab);
registerCleanupFunction(() => {
Services.search.currentEngine = originalEngine;
let engine = Services.search.getEngineByName("MozSearch");
Services.search.removeEngine(engine);
Services.prefs.clearUserPref("browser.urlbar.unifiedcomplete");
try {
gBrowser.removeTab(tab);
} catch(ex) { /* tab may have already been closed in case of failure */ }
return promiseClearHistory();
});
yield promiseAutocompleteResultPopup("moz open a search");
let result = gURLBar.popup.richlistbox.children[0];
ok(result.hasAttribute("image"), "Result should have an image attribute");
// Image attribute gets a suffix (-moz-resolution) added in the value.
ok(result.getAttribute("image").startsWith(engine.iconURI.spec),
"Image attribute should have the search engine's icon");
EventUtils.synthesizeKey("VK_RETURN" , { });
yield promiseTabLoaded(gBrowser.selectedTab);
is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search");
});

View File

@ -1,32 +1,25 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function* check_a11y_label(inputText, expectedLabel) {
gURLBar.focus();
gURLBar.value = inputText.slice(0, -1);
EventUtils.synthesizeKey(inputText.slice(-1) , {});
yield promiseSearchComplete();
ok(gURLBar.popup.richlistbox.children.length > 1, "Should get at least 2 results");
let result = gURLBar.popup.richlistbox.children[1];
is(result.getAttribute("type"), "action switchtab", "Expect right type attribute");
is(result.label, expectedLabel, "Result a11y label should be as expected");
}
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let tab = gBrowser.addTab("about:about");
yield promiseTabLoaded(tab);
let actionURL = makeActionURI("switchtab", {url: "about:about"}).spec;
yield check_a11y_label("% about", "about:about " + actionURL + " Tab");
gURLBar.popup.hidePopup();
yield promisePopupHidden(gURLBar.popup);
gBrowser.removeTab(tab);
});
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let tab = gBrowser.addTab("about:about");
yield promiseTabLoaded(tab);
let actionURL = makeActionURI("switchtab", {url: "about:about"}).spec;
yield promiseAutocompleteResultPopup("% about");
ok(gURLBar.popup.richlistbox.children.length > 1, "Should get at least 2 results");
let result = gURLBar.popup.richlistbox.children[1];
is(result.getAttribute("type"), "action switchtab", "Expect right type attribute");
is(result.label, "about:about " + actionURL + " Tab", "Result a11y label should be as expected");
gURLBar.popup.hidePopup();
yield promisePopupHidden(gURLBar.popup);
gBrowser.removeTab(tab);
});

View File

@ -1,65 +1,61 @@
function repeat(limit, func) {
for (let i = 0; i < limit; i++) {
func(i);
}
}
function* promiseAutoComplete(inputText) {
gURLBar.focus();
gURLBar.value = inputText.slice(0, -1);
EventUtils.synthesizeKey(inputText.slice(-1), {});
yield promiseSearchComplete();
}
function is_selected(index) {
is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`);
}
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
registerCleanupFunction(promiseClearHistory);
let visits = [];
repeat(10, i => {
visits.push({
uri: makeURI("http://example.com/autocomplete/?" + i),
});
});
yield PlacesTestUtils.addVisits(visits);
yield promiseAutoComplete("example.com/autocomplete");
let popup = gURLBar.popup;
let results = popup.richlistbox.children;
// 1 extra for the current search engine match
is(results.length, 11, "Should get 11 results");
is_selected(0);
info("Key Down to select the next item");
EventUtils.synthesizeKey("VK_DOWN", {});
is_selected(1);
info("Key Down 11 times should wrap around all the way around");
repeat(11, () => EventUtils.synthesizeKey("VK_DOWN", {}));
is_selected(1);
info("Key Up 11 times should wrap around the other way");
repeat(11, () => EventUtils.synthesizeKey("VK_UP", {}));
is_selected(1);
info("Page Up will go up the list, but not wrap");
EventUtils.synthesizeKey("VK_PAGE_UP", {})
is_selected(0);
info("Page Up again will wrap around to the end of the list");
EventUtils.synthesizeKey("VK_PAGE_UP", {})
is_selected(10);
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield promisePopupHidden(gURLBar.popup);
});
function repeat(limit, func) {
for (let i = 0; i < limit; i++) {
func(i);
}
}
function is_selected(index) {
is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`);
}
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
registerCleanupFunction(promiseClearHistory);
let visits = [];
repeat(10, i => {
visits.push({
uri: makeURI("http://example.com/autocomplete/?" + i),
});
});
yield PlacesTestUtils.addVisits(visits);
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(tab);
yield promiseAutocompleteResultPopup("example.com/autocomplete");
let popup = gURLBar.popup;
let results = popup.richlistbox.children;
// 1 extra for the current search engine match
is(results.length, 11, "Should get 11 results");
is_selected(0);
info("Key Down to select the next item");
EventUtils.synthesizeKey("VK_DOWN", {});
is_selected(1);
info("Key Down 11 times should wrap around all the way around");
repeat(11, () => EventUtils.synthesizeKey("VK_DOWN", {}));
is_selected(1);
info("Key Up 11 times should wrap around the other way");
repeat(11, () => EventUtils.synthesizeKey("VK_UP", {}));
is_selected(1);
info("Page Up will go up the list, but not wrap");
EventUtils.synthesizeKey("VK_PAGE_UP", {})
is_selected(0);
info("Page Up again will wrap around to the end of the list");
EventUtils.synthesizeKey("VK_PAGE_UP", {})
is_selected(10);
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield promisePopupHidden(gURLBar.popup);
gBrowser.removeTab(tab);
});

View File

@ -1,17 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function* check_title(inputText, expectedTitle) {
gURLBar.focus();
gURLBar.value = inputText.slice(0, -1);
EventUtils.synthesizeKey(inputText.slice(-1) , {});
yield promiseSearchComplete();
ok(gURLBar.popup.richlistbox.children.length > 1, "Should get at least 2 results");
let result = gURLBar.popup.richlistbox.children[1];
is(result._title.textContent, expectedTitle, "Result title should be as expected");
}
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
@ -19,11 +8,18 @@ add_task(function*() {
return;
}
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(tab);
let uri = NetUtil.newURI("http://bug1060642.example.com/beards/are/pretty/great");
yield PlacesTestUtils.addVisits([{uri: uri, title: ""}]);
yield check_title("bug1060642", "bug1060642.example.com");
yield promiseAutocompleteResultPopup("bug1060642");
ok(gURLBar.popup.richlistbox.children.length > 1, "Should get at least 2 results");
let result = gURLBar.popup.richlistbox.children[1];
is(result._title.textContent, "bug1060642.example.com", "Result title should be as expected");
gURLBar.popup.hidePopup();
yield promisePopupHidden(gURLBar.popup);
gBrowser.removeTab(tab);
});

View File

@ -4,13 +4,6 @@ function repeat(limit, func) {
}
}
function* promiseAutoComplete(inputText) {
gURLBar.focus();
gURLBar.value = inputText.slice(0, -1);
EventUtils.synthesizeKey(inputText.slice(-1), {});
yield promiseSearchComplete();
}
function is_selected(index) {
is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`);
}
@ -18,7 +11,7 @@ function is_selected(index) {
add_task(function*() {
// This test is only relevant if UnifiedComplete is *disabled*.
if (Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
ok(true, "Don't run this test with UnifiedComplete enabled.")
return;
}
@ -32,7 +25,9 @@ add_task(function*() {
});
yield PlacesTestUtils.addVisits(visits);
yield promiseAutoComplete("example.com/autocomplete");
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(tab);
yield promiseAutocompleteResultPopup("example.com/autocomplete");
let popup = gURLBar.popup;
let results = popup.richlistbox.children;
@ -71,4 +66,5 @@ add_task(function*() {
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield promisePopupHidden(gURLBar.popup);
gBrowser.removeTab(tab);
});

View File

@ -0,0 +1,83 @@
/* 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/. */
add_task(function test_ignoreFragment() {
let tabRefAboutHome = gBrowser.addTab("about:home#1");
yield promiseTabLoaded(tabRefAboutHome);
let tabRefAboutMozilla = gBrowser.addTab("about:mozilla");
yield promiseTabLoaded(tabRefAboutMozilla);
gBrowser.selectedTab = tabRefAboutMozilla;
let numTabsAtStart = gBrowser.tabs.length;
switchTab("about:home#1", true);
switchTab("about:mozilla", true);
switchTab("about:home#2", true, { ignoreFragment: true });
is(tabRefAboutHome, gBrowser.selectedTab, "The same about:home tab should be switched to");
is(gBrowser.currentURI.ref, "2", "The ref should be updated to the new ref");
switchTab("about:mozilla", true);
switchTab("about:home#1", false);
isnot(tabRefAboutHome, gBrowser.selectedTab, "Selected tab should not be initial about:blank tab");
is(gBrowser.tabs.length, numTabsAtStart + 1, "Should have one new tab opened");
switchTab("about:about", false, { ignoreFragment: true });
cleanupTestTabs();
});
add_task(function test_ignoreQueryString() {
let tabRefAboutHome = gBrowser.addTab("about:home?hello=firefox");
yield promiseTabLoaded(tabRefAboutHome);
let tabRefAboutMozilla = gBrowser.addTab("about:mozilla");
yield promiseTabLoaded(tabRefAboutMozilla);
gBrowser.selectedTab = tabRefAboutMozilla;
switchTab("about:home?hello=firefox", true);
switchTab("about:home?hello=firefoxos", false);
// Remove the last opened tab to test ignoreQueryString option.
gBrowser.removeCurrentTab();
switchTab("about:home?hello=firefoxos", true, { ignoreQueryString: true });
is(tabRefAboutHome, gBrowser.selectedTab, "Selected tab should be the initial about:home tab");
is(gBrowser.currentURI.spec, "about:home?hello=firefox", "The spec should NOT be updated to the new query string");
cleanupTestTabs();
});
add_task(function test_replaceQueryString() {
let tabRefAboutHome = gBrowser.addTab("about:home?hello=firefox");
yield promiseTabLoaded(tabRefAboutHome);
let tabRefAboutMozilla = gBrowser.addTab("about:mozilla");
yield promiseTabLoaded(tabRefAboutMozilla);
gBrowser.selectedTab = tabRefAboutMozilla;
switchTab("about:home", false);
switchTab("about:home?hello=firefox", true);
switchTab("about:home?hello=firefoxos", false);
// Remove the last opened tab to test replaceQueryString option.
gBrowser.removeCurrentTab();
switchTab("about:home?hello=firefoxos", true, { replaceQueryString: true });
is(tabRefAboutHome, gBrowser.selectedTab, "Selected tab should be the initial about:home tab");
// Wait for the tab to load the new URI spec.
yield promiseTabLoaded(tabRefAboutHome);
is(gBrowser.currentURI.spec, "about:home?hello=firefoxos", "The spec should be updated to the new spec");
cleanupTestTabs();
});
// Begin helpers
function cleanupTestTabs() {
while (gBrowser.tabs.length > 1)
gBrowser.removeCurrentTab();
}
function switchTab(aURI, aShouldFindExistingTab, aOpenParams = {}) {
// Build the description before switchToTabHavingURI deletes the object properties.
let msg = "Should switch to existing " + aURI + " tab if one existed, " +
(aOpenParams.ignoreFragment ? "ignoring" : "including") + " fragment portion, " +
(aOpenParams.ignoreQueryString || aOpenParams.replaceQueryString ?
(aOpenParams.replaceQueryString ? "replacing" : "ignoring") :
"including"
) + " query string.";
let tabFound = switchToTabHavingURI(aURI, true, aOpenParams);
is(tabFound, aShouldFindExistingTab, msg);
}
registerCleanupFunction(cleanupTestTabs);

View File

@ -1,62 +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/. */
add_task(function() {
registerCleanupFunction(function() {
while (gBrowser.tabs.length > 1)
gBrowser.removeCurrentTab();
});
let tabRefAboutHome = gBrowser.addTab("about:home#1");
yield promiseTabLoaded(tabRefAboutHome);
let tabRefAboutMozilla = gBrowser.addTab("about:mozilla");
yield promiseTabLoaded(tabRefAboutMozilla);
gBrowser.selectedTab = tabRefAboutMozilla;
let numTabsAtStart = gBrowser.tabs.length;
switchTab("about:home#1", false, false, true);
switchTab("about:mozilla", false, false, true);
switchTab("about:home#2", true, false, true);
is(tabRefAboutHome, gBrowser.selectedTab, "The same about:home tab should be switched to");
is(gBrowser.currentURI.ref, "2", "The ref should be updated to the new ref");
switchTab("about:mozilla", false, false, true);
switchTab("about:home#1", false, false, false);
isnot(tabRefAboutHome, gBrowser.selectedTab, "Selected tab should not be initial about:blank tab");
is(gBrowser.tabs.length, numTabsAtStart + 1, "Should have one new tab opened");
switchTab("about:about", true, false, false);
});
// Test for replaceQueryString option.
add_task(function() {
registerCleanupFunction(function() {
while (gBrowser.tabs.length > 1)
gBrowser.removeCurrentTab();
});
let tabRefAboutHome = gBrowser.addTab("about:home?hello=firefox");
yield promiseTabLoaded(tabRefAboutHome);
switchTab("about:home", false, false, false);
switchTab("about:home?hello=firefox", false, false, true);
switchTab("about:home?hello=firefoxos", false, false, false);
// Remove the last opened tab to test replaceQueryString option.
gBrowser.removeCurrentTab();
switchTab("about:home?hello=firefoxos", false, true, true);
is(tabRefAboutHome, gBrowser.selectedTab, "Selected tab should be the initial about:home tab");
// Wait for the tab to load the new URI spec.
yield promiseTabLoaded(tabRefAboutHome);
is(gBrowser.currentURI.spec, "about:home?hello=firefoxos", "The spec should be updated to the new spec");
});
function switchTab(aURI, aIgnoreFragment, aReplaceQueryString, aShouldFindExistingTab) {
let tabFound = switchToTabHavingURI(aURI, true, {
ignoreFragment: aIgnoreFragment,
replaceQueryString: aReplaceQueryString
});
is(tabFound, aShouldFindExistingTab,
"Should switch to existing " + aURI + " tab if one existed, " +
(aIgnoreFragment ? "ignoring" : "including") + " fragment portion, " +
(aReplaceQueryString ? "ignoring" : "replacing") + " query string.");
}

View File

@ -1,64 +1,60 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function* promiseAutoComplete(inputText) {
gURLBar.focus();
gURLBar.value = inputText.slice(0, -1);
EventUtils.synthesizeKey(inputText.slice(-1) , {});
yield promiseSearchComplete();
}
function is_selected(index) {
is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`);
}
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
registerCleanupFunction(() => {
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
});
let itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/?q=%s"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"test");
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
// This item only needed so we can select the keyword item, select something
// else, then select the keyword item again.
itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/keyword"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"keyword abc");
yield promiseAutoComplete("keyword a");
// First item should already be selected
is_selected(0);
// Select next one (important!)
EventUtils.synthesizeKey("VK_DOWN", {});
is_selected(1);
// Re-select keyword item
EventUtils.synthesizeKey("VK_UP", {});
is_selected(0);
EventUtils.synthesizeKey("b", {});
yield promiseSearchComplete();
is(gURLBar.value, "keyword ab", "urlbar should have expected input");
let result = gURLBar.popup.richlistbox.firstChild;
isnot(result, null, "Should have first item");
let uri = NetUtil.newURI(result.getAttribute("url"));
is(uri.spec, makeActionURI("keyword", {url: "http://example.com/?q=ab", input: "keyword ab"}).spec, "Expect correct url");
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield promisePopupHidden(gURLBar.popup);
});
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function is_selected(index) {
is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`);
}
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
registerCleanupFunction(() => {
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
});
let itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/?q=%s"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"test");
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
// This item only needed so we can select the keyword item, select something
// else, then select the keyword item again.
itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/keyword"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"keyword abc");
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(tab);
yield promiseAutocompleteResultPopup("keyword a");
// First item should already be selected
is_selected(0);
// Select next one (important!)
EventUtils.synthesizeKey("VK_DOWN", {});
is_selected(1);
// Re-select keyword item
EventUtils.synthesizeKey("VK_UP", {});
is_selected(0);
EventUtils.synthesizeKey("b", {});
yield promiseSearchComplete();
is(gURLBar.value, "keyword ab", "urlbar should have expected input");
let result = gURLBar.popup.richlistbox.firstChild;
isnot(result, null, "Should have first item");
let uri = NetUtil.newURI(result.getAttribute("url"));
is(uri.spec, makeActionURI("keyword", {url: "http://example.com/?q=ab", input: "keyword ab"}).spec, "Expect correct url");
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield promisePopupHidden(gURLBar.popup);
gBrowser.removeTab(tab);
});

View File

@ -2,7 +2,7 @@
* 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/. */
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
let fm = Services.focus;
function test() {
waitForExplicitFinish();

View File

@ -4,8 +4,7 @@
const TEST_VALUE = "example.com";
const START_VALUE = "example.org";
let gFocusManager = Cc["@mozilla.org/focus-manager;1"].
getService(Ci.nsIFocusManager);
let gFocusManager = Services.focus;
function test() {
waitForExplicitFinish();

View File

@ -45,7 +45,7 @@ function testURL(url, loadFunc, endFunc) {
loadFunc(url);
addPageShowListener(function () {
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
let fm = Services.focus;
is(fm.focusedElement, null, "should be no focused element");
is(fm.focusedWindow, gBrowser.contentWindow, "content window should be focused");

View File

@ -67,15 +67,6 @@ function promiseAddVisits(aPlaceInfo) {
});
}
function* promiseAutocompleteResultPopup(inputText) {
gURLBar.focus();
gURLBar.value = inputText.slice(0, -1);
EventUtils.synthesizeKey(inputText.slice(-1) , {});
yield promiseSearchComplete();
return gURLBar.popup.richlistbox.children;
}
registerCleanupFunction(() => {
Services.prefs.clearUserPref(gUnifiedCompletePref);
Services.prefs.clearUserPref(gRestyleSearchesPref);
@ -101,10 +92,13 @@ add_task(function*() {
let uri = NetUtil.newURI("http://s.example.com/search?q=foo&client=1");
yield promiseAddVisits({ uri: uri, title: "Foo - SearchEngine Search" });
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(gBrowser.selectedTab);
// The first autocomplete result has the action searchengine, while
// the second result is the "search favicon" element.
let result = yield promiseAutocompleteResultPopup("foo");
result = result[1];
yield promiseAutocompleteResultPopup("foo");
let result = gURLBar.popup.richlistbox.children[1];
isnot(result, null, "Expect a search result");
is(result.getAttribute("type"), "search favicon", "Expect correct `type` attribute");
@ -121,4 +115,6 @@ add_task(function*() {
is_element_visible(result._url, "URL element should be visible");
is(result._url.textContent, "Search with SearchEngine");
gBrowser.removeCurrentTab();
});

View File

@ -71,52 +71,35 @@ function test() {
ok(!testTab.hasAttribute("busy"),
"The test tab doesn't have the busy attribute");
let urlbar = aDestWindow.gURLBar;
let controller = urlbar.controller;
// Focus URL bar, enter value, and start searching.
urlbar.focus();
urlbar.value = testURL;
controller.startSearch(testURL);
// Wait for the Awesomebar popup to appear.
let popup = aDestWindow.gURLBar.popup;
promisePopupShown(popup).then(() => {
function searchIsComplete() {
return controller.searchStatus ==
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH;
promiseAutocompleteResultPopup(testURL, aDestWindow).then(() => {
if (aExpectSwitch) {
// If we expect a tab switch then the current tab
// will be closed and we switch to the other tab.
let tabContainer = aDestWindow.gBrowser.tabContainer;
tabContainer.addEventListener("TabClose", function onClose(event) {
if (event.target == testTab) {
tabContainer.removeEventListener("TabClose", onClose);
executeSoon(aCallback);
}
});
} else {
// If we don't expect a tab switch then wait for the tab to load.
testTab.addEventListener("load", function onLoad() {
testTab.removeEventListener("load", onLoad, true);
executeSoon(aCallback);
}, true);
}
// Wait until the search is complete.
waitForCondition(searchIsComplete, function () {
if (aExpectSwitch) {
// If we expect a tab switch then the current tab
// will be closed and we switch to the other tab.
let tabContainer = aDestWindow.gBrowser.tabContainer;
tabContainer.addEventListener("TabClose", function onClose(event) {
if (event.target == testTab) {
tabContainer.removeEventListener("TabClose", onClose);
executeSoon(aCallback);
}
});
} else {
// If we don't expect a tab switch then wait for the tab to load.
testTab.addEventListener("load", function onLoad() {
testTab.removeEventListener("load", onLoad, true);
executeSoon(aCallback);
}, true);
}
// Make sure the last match is selected.
let {controller, popup} = aDestWindow.gURLBar;
while (popup.selectedIndex < controller.matchCount - 1) {
controller.handleKeyNavigation(KeyEvent.DOM_VK_DOWN);
}
// Make sure the last match is selected.
while (popup.selectedIndex < controller.matchCount - 1) {
controller.handleKeyNavigation(KeyEvent.DOM_VK_DOWN);
}
// Execute the selected action.
controller.handleEnter(true);
});
// Execute the selected action.
controller.handleEnter(true);
});
}, aDestWindow);
}, true);
}

View File

@ -39,7 +39,7 @@ function test() {
window.addEventListener("blur", _browser_tabfocus_test_eventOccured, true);
// make sure that the focus initially starts out blank
var fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
var fm = Services.focus;
var focusedWindow = {};
is(fm.getFocusedElementForWindow(browser1.contentWindow, false, focusedWindow), null, "initial focus in tab 1");
is(focusedWindow.value, browser1.contentWindow, "initial frame focus in tab 1");
@ -259,7 +259,7 @@ function expectFocusShift(callback, expectedWindow, expectedElement, focusChange
is(_browser_tabfocus_test_events, expectedEvents, testid + " events");
_browser_tabfocus_test_events = "";
var fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
var fm = Services.focus;
var focusedElement = fm.focusedElement;
is(focusedElement ? getId(focusedElement) : "none",

View File

@ -0,0 +1,71 @@
function repeat(limit, func) {
for (let i = 0; i < limit; i++) {
func(i);
}
}
function* promiseAutoComplete(inputText) {
gURLBar.focus();
gURLBar.value = inputText.slice(0, -1);
EventUtils.synthesizeKey(inputText.slice(-1), {});
yield promiseSearchComplete();
}
function is_selected(index) {
is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`);
}
add_task(function*() {
registerCleanupFunction(promiseClearHistory);
yield promiseClearHistory();
let tabCount = gBrowser.tabs.length;
let visits = [];
repeat(10, i => {
visits.push({
uri: makeURI("http://example.com/autocomplete/?" + i),
});
});
yield PlacesTestUtils.addVisits(visits);
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
yield* do_test();
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", false);
yield* do_test();
Services.prefs.clearUserPref("browser.urlbar.unifiedcomplete");
});
function* do_test() {
gBrowser.selectedTab = gBrowser.addTab("about:blank");
yield promiseAutoComplete("http://example.com/autocomplete/");
let popup = gURLBar.popup;
let results = popup.richlistbox.children;
is(results.length, 11, "Should get 11 results");
let initiallySelected = gURLBar.popup.richlistbox.selectedIndex;
info("Key Down to select the next item");
EventUtils.synthesizeKey("VK_DOWN", {});
is_selected(initiallySelected + 1);
let expectedURL = gURLBar.controller.getFinalCompleteValueAt(initiallySelected + 1);
is(gURLBar.value, gURLBar.controller.getValueAt(initiallySelected + 1),
"Value in the URL bar should be updated by keyboard selection");
// Verify that what we're about to do changes the selectedIndex:
isnot(initiallySelected + 1, 3, "Shouldn't be changing the selectedIndex to the same index we keyboard-selected.");
// Would love to use a synthetic mousemove event here, but that doesn't seem to do anything.
// EventUtils.synthesizeMouseAtCenter(results[3], {type: "mousemove"});
gURLBar.popup.richlistbox.selectedIndex = 3;
is_selected(3);
let autocompletePopupHidden = promisePopupHidden(gURLBar.popup);
let openedExpectedPage = waitForDocLoadAndStopIt(expectedURL);
EventUtils.synthesizeKey("VK_RETURN", {});
yield Promise.all([autocompletePopupHidden, openedExpectedPage]);
gBrowser.removeCurrentTab();
}

View File

@ -780,28 +780,24 @@ function promisePopupHidden(popup) {
return promisePopupEvent(popup, "hidden");
}
// NOTE: If you're using this, and attempting to interact with one of the
// autocomplete results, your test is likely to be unreliable on Linux.
// See bug 1073339.
let gURLBarOnSearchComplete = null;
function promiseSearchComplete() {
info("Waiting for onSearchComplete");
return new Promise(resolve => {
if (!gURLBarOnSearchComplete) {
gURLBarOnSearchComplete = gURLBar.onSearchComplete;
registerCleanupFunction(() => {
gURLBar.onSearchComplete = gURLBarOnSearchComplete;
});
function promiseSearchComplete(win = window) {
return promisePopupShown(win.gURLBar.popup).then(() => {
function searchIsComplete() {
return win.gURLBar.controller.searchStatus >=
Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
}
gURLBar.onSearchComplete = function () {
ok(gURLBar.popupOpen, "The autocomplete popup is correctly open");
gURLBarOnSearchComplete.apply(gURLBar);
resolve();
}
}).then(() => {
// On Linux, the popup may or may not be open at this stage. So we need
// additional checks to ensure we wait long enough.
return promisePopupShown(gURLBar.popup);
// Wait until there are at least two matches.
return new Promise(resolve => waitForCondition(searchIsComplete, resolve));
});
}
function promiseAutocompleteResultPopup(inputText, win = window) {
waitForFocus(() => {
win.gURLBar.focus();
win.gURLBar.value = inputText;
win.gURLBar.controller.startSearch(inputText);
}, win);
return promiseSearchComplete(win);
}

View File

@ -34,6 +34,8 @@ const roomsPushNotification = function(version, channelID) {
// of date. The Push server may notify us of this event, which will set the global
// 'dirty' flag to TRUE.
let gDirty = true;
// Global variable that keeps track of the currently used account.
let gCurrentUser = null;
/**
* Extend a `target` object with the properties defined in `source`.
@ -479,6 +481,26 @@ let LoopRoomsInternal = {
gDirty = true;
this.getAll(version, () => {});
},
/**
* When a user logs in or out, this method should be invoked to check whether
* the rooms cache needs to be refreshed.
*
* @param {String|null} user The FxA userID or NULL
*/
maybeRefresh: function(user = null) {
if (gCurrentUser == user) {
return;
}
gCurrentUser = user;
if (!gDirty) {
gDirty = true;
this.rooms.clear();
eventEmitter.emit("refresh");
this.getAll(null, () => {});
}
}
};
Object.freeze(LoopRoomsInternal);
@ -544,6 +566,10 @@ this.LoopRooms = {
return LoopRoomsInternal.getGuestCreatedRoom();
},
maybeRefresh: function(user) {
return LoopRoomsInternal.maybeRefresh(user);
},
promise: function(method, ...params) {
return new Promise((resolve, reject) => {
this[method](...params, (error, result) => {

View File

@ -243,7 +243,8 @@ let MozLoopServiceInternal = {
notifyStatusChanged: function(aReason = null) {
log.debug("notifyStatusChanged with reason:", aReason);
let profile = MozLoopService.userProfile;
LoopStorage.switchDatabase(profile ? profile.uid : null);
LoopStorage.switchDatabase(profile && profile.uid);
LoopRooms.maybeRefresh(profile && profile.uid);
Services.obs.notifyObservers(null, "loop-status-changed", aReason);
},

View File

@ -67,10 +67,20 @@ loop.roomViews = (function(mozL10n) {
getInitialState: function() {
return {
copiedUrl: false,
newRoomName: ""
newRoomName: "",
error: null,
};
},
componentWillMount: function() {
this.listenTo(this.props.roomStore, "change:error",
this.onRoomError);
},
componentWillUnmount: function() {
this.stopListening(this.props.roomStore);
},
handleFormSubmit: function(event) {
event.preventDefault();
@ -101,9 +111,23 @@ loop.roomViews = (function(mozL10n) {
this.setState({copiedUrl: true});
},
onRoomError: function() {
// Only update the state if we're mounted, to avoid the problem where
// stopListening doesn't nuke the active listeners during a event
// processing.
if (this.isMounted()) {
this.setState({error: this.props.roomStore.getStoreState("error")});
}
},
render: function() {
var cx = React.addons.classSet;
return (
React.DOM.div({className: "room-invitation-overlay"},
React.DOM.p({className: cx({"error": !!this.state.error,
"error-display-area": true})},
mozL10n.get("rooms_name_change_failed_label")
),
React.DOM.form({onSubmit: this.handleFormSubmit},
React.DOM.input({type: "text", className: "input-room-name",
valueLink: this.linkState("newRoomName"),

View File

@ -67,10 +67,20 @@ loop.roomViews = (function(mozL10n) {
getInitialState: function() {
return {
copiedUrl: false,
newRoomName: ""
newRoomName: "",
error: null,
};
},
componentWillMount: function() {
this.listenTo(this.props.roomStore, "change:error",
this.onRoomError);
},
componentWillUnmount: function() {
this.stopListening(this.props.roomStore);
},
handleFormSubmit: function(event) {
event.preventDefault();
@ -101,9 +111,23 @@ loop.roomViews = (function(mozL10n) {
this.setState({copiedUrl: true});
},
onRoomError: function() {
// Only update the state if we're mounted, to avoid the problem where
// stopListening doesn't nuke the active listeners during a event
// processing.
if (this.isMounted()) {
this.setState({error: this.props.roomStore.getStoreState("error")});
}
},
render: function() {
var cx = React.addons.classSet;
return (
<div className="room-invitation-overlay">
<p className={cx({"error": !!this.state.error,
"error-display-area": true})}>
{mozL10n.get("rooms_name_change_failed_label")}
</p>
<form onSubmit={this.handleFormSubmit}>
<input type="text" className="input-room-name"
valueLink={this.linkState("newRoomName")}

View File

@ -157,7 +157,7 @@
opacity: 1;
}
.conversation-toolbar .media-control:hover {
background-color: rgba(255, 255, 255, .35);
background-color: rgba(255,255,255,.35);
opacity: 1;
}
.conversation-toolbar .media-control.muted {
@ -208,7 +208,7 @@
.standalone .local-stream {
/* required to have it superimposed to the control toolbar */
z-index: 1001;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
box-shadow: 0 2px 4px rgba(0,0,0,.5);
}
/* Side by side video elements */
@ -320,7 +320,7 @@
position: absolute; /* element can be wider than the parent */
background: #fff;
margin: 0;
box-shadow: 0 4px 5px rgba(30, 30, 30, .3);
box-shadow: 0 4px 5px rgba(30,30,30,.3);
border-style: solid;
border-width: 1px 1px 1px 2px;
border-color: #aaa #111 #111 #aaa;
@ -473,7 +473,7 @@
width: 30%;
height: 28%;
max-height: 105px;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.5);
box-shadow: 0px 2px 4px rgba(0,0,0,.5);
}
.fx-embedded .local-stream.room-preview {
@ -566,7 +566,7 @@
background-color: #4ba6e7;
background-size: contain;
overflow: hidden;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
float: left;
-moz-margin-end: 1em;
}
@ -776,7 +776,7 @@ html, .fx-embedded, #main,
.room-invitation-overlay {
position: absolute;
background: rgba(0, 0, 0, .6);
background: rgba(0,0,0,.6);
/* This matches .fx-embedded .conversation toolbar height */
top: 26px;
right: 0;
@ -787,18 +787,36 @@ html, .fx-embedded, #main,
z-index: 1010;
}
.room-invitation-overlay .error-display-area.error,
.room-invitation-overlay input[type="text"] {
display: block;
background-color: rgba(0,0,0,.5);
border-radius: 3px;
padding: .5em;
}
.room-invitation-overlay .error-display-area {
display: none;
}
.room-invitation-overlay .error-display-area.error {
position: absolute;
top: 2em;
left: 1em;
right: 1em;
text-align: start;
width: calc(258px - 2em);
color: #d74345;
}
.room-invitation-overlay form {
padding: 8em 0 2.5em 0;
}
.room-invitation-overlay input[type="text"] {
display: block;
background: rgba(0, 0, 0, .5);
color: #fff;
font-size: 1.2em;
border: none;
border-radius: 3px;
padding: .5em;
width: 200px;
margin: 0 auto;
}

View File

@ -264,6 +264,14 @@ loop.shared.actions = (function() {
newRoomName: String
}),
/**
* Renaming a room error.
* XXX: should move to some roomActions module - refs bug 1079284
*/
RenameRoomError: Action.define("renameRoomError", {
error: [Error, Object]
}),
/**
* Copy a room url into the user's clipboard.
* XXX: should move to some roomActions module - refs bug 1079284

View File

@ -98,6 +98,7 @@ loop.store = loop.store || {};
"getAllRoomsError",
"openRoom",
"renameRoom",
"renameRoomError",
"updateRoomList"
],
@ -120,7 +121,7 @@ loop.store = loop.store || {};
error: null,
pendingCreation: false,
pendingInitialRetrieval: false,
rooms: []
rooms: [],
};
},
@ -132,6 +133,7 @@ loop.store = loop.store || {};
this._mozLoop.rooms.on("add", this._onRoomAdded.bind(this));
this._mozLoop.rooms.on("update", this._onRoomUpdated.bind(this));
this._mozLoop.rooms.on("delete", this._onRoomRemoved.bind(this));
this._mozLoop.rooms.on("refresh", this._onRoomsRefresh.bind(this));
},
/**
@ -184,6 +186,17 @@ loop.store = loop.store || {};
}));
},
/**
* Executed when the user switches accounts.
*
* @param {String} eventName The event name (unused).
*/
_onRoomsRefresh: function(eventName) {
this.dispatchAction(new sharedActions.UpdateRoomList({
roomList: []
}));
},
/**
* Maps and sorts the raw room list received from the mozLoop API.
*
@ -378,13 +391,17 @@ loop.store = loop.store || {};
* @param {sharedActions.RenameRoom} actionData
*/
renameRoom: function(actionData) {
this.setStoreState({error: null});
this._mozLoop.rooms.rename(actionData.roomToken, actionData.newRoomName,
function(err) {
if (err) {
// XXX Give this a proper UI - bug 1100595.
console.error("Failed to rename the room", err);
this.dispatchAction(new sharedActions.RenameRoomError({error: err}));
}
});
}.bind(this));
},
renameRoomError: function(actionData) {
this.setStoreState({error: actionData.error});
}
});
})();

View File

@ -8,9 +8,13 @@ set -e
./mach marionette-test browser/components/loop/manifest.ini
# The browser_parsable_css.js can fail if we add some css that isn't parsable.
./mach mochitest browser/components/loop/test/mochitest browser/base/content/test/general/browser_parsable_css.js
#
# The check to make sure that the media devices can be used in Loop without
# prompting is in browser_devices_get_user_media_about_urls.js. It's possible
# to mess this up with CSP handling, and probably other changes, too.
./mach mochitest browser/base/content/test/general/browser_devices_get_user_media_about_urls.js
./mach mochitest \
browser/components/loop/test/mochitest \
browser/base/content/test/general/browser_parsable_css.js \
browser/base/content/test/general/browser_devices_get_user_media_about_urls.js

View File

@ -81,6 +81,7 @@ describe("loop.store.RoomStore", function () {
create: function() {},
getAll: function() {},
open: function() {},
rename: function() {},
on: sandbox.stub()
}
};
@ -144,6 +145,14 @@ describe("loop.store.RoomStore", function () {
})).eql(false);
});
});
describe("refresh", function() {
it ("should clear the list of rooms", function() {
fakeMozLoop.rooms.trigger("refresh", "refresh");
expect(store.getStoreState().rooms).to.have.length.of(0);
});
})
});
describe("#findNextAvailableRoomNumber", function() {
@ -433,13 +442,14 @@ describe("loop.store.RoomStore", function () {
beforeEach(function() {
fakeMozLoop = {
rooms: {
rename: sinon.spy()
rename: null
}
};
store = new loop.store.RoomStore(dispatcher, {mozLoop: fakeMozLoop});
});
it("should rename the room via mozLoop", function() {
fakeMozLoop.rooms.rename = sinon.spy();
dispatcher.dispatch(new sharedActions.RenameRoom({
roomToken: "42abc",
newRoomName: "silly name"
@ -449,5 +459,19 @@ describe("loop.store.RoomStore", function () {
sinon.assert.calledWith(fakeMozLoop.rooms.rename, "42abc",
"silly name");
});
it("should store any rename-encountered error", function() {
var err = new Error("fake");
sandbox.stub(fakeMozLoop.rooms, "rename", function(roomToken, roomName, cb) {
cb(err);
});
dispatcher.dispatch(new sharedActions.RenameRoom({
roomToken: "42abc",
newRoomName: "silly name"
}));
expect(store.getStoreState().error).eql(err);
});
});
});

View File

@ -5,6 +5,7 @@
Cu.import("resource://services-common/utils.js");
Cu.import("resource:///modules/loop/LoopRooms.jsm");
Cu.import("resource:///modules/Chat.jsm");
Cu.import("resource://gre/modules/Promise.jsm");
let openChatOrig = Chat.open;
@ -127,6 +128,7 @@ let gExpectedUpdates = [];
let gExpectedDeletes = [];
let gExpectedJoins = {};
let gExpectedLeaves = {};
let gExpectedRefresh = false;
const onRoomAdded = function(e, room) {
let expectedIds = gExpectedAdds.map(room => room.roomToken);
@ -171,6 +173,11 @@ const onRoomLeft = function(e, room, participant) {
}
};
const onRefresh = function(e) {
Assert.ok(gExpectedRefresh, "A refresh event should've been expected");
gExpectedRefresh = false;
};
const parseQueryString = function(qs) {
let map = {};
let parts = qs.split("=");
@ -312,6 +319,34 @@ add_task(function* test_openRoom() {
Assert.equal(windowData.roomToken, "fakeToken", "window data should have the roomToken");
});
// Test if the rooms cache is refreshed after FxA signin or signout.
add_task(function* test_refresh() {
gExpectedAdds.push(...kRooms.values());
gExpectedRefresh = true;
// Make the switch.
MozLoopServiceInternal.fxAOAuthTokenData = { token_type: "bearer" };
MozLoopServiceInternal.fxAOAuthProfile = {
email: "fake@invalid.com",
uid: "fake"
};
yield waitForCondition(() => !gExpectedRefresh);
yield waitForCondition(() => gExpectedAdds.length === 0);
gExpectedAdds.push(...kRooms.values());
gExpectedRefresh = true;
// Simulate a logout.
MozLoopServiceInternal.fxAOAuthTokenData = null;
MozLoopServiceInternal.fxAOAuthProfile = null;
yield waitForCondition(() => !gExpectedRefresh);
yield waitForCondition(() => gExpectedAdds.length === 0);
// Simulating a logout again shouldn't yield a refresh event.
MozLoopServiceInternal.fxAOAuthTokenData = null;
MozLoopServiceInternal.fxAOAuthProfile = null;
});
// Test if push updates function as expected.
add_task(function* test_roomUpdates() {
gExpectedUpdates.push("_nxD4V4FflQ");
@ -433,6 +468,11 @@ add_task(function* () {
Assert.strictEqual(gExpectedAdds.length, 0, "No room additions should be expected anymore");
Assert.strictEqual(gExpectedUpdates.length, 0, "No room updates should be expected anymore");
Assert.strictEqual(gExpectedDeletes.length, 0, "No room deletes should be expected anymore");
Assert.strictEqual(Object.getOwnPropertyNames(gExpectedJoins).length, 0,
"No room joins should be expected anymore");
Assert.strictEqual(Object.getOwnPropertyNames(gExpectedLeaves).length, 0,
"No room leaves should be expected anymore");
Assert.ok(!gExpectedRefresh, "No refreshes should be expected anymore");
});
function run_test() {
@ -443,6 +483,7 @@ function run_test() {
LoopRooms.on("delete", onRoomDeleted);
LoopRooms.on("joined", onRoomJoined);
LoopRooms.on("left", onRoomLeft);
LoopRooms.on("refresh", onRefresh);
do_register_cleanup(function () {
// Revert original Chat.open implementation
@ -456,6 +497,7 @@ function run_test() {
LoopRooms.off("delete", onRoomDeleted);
LoopRooms.off("joined", onRoomJoined);
LoopRooms.off("left", onRoomLeft);
LoopRooms.off("refresh", onRefresh);
});
run_next_test();

View File

@ -102,7 +102,7 @@
<richlistitem id="category-search"
class="category"
value="paneSearch"
helpTopic="prefs-main"
helpTopic="prefs-search"
tooltiptext="&paneSearch.title;"
align="center">
<image class="category-icon"/>

View File

@ -28,8 +28,7 @@ function spawnTest() {
let hud = HUDService.getHudReferenceById(subject.data);
ok(hud, "console open");
let jstermExecute = helpers.promiseify(hud.jsterm.execute, hud.jsterm);
let msg = yield jstermExecute("pprint(window)");
let msg = yield hud.jsterm.execute("pprint(window)");
ok(msg, "output for pprint(window)");

View File

@ -468,7 +468,7 @@ var Scratchpad = {
return connection.then(({ debuggerClient, webConsoleClient }) => {
let deferred = promise.defer();
webConsoleClient.evaluateJS(aString, aResponse => {
webConsoleClient.evaluateJSAsync(aString, aResponse => {
this.debuggerClient = debuggerClient;
this.webConsoleClient = webConsoleClient;
if (aResponse.error) {
@ -572,20 +572,11 @@ var Scratchpad = {
return;
}
let browser = this.gBrowser.selectedBrowser;
this._reloadAndRunEvent = evt => {
if (evt.target !== browser.contentDocument) {
return;
}
browser.removeEventListener("load", this._reloadAndRunEvent, true);
this.run().then(aResults => deferred.resolve(aResults));
};
browser.addEventListener("load", this._reloadAndRunEvent, true);
browser.contentWindow.location.reload();
let target = TargetFactory.forTab(this.gBrowser.selectedTab);
target.once("navigate", () => {
this.run().then(results => deferred.resolve(results));
});
target.makeRemote().then(() => target.activeTab.reload());
return deferred.promise;
},
@ -2067,8 +2058,8 @@ ScratchpadTab.prototype = {
/**
* Initialize a debugger client and connect it to the debugger server.
*
* @param object aSubject
* The tab or window to obtain the connection for.
* @param object aSubject
* The tab or window to obtain the connection for.
* @return Promise
* The promise for the result of connecting to this tab or window.
*/
@ -2113,8 +2104,8 @@ ScratchpadTab.prototype = {
/**
* Attach to this tab.
*
* @param object aSubject
* The tab or window to obtain the connection for.
* @param object aSubject
* The tab or window to obtain the connection for.
* @return Promise
* The promise for the TabTarget for this tab.
*/

View File

@ -1,5 +1,4 @@
[DEFAULT]
skip-if = e10s # Bug ?????? - devtools tests disabled with e10s
subsuite = devtools
support-files = head.js

View File

@ -40,6 +40,7 @@ EXTRA_JS_MODULES.devtools.shared += [
'observable-object.js',
'telemetry.js',
'theme-switching.js',
'theme.js',
'undo.js',
]

View File

@ -45,6 +45,7 @@ support-files =
[browser_prefs.js]
[browser_require_basic.js]
[browser_spectrum.js]
[browser_theme.js]
[browser_tableWidget_basic.js]
[browser_tableWidget_keyboard_interaction.js]
[browser_tableWidget_mouse_interaction.js]

View File

@ -0,0 +1,91 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that theme utilities work
let { Cu } = devtools.require("chrome");
let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let { getColor, getTheme, setTheme } = devtools.require("devtools/shared/theme");
function test() {
waitForExplicitFinish();
testGetTheme();
testSetTheme();
testGetColor();
testColorExistence();
endTests();
}
function endTests() {
gDevTools = Services = null;
finish();
}
function testGetTheme () {
let originalTheme = getTheme();
ok(originalTheme, "has some theme to start with.");
Services.prefs.setCharPref("devtools.theme", "light");
is(getTheme(), "light", "getTheme() correctly returns light theme");
Services.prefs.setCharPref("devtools.theme", "dark");
is(getTheme(), "dark", "getTheme() correctly returns dark theme");
Services.prefs.setCharPref("devtools.theme", "unknown");
is(getTheme(), "unknown", "getTheme() correctly returns an unknown theme");
Services.prefs.setCharPref("devtools.theme", originalTheme);
}
function testSetTheme () {
let originalTheme = getTheme();
setTheme("dark");
is(Services.prefs.getCharPref("devtools.theme"), "dark", "setTheme() correctly sets dark theme.");
setTheme("light");
is(Services.prefs.getCharPref("devtools.theme"), "light", "setTheme() correctly sets light theme.");
setTheme("unknown");
is(Services.prefs.getCharPref("devtools.theme"), "unknown", "setTheme() correctly sets an unknown theme.");
Services.prefs.setCharPref("devtools.theme", originalTheme);
}
function testGetColor () {
let BLUE_DARK = "#3689b2";
let BLUE_LIGHT = "hsl(208,56%,40%)";
let originalTheme = getTheme();
setTheme("dark");
is(getColor("highlight-blue"), BLUE_DARK, "correctly gets color for enabled theme.");
setTheme("light");
is(getColor("highlight-blue"), BLUE_LIGHT, "correctly gets color for enabled theme.");
setTheme("metal");
is(getColor("highlight-blue"), BLUE_LIGHT, "correctly uses light for default theme if enabled theme not found");
is(getColor("highlight-blue", "dark"), BLUE_DARK, "if provided and found, uses the provided theme.");
is(getColor("highlight-blue", "metal"), BLUE_LIGHT, "if provided and not found, defaults to light theme.");
is(getColor("somecomponents"), null, "if a type cannot be found, should return null.");
setTheme(originalTheme);
}
function testColorExistence () {
var vars = ["body-background", "sidebar-background", "contrast-background", "tab-toolbar-background",
"toolbar-background", "selection-background", "selection-color",
"selection-background-semitransparent", "splitter-color", "comment", "body-color",
"body-color-alt", "content-color1", "content-color2", "content-color3",
"highlight-green", "highlight-blue", "highlight-bluegrey", "highlight-purple",
"highlight-lightorange", "highlight-orange", "highlight-red", "highlight-pink"
];
for (let type of vars) {
ok(getColor(type, "light"), `${type} is a valid color in light theme`);
ok(getColor(type, "dark"), `${type} is a valid color in light theme`);
}
}
function isColor (s) {
// Regexes from Heather Arthur's `color-string`
// https://github.com/harthur/color-string
// MIT License
return /^#([a-fA-F0-9]{3})$/.test(s) ||
/^#([a-fA-F0-9]{6})$/.test(s) ||
/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d\.]+)\s*)?\)$/.test(s) ||
/^rgba?\(\s*([\d\.]+)\%\s*,\s*([\d\.]+)\%\s*,\s*([\d\.]+)\%\s*(?:,\s*([\d\.]+)\s*)?\)$/.test(s);
}

View File

@ -0,0 +1,90 @@
/* 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";
/**
* Colors for themes taken from:
* https://developer.mozilla.org/en-US/docs/Tools/DevToolsColors
*/
const { Cu } = require("chrome");
const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
loader.lazyRequireGetter(this, "Services");
loader.lazyImporter(this, "gDevTools", "resource:///modules/devtools/gDevTools.jsm");
const themeURIs = {
light: "chrome://browser/skin/devtools/light-theme.css",
dark: "chrome://browser/skin/devtools/dark-theme.css"
}
const cachedThemes = {};
/**
* Returns a string of the file found at URI
*/
function readURI (uri) {
let stream = NetUtil.newChannel(uri, "UTF-8", null).open();
let count = stream.available();
let data = NetUtil.readInputStreamToString(stream, count, { charset: "UTF-8" });
stream.close();
return data;
}
/**
* Takes a theme name and either returns it from the cache,
* or fetches the theme CSS file and caches it.
*/
function getThemeFile (name) {
// Use the cached theme, or generate it
let themeFile = cachedThemes[name] || readURI(themeURIs[name]).match(/--theme-.*: .*;/g).join("\n");
// Cache if not already cached
if (!cachedThemes[name]) {
cachedThemes[name] = themeFile;
}
return themeFile;
}
/**
* Returns the string value of the current theme,
* like "dark" or "light".
*/
const getTheme = exports.getTheme = () => Services.prefs.getCharPref("devtools.theme");
/**
* Returns a color indicated by `type` (like "toolbar-background", or "highlight-red"),
* with the ability to specify a theme, or use whatever the current theme is
* if left unset. If theme not found, falls back to "light" theme. Returns null
* if the type cannot be found for the theme given.
*/
const getColor = exports.getColor = (type, theme) => {
let themeName = theme || getTheme();
// If there's no theme URIs for this theme, use `light` as default.
if (!themeURIs[themeName]) {
themeName = "light";
}
let themeFile = getThemeFile(themeName);
let match;
// Return the appropriate variable in the theme, or otherwise, null.
return (match = themeFile.match(new RegExp("--theme-" + type + ": (.*);"))) ? match[1] : null;
};
/**
* Mimics selecting the theme selector in the toolbox;
* sets the preference and emits an event on gDevTools to trigger
* the themeing.
*/
const setTheme = exports.setTheme = (newTheme) => {
Services.prefs.setCharPref("devtools.theme", newTheme);
gDevTools.emit("pref-changed", {
pref: "devtools.theme",
newValue: newTheme,
oldValue: getTheme()
});
};

View File

@ -1,5 +1,4 @@
[DEFAULT]
skip-if = e10s && os == 'linux' # bug 1104908
subsuite = devtools
support-files =
doc_content_stylesheet.html
@ -115,10 +114,12 @@ skip-if = e10s # bug 1040670 Cannot open inline styles in viewSourceUtils
[browser_styleinspector_refresh_when_active.js]
[browser_styleinspector_tooltip-background-image.js]
[browser_styleinspector_tooltip-closes-on-new-selection.js]
skip-if = e10s # Bug 1111546
[browser_styleinspector_tooltip-longhand-fontfamily.js]
[browser_styleinspector_tooltip-multiple-background-images.js]
[browser_styleinspector_tooltip-shorthand-fontfamily.js]
[browser_styleinspector_tooltip-size.js]
skip-if = e10s # Bug 1111546
[browser_styleinspector_transform-highlighter-01.js]
[browser_styleinspector_transform-highlighter-02.js]
[browser_styleinspector_transform-highlighter-03.js]

View File

@ -506,25 +506,19 @@ function fireCopyEvent(element) {
* polling timeouts after several tries and the promise rejects.
* @param {String} name Optional name of the test. This is used to generate
* the success and failure messages.
* @param {Number} timeout Optional timeout for the validator function, in
* milliseconds. Default is 5000.
* @return a promise that resolves when the function returned true or rejects
* if the timeout is reached
*/
function waitForSuccess(validatorFn, name="untitled", timeout=5000) {
function waitForSuccess(validatorFn, name="untitled") {
let def = promise.defer();
let start = Date.now();
function wait(validatorFn) {
if ((Date.now() - start) > timeout) {
ok(false, "Validator function " + name + " timed out");
return def.reject();
}
if (validatorFn()) {
ok(true, "Validator function " + name + " returned true");
def.resolve();
} else {
setTimeout(() => wait(validatorFn), 100);
setTimeout(() => wait(validatorFn), 200);
}
}
wait(validatorFn);

View File

@ -1,5 +1,4 @@
[DEFAULT]
skip-if = e10s # Bug ?????? - devtools tests disabled with e10s
subsuite = devtools
support-files =
head.js
@ -130,25 +129,28 @@ support-files =
[browser_bug1045902_console_csp_ignore_reflected_xss_message.js]
[browser_bug664688_sandbox_update_after_navigation.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests (intermittent Linux debug)
[browser_bug_638949_copy_link_location.js]
[browser_bug_862916_console_dir_and_filter_off.js]
[browser_bug_865288_repeat_different_objects.js]
[browser_bug_865871_variables_view_close_on_esc_key.js]
[browser_bug_869003_inspect_cross_domain_object.js]
[browser_bug_871156_ctrlw_close_tab.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests (intermittent Linux debug)
[browser_cached_messages.js]
skip-if = buildapp == 'mulet'
skip-if = buildapp == 'mulet' || e10s # Bug 1042253 - webconsole e10s tests (expectUncaughtException)
[browser_console.js]
[browser_console_addonsdk_loader_exception.js]
[browser_console_clear_on_reload.js]
[browser_console_click_focus.js]
[browser_console_consolejsm_output.js]
[browser_console_dead_objects.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_console_error_source_click.js]
skip-if = buildapp == 'mulet'
skip-if = buildapp == 'mulet' || e10s # Bug 1042253 - webconsole e10s tests
[browser_console_filters.js]
[browser_console_iframe_messages.js]
skip-if = buildapp == 'mulet'
skip-if = buildapp == 'mulet' || e10s # Bug 1042253 - webconsole e10s tests
[browser_console_keyboard_accessibility.js]
[browser_console_log_inspectable_object.js]
[browser_console_native_getters.js]
@ -156,18 +158,25 @@ skip-if = buildapp == 'mulet'
[browser_console_nsiconsolemessage.js]
skip-if = buildapp == 'mulet'
[browser_console_optimized_out_vars.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_console_private_browsing.js]
skip-if = buildapp == 'mulet'
skip-if = buildapp == 'mulet' || e10s # Bug 1042253 - webconsole e10s tests
[browser_console_variables_view.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_console_variables_view_dom_nodes.js]
[browser_console_variables_view_dont_sort_non_sortable_classes_properties.js]
skip-if = buildapp == 'mulet'
[browser_console_variables_view_while_debugging.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_console_variables_view_while_debugging_and_inspecting.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_eval_in_debugger_stackframe.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_eval_in_debugger_stackframe2.js]
[browser_jsterm_inspect.js]
[browser_longstring_hang.js]
[browser_netpanel_longstring_expand.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_output_breaks_after_console_dir_uninspectable.js]
[browser_output_longstring_expand.js]
[browser_repeated_messages_accuracy.js]
@ -184,37 +193,49 @@ skip-if = buildapp == 'mulet'
[browser_webconsole_bug_579412_input_focus.js]
[browser_webconsole_bug_580001_closing_after_completion.js]
[browser_webconsole_bug_580030_errors_after_page_reload.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
[browser_webconsole_bug_580454_timestamp_l10n.js]
[browser_webconsole_bug_582201_duplicate_errors.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
[browser_webconsole_bug_583816_No_input_and_Tab_key_pressed.js]
[browser_webconsole_bug_585237_line_limit.js]
[browser_webconsole_bug_585956_console_trace.js]
[browser_webconsole_bug_585991_autocomplete_keys.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_bug_585991_autocomplete_popup.js]
[browser_webconsole_bug_586388_select_all.js]
[browser_webconsole_bug_587617_output_copy.js]
[browser_webconsole_bug_588342_document_focus.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_bug_588730_text_node_insertion.js]
[browser_webconsole_bug_588967_input_expansion.js]
[browser_webconsole_bug_589162_css_filter.js]
[browser_webconsole_bug_592442_closing_brackets.js]
[browser_webconsole_bug_593003_iframe_wrong_hud.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_bug_594477_clickable_output.js]
[browser_webconsole_bug_594497_history_arrow_keys.js]
[browser_webconsole_bug_595223_file_uri.js]
[browser_webconsole_bug_595350_multiple_windows_and_tabs.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_bug_595934_message_categories.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
[browser_webconsole_bug_597103_deactivateHUDForContext_unfocused_window.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_bug_597136_external_script_errors.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
[browser_webconsole_bug_597136_network_requests_from_chrome.js]
[browser_webconsole_bug_597460_filter_scroll.js]
[browser_webconsole_bug_597756_reopen_closed_tab.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
[browser_webconsole_bug_599725_response_headers.js]
[browser_webconsole_bug_600183_charset.js]
[browser_webconsole_bug_601177_log_levels.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
[browser_webconsole_bug_601352_scroll.js]
[browser_webconsole_bug_601667_filter_buttons.js]
[browser_webconsole_bug_602572_log_bodies_checkbox.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_bug_603750_websocket.js]
[browser_webconsole_bug_611795.js]
[browser_webconsole_bug_613013_console_api_iframe.js]
@ -223,6 +244,7 @@ skip-if = buildapp == 'mulet'
[browser_webconsole_bug_613642_prune_scroll.js]
[browser_webconsole_bug_614793_jsterm_scroll.js]
[browser_webconsole_bug_618078_network_exceptions.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
[browser_webconsole_bug_618311_close_panels.js]
[browser_webconsole_bug_621644_jsterm_dollar.js]
[browser_webconsole_bug_622303_persistent_filters.js]
@ -231,13 +253,16 @@ run-if = os == "win"
[browser_webconsole_bug_630733_response_redirect_headers.js]
[browser_webconsole_bug_632275_getters_document_width.js]
[browser_webconsole_bug_632347_iterators_generators.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_bug_632817.js]
[browser_webconsole_bug_642108_pruneTest.js]
[browser_webconsole_autocomplete_and_selfxss.js]
[browser_webconsole_bug_644419_log_limits.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
[browser_webconsole_bug_646025_console_file_location.js]
[browser_webconsole_bug_651501_document_body_autocomplete.js]
[browser_webconsole_bug_653531_highlighter_console_helper.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_bug_658368_time_methods.js]
[browser_webconsole_bug_659907_console_dir.js]
[browser_webconsole_bug_660806_history_nav.js]
@ -247,13 +272,15 @@ run-if = os == "win"
[browser_webconsole_bug_734061_No_input_change_and_Tab_key_pressed.js]
[browser_webconsole_bug_737873_mixedcontent.js]
[browser_webconsole_bug_752559_ineffective_iframe_sandbox_warning.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
[browser_webconsole_bug_762593_insecure_passwords_about_blank_web_console_warning.js]
skip-if = buildapp == 'mulet'
[browser_webconsole_bug_762593_insecure_passwords_web_console_warning.js]
skip-if = buildapp == 'mulet'
skip-if = true # Bug 1110500 - mouse event failure in test
[browser_webconsole_bug_764572_output_open_url.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_bug_766001_JS_Console_in_Debugger.js]
skip-if = buildapp == 'mulet'
skip-if = buildapp == 'mulet' || e10s # Bug 1042253 - webconsole e10s tests (expectUncaughtException)
[browser_webconsole_bug_770099_violation.js]
[browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js]
skip-if = buildapp == 'mulet'
@ -263,17 +290,21 @@ run-if = os == "mac"
[browser_webconsole_bug_837351_securityerrors.js]
skip-if = buildapp == 'mulet'
[browser_webconsole_bug_846918_hsts_invalid-headers.js]
skip-if = buildapp == 'mulet'
skip-if = buildapp == 'mulet' || e10s # Bug 1042253 - webconsole e10s tests
[browser_webconsole_bug_915141_toggle_response_logging_with_keyboard.js]
[browser_webconsole_filter_buttons_contextmenu.js]
[browser_webconsole_bug_1006027_message_timestamps_incorrect.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug intermittent)
[browser_webconsole_bug_1010953_cspro.js]
[browser_webconsole_certificate_messages.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_cached_autocomplete.js]
[browser_webconsole_change_font_size.js]
[browser_webconsole_chrome.js]
[browser_webconsole_clickable_urls.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
[browser_webconsole_closure_inspection.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_completion.js]
[browser_webconsole_console_extras.js]
[browser_webconsole_console_logging_api.js]
@ -286,6 +317,7 @@ skip-if = buildapp == 'mulet'
[browser_webconsole_inspect-parsed-documents.js]
[browser_webconsole_js_input_expansion.js]
[browser_webconsole_jsterm.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
[browser_webconsole_live_filtering_of_message_types.js]
[browser_webconsole_live_filtering_on_search_strings.js]
[browser_webconsole_message_node_id.js]
@ -296,20 +328,26 @@ skip-if = buildapp == 'mulet'
[browser_webconsole_output_copy_newlines.js]
[browser_webconsole_output_order.js]
[browser_webconsole_property_provider.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_scratchpad_panel_link.js]
[browser_webconsole_split.js]
[browser_webconsole_split_escape_key.js]
[browser_webconsole_split_focus.js]
[browser_webconsole_split_persist.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
[browser_webconsole_view_source.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
[browser_webconsole_reflow.js]
[browser_webconsole_log_file_filter.js]
[browser_webconsole_expandable_timestamps.js]
[browser_webconsole_autocomplete_in_debugger_stackframe.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_autocomplete_popup_close_on_tab_switch.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_autocomplete-properties-with-non-alphanumeric-names.js]
[browser_console_hide_jsterm_when_devtools_chrome_enabled_false.js]
[browser_webconsole_output_01.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests
[browser_webconsole_output_02.js]
[browser_webconsole_output_03.js]
[browser_webconsole_output_04.js]
@ -317,8 +355,10 @@ skip-if = buildapp == 'mulet'
[browser_webconsole_output_06.js]
[browser_webconsole_output_dom_elements_01.js]
[browser_webconsole_output_dom_elements_02.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
[browser_webconsole_output_dom_elements_03.js]
[browser_webconsole_output_dom_elements_04.js]
skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
[browser_webconsole_output_events.js]
[browser_webconsole_output_table.js]
[browser_console_variables_view_highlighter.js]

View File

@ -16,38 +16,44 @@ const TEST_FILE = "http://example.com/browser/browser/devtools/webconsole/test/"
let hud = undefined;
function test() {
addTab("data:text/html;charset=utf8,Web Console CSP ignoring reflected XSS (bug 1045902)");
browser.addEventListener("load", function _onLoad() {
browser.removeEventListener("load", _onLoad, true);
openConsole(null, loadDocument);
}, true);
}
let TEST_URI = "data:text/html;charset=utf8,Web Console CSP ignoring reflected XSS (bug 1045902)";
let test = asyncTest(function* () {
let { browser } = yield loadTab(TEST_URI);
hud = yield openConsole();
yield loadDocument(browser);
yield testViolationMessage();
hud = null;
});
function loadDocument(browser) {
let deferred = promise.defer();
function loadDocument(theHud) {
hud = theHud;
hud.jsterm.clearOutput()
browser.addEventListener("load", onLoad, true);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
deferred.resolve();
}, true);
content.location = TEST_FILE;
}
function onLoad(aEvent) {
browser.removeEventListener("load", onLoad, true);
testViolationMessage();
return deferred.promise;
}
function testViolationMessage() {
let deferred = promise.defer();
let aOutputNode = hud.outputNode;
waitForSuccess({
return waitForSuccess({
name: "Confirming that CSP logs messages to the console when 'reflected-xss' directive is used!",
validatorFn: function() {
validator: function() {
console.log(hud.outputNode.textContent);
let success = false;
success = hud.outputNode.textContent.indexOf(EXPECTED_RESULT) > -1;
return success;
},
successFn: finishTest,
failureFn: finishTest,
}
});
}

View File

@ -7,107 +7,85 @@
// domain to another, in order to avoid permission denied errors with a sandbox
// created for a different origin.
function test()
{
"use strict";
let test = asyncTest(function* () {
const TEST_URI1 = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
const TEST_URI2 = "http://example.org/browser/browser/devtools/webconsole/test/test-console.html";
let hud;
let msgForLocation1;
yield loadTab(TEST_URI1);
let hud = yield openConsole();
waitForExplicitFinish();
hud.jsterm.clearOutput();
hud.jsterm.execute("window.location.href");
gBrowser.selectedTab = gBrowser.addTab(TEST_URI1);
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
openConsole(gBrowser.selectedTab, pageLoad1);
}, true);
info("wait for window.location.href");
function pageLoad1(aHud)
{
hud = aHud;
let msgForLocation1 = {
webconsole: hud,
messages: [
{
name: "window.location.href jsterm input",
text: "window.location.href",
category: CATEGORY_INPUT,
},
{
name: "window.location.href result is displayed",
text: TEST_URI1,
category: CATEGORY_OUTPUT,
},
],
};
hud.jsterm.clearOutput();
hud.jsterm.execute("window.location.href");
yield waitForMessages(msgForLocation1);
info("wait for window.location.href");
// load second url
content.location = TEST_URI2;
yield loadBrowser(gBrowser.selectedBrowser);
msgForLocation1 = {
webconsole: hud,
messages: [
{
name: "window.location.href jsterm input",
text: "window.location.href",
category: CATEGORY_INPUT,
},
{
name: "window.location.href result is displayed",
text: TEST_URI1,
category: CATEGORY_OUTPUT,
},
]
};
is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
"no permission denied errors");
waitForMessages(msgForLocation1).then(() => {
gBrowser.selectedBrowser.addEventListener("load", onPageLoad2, true);
content.location = TEST_URI2;
});
}
hud.jsterm.clearOutput();
hud.jsterm.execute("window.location.href");
function onPageLoad2() {
gBrowser.selectedBrowser.removeEventListener("load", onPageLoad2, true);
info("wait for window.location.href after page navigation");
is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
"no permission denied errors");
yield waitForMessages({
webconsole: hud,
messages: [
{
name: "window.location.href jsterm input",
text: "window.location.href",
category: CATEGORY_INPUT,
},
{
name: "window.location.href result is displayed",
text: TEST_URI2,
category: CATEGORY_OUTPUT,
},
],
});
hud.jsterm.clearOutput();
hud.jsterm.execute("window.location.href");
is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
"no permission denied errors");
info("wait for window.location.href after page navigation");
gBrowser.goBack();
waitForMessages({
webconsole: hud,
messages: [
{
name: "window.location.href jsterm input",
text: "window.location.href",
category: CATEGORY_INPUT,
},
{
name: "window.location.href result is displayed",
text: TEST_URI2,
category: CATEGORY_OUTPUT,
},
]
}).then(() => {
is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
"no permission denied errors");
gBrowser.goBack();
waitForSuccess(waitForBack);
});
}
let waitForBack = {
yield waitForSuccess({
name: "go back",
validatorFn: function()
{
validator: function() {
return content.location.href == TEST_URI1;
},
successFn: function()
{
hud.jsterm.clearOutput();
executeSoon(() => {
hud.jsterm.execute("window.location.href");
});
});
info("wait for window.location.href after goBack()");
waitForMessages(msgForLocation1).then(() => executeSoon(() => {
is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
"no permission denied errors");
finishTest();
}));
},
failureFn: finishTest,
};
}
hud.jsterm.clearOutput();
executeSoon(() => {
hud.jsterm.execute("window.location.href");
});
info("wait for window.location.href after goBack()");
yield waitForMessages(msgForLocation1);
is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
"no permission denied errors");
});

View File

@ -3,116 +3,103 @@
* 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/. */
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/" +
"test/test-console.html?_date=" + Date.now();
const COMMAND_NAME = "consoleCmd_copyURL";
const CONTEXT_MENU_ID = "#menu_copyURL";
// Test for the "Copy link location" context menu item shown when you right
// click network requests in the output.
let HUD = null;
let output = null;
let menu = null;
"use strict";
let test = asyncTest(function* () {
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/" +
"test/test-console.html?_date=" + Date.now();
const COMMAND_NAME = "consoleCmd_copyURL";
const CONTEXT_MENU_ID = "#menu_copyURL";
function test() {
let originalNetPref = Services.prefs.getBoolPref("devtools.webconsole.filter.networkinfo");
registerCleanupFunction(() => {
Services.prefs.setBoolPref("devtools.webconsole.filter.networkinfo", originalNetPref);
HUD = output = menu = null;
Services.prefs.clearUserPref("devtools.webconsole.filter.networkinfo");
});
Services.prefs.setBoolPref("devtools.webconsole.filter.networkinfo", true);
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
yield loadTab(TEST_URI);
let hud = yield openConsole();
let output = hud.outputNode;
let menu = hud.iframeWindow.document.getElementById("output-contextmenu");
openConsole(null, function (aHud) {
HUD = aHud;
output = aHud.outputNode;
menu = HUD.iframeWindow.document.getElementById("output-contextmenu");
executeSoon(testWithoutNetActivity);
});
}, true);
}
// Return whether "Copy Link Location" command is enabled or not.
function isEnabled() {
let controller = top.document.commandDispatcher
.getControllerForCommand(COMMAND_NAME);
return controller && controller.isCommandEnabled(COMMAND_NAME);
}
function testWithoutNetActivity() {
HUD.jsterm.clearOutput();
hud.jsterm.clearOutput();
content.console.log("bug 638949");
// Test that the "Copy Link Location" command is disabled for non-network
// messages.
waitForMessages({
webconsole: HUD,
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
text: "bug 638949",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
}).then(onConsoleMessage);
}
});
function onConsoleMessage(aResults) {
output.focus();
let message = [...aResults[0].matched][0];
let message = [...result.matched][0];
goUpdateCommand(COMMAND_NAME);
ok(!isEnabled(), COMMAND_NAME + "is disabled");
ok(!isEnabled(), COMMAND_NAME + " is disabled");
// Test that the "Copy Link Location" menu item is hidden for non-network
// messages.
message.scrollIntoView();
waitForContextMenu(menu, message, () => {
yield waitForContextMenu(menu, message, () => {
let isHidden = menu.querySelector(CONTEXT_MENU_ID).hidden;
ok(isHidden, CONTEXT_MENU_ID + " is hidden");
}, testWithNetActivity);
}
});
function testWithNetActivity() {
HUD.jsterm.clearOutput();
hud.jsterm.clearOutput();
content.location.reload(); // Reloading will produce network logging
// Test that the "Copy Link Location" command is enabled and works
// as expected for any network-related message.
// This command should copy only the URL.
waitForMessages({
webconsole: HUD,
[result] = yield waitForMessages({
webconsole: hud,
messages: [{
text: "test-console.html",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
}],
}).then(onNetworkMessage);
}
});
function onNetworkMessage(aResults) {
output.focus();
let message = [...aResults[0].matched][0];
HUD.ui.output.selectMessage(message);
message = [...result.matched][0];
hud.ui.output.selectMessage(message);
goUpdateCommand(COMMAND_NAME);
ok(isEnabled(), COMMAND_NAME + " is enabled");
info("expected clipboard value: " + message.url);
let deferred = promise.defer();
waitForClipboard((aData) => { return aData.trim() == message.url; },
() => { goDoCommand(COMMAND_NAME) },
testMenuWithNetActivity, testMenuWithNetActivity);
() => { goDoCommand(COMMAND_NAME); },
() => { deferred.resolve(null); },
() => { deferred.reject(null); });
function testMenuWithNetActivity() {
// Test that the "Copy Link Location" menu item is visible for network-related
// messages.
message.scrollIntoView();
waitForContextMenu(menu, message, () => {
let isVisible = !menu.querySelector(CONTEXT_MENU_ID).hidden;
ok(isVisible, CONTEXT_MENU_ID + " is visible");
}, finishTest);
yield deferred.promise;
// Test that the "Copy Link Location" menu item is visible for network-related
// messages.
message.scrollIntoView();
yield waitForContextMenu(menu, message, () => {
let isVisible = !menu.querySelector(CONTEXT_MENU_ID).hidden;
ok(isVisible, CONTEXT_MENU_ID + " is visible");
});
// Return whether "Copy Link Location" command is enabled or not.
function isEnabled() {
let controller = top.document.commandDispatcher
.getControllerForCommand(COMMAND_NAME);
return controller && controller.isCommandEnabled(COMMAND_NAME);
}
}
});

View File

@ -5,30 +5,27 @@
// Check that the output for console.dir() works even if Logging filter is off.
"use strict";
const TEST_URI = "data:text/html;charset=utf8,<p>test for bug 862916";
function test()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
}
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
let hud = yield openConsole();
function consoleOpened(hud)
{
ok(hud, "web console opened");
hud.setFilterState("log", false);
registerCleanupFunction(() => hud.setFilterState("log", true));
content.wrappedJSObject.fooBarz = "bug862916";
hud.jsterm.execute("console.dir(window)");
hud.jsterm.once("variablesview-fetched", (aEvent, aVar) => {
ok(aVar, "variables view object");
findVariableViewProperties(aVar, [
{ name: "fooBarz", value: "bug862916" },
], { webconsole: hud }).then(finishTest);
});
}
hud.jsterm.execute("window.fooBarz = 'bug862916'; " +
"console.dir(window)");
let varView = yield hud.jsterm.once("variablesview-fetched");
ok(varView, "variables view object");
yield findVariableViewProperties(varView, [
{ name: "fooBarz", value: "bug862916" },
], { webconsole: hud });
});

View File

@ -6,28 +6,20 @@
// Test that makes sure messages are not considered repeated when console.log()
// is invoked with different objects, see bug 865288.
"use strict";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-repeated-messages.html";
let hud = null;
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
let hud = yield openConsole();
function test() {
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
}
function consoleOpened(aHud) {
hud = aHud;
// Check that css warnings are not coalesced if they come from different lines.
info("waiting for 3 console.log objects");
hud.jsterm.clearOutput(true);
content.wrappedJSObject.testConsoleObjects();
hud.jsterm.execute("window.testConsoleObjects()");
waitForMessages({
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
name: "3 console.log messages",
@ -38,44 +30,34 @@ function consoleOpened(aHud) {
repeats: 1,
objects: true,
}],
}).then(checkMessages);
}
});
function checkMessages([result])
{
let msgs = [...result.matched];
is(msgs.length, 3, "3 message elements");
let m = -1;
function nextMessage()
{
let msg = msgs[++m];
if (msg) {
ok(msg, "message element #" + m);
for (let i = 0; i < msgs.length; i++) {
info("test message element #" + i);
let clickable = msg.querySelector(".message-body a");
ok(clickable, "clickable object #" + m);
let msg = msgs[i];
let clickable = msg.querySelector(".message-body a");
ok(clickable, "clickable object #" + i);
msg.scrollIntoView(false);
clickObject(clickable);
}
else {
finishTest();
}
msg.scrollIntoView(false);
yield clickObject(clickable, i);
}
nextMessage();
function clickObject(aObject)
function* clickObject(obj, i)
{
hud.jsterm.once("variablesview-fetched", onObjectFetch);
EventUtils.synthesizeMouse(aObject, 2, 2, {}, hud.iframeWindow);
}
executeSoon(() => {
EventUtils.synthesizeMouse(obj, 2, 2, {}, hud.iframeWindow);
});
function onObjectFetch(aEvent, aVar)
{
findVariableViewProperties(aVar, [
{ name: "id", value: "abba" + m },
], { webconsole: hud }).then(nextMessage);
let varView = yield hud.jsterm.once("variablesview-fetched");
ok(varView, "variables view fetched #" + i);
yield findVariableViewProperties(varView, [
{ name: "id", value: "abba" + i },
], { webconsole: hud });
}
}
});

View File

@ -6,6 +6,8 @@
// Check that the variables view sidebar can be closed by pressing Escape in the
// web console.
"use strict";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-eval-in-stackframe.html";
function test()
@ -44,9 +46,6 @@ function test()
let prop = result.matchedProp;
ok(prop, "matched the |testProp| property in the variables view");
is(content.wrappedJSObject.fooObj.testProp, result.value,
"|fooObj.testProp| value is correct");
vview.window.focus();
executeSoon(() => {

View File

@ -6,31 +6,22 @@
// Check that users can inspect objects logged from cross-domain iframes -
// bug 869003.
"use strict";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug-869003-top-window.html";
let gWebConsole, gJSTerm, gVariablesView;
function test()
{
let test = asyncTest(function* () {
// This test is slightly more involved: it opens the web console, then the
// variables view for a given object, it updates a property in the view and
// checks the result. We can get a timeout with debug builds on slower machines.
requestLongerTimeout(2);
addTab("data:text/html;charset=utf8,<p>hello");
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
}
yield loadTab("data:text/html;charset=utf8,<p>hello");
let hud = yield openConsole();
function consoleOpened(hud)
{
gWebConsole = hud;
gJSTerm = hud.jsterm;
content.location = TEST_URI;
waitForMessages({
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
name: "console.log message",
@ -39,61 +30,47 @@ function consoleOpened(hud)
severity: SEVERITY_LOG,
objects: true,
}],
}).then(onConsoleMessage);
}
});
function onConsoleMessage(aResults)
{
let msg = [...aResults[0].matched][0];
let msg = [...result.matched][0];
ok(msg, "message element");
let body = msg.querySelector(".message-body");
ok(body, "message body");
let clickable = aResults[0].clickableElements[0];
let clickable = result.clickableElements[0];
ok(clickable, "clickable object found");
ok(body.textContent.contains('{ hello: "world!",'), "message text check");
gJSTerm.once("variablesview-fetched", onObjFetch);
executeSoon(() => {
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow)
});
EventUtils.synthesizeMouse(clickable, 2, 2, {}, gWebConsole.iframeWindow)
}
let aVar = yield hud.jsterm.once("variablesview-fetched");
ok(aVar, "variables view fetched");
ok(aVar._variablesView, "variables view object");
function onObjFetch(aEvent, aVar)
{
gVariablesView = aVar._variablesView;
ok(gVariablesView, "variables view object");
findVariableViewProperties(aVar, [
[result] = yield findVariableViewProperties(aVar, [
{ name: "hello", value: "world!" },
{ name: "bug", value: 869003 },
], { webconsole: gWebConsole }).then(onPropFound);
}
], { webconsole: hud });
function onPropFound(aResults)
{
let prop = aResults[0].matchedProp;
let prop = result.matchedProp;
ok(prop, "matched the |hello| property in the variables view");
// Check that property value updates work.
updateVariablesViewProperty({
aVar = yield updateVariablesViewProperty({
property: prop,
field: "value",
string: "'omgtest'",
webconsole: gWebConsole,
callback: onFetchAfterUpdate,
webconsole: hud,
});
}
function onFetchAfterUpdate(aEvent, aVar)
{
info("onFetchAfterUpdate");
findVariableViewProperties(aVar, [
yield findVariableViewProperties(aVar, [
{ name: "hello", value: "omgtest" },
{ name: "bug", value: 869003 },
], { webconsole: gWebConsole }).then(() => {
gWebConsole = gJSTerm = gVariablesView = null;
finishTest();
});
}
], { webconsole: hud });
});

View File

@ -6,78 +6,74 @@
// Check that Ctrl-W closes the Browser Console and that Ctrl-W closes the
// current tab when using the Web Console - bug 871156.
function test()
{
"use strict";
let test = asyncTest(function* () {
const TEST_URI = "data:text/html;charset=utf8,<title>bug871156</title>\n" +
"<p>hello world";
let firstTab = gBrowser.selectedTab;
Services.prefs.setBoolPref("browser.tabs.animate", false);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("browser.tabs.animate");
});
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
yield loadTab(TEST_URI);
function consoleOpened(hud)
{
ok(hud, "Web Console opened");
let hud = yield openConsole();
ok(hud, "Web Console opened");
let tabClosed = promise.defer();
let toolboxDestroyed = promise.defer();
let tabSelected = promise.defer();
let tabClosed = promise.defer();
let toolboxDestroyed = promise.defer();
let tabSelected = promise.defer();
let pageWindow = firstTab.linkedBrowser.contentWindow;
let toolbox = gDevTools.getToolbox(hud.target);
let target = TargetFactory.forTab(gBrowser.selectedTab);
let toolbox = gDevTools.getToolbox(target);
gBrowser.tabContainer.addEventListener("TabClose", function onTabClose() {
gBrowser.tabContainer.removeEventListener("TabClose", onTabClose);
info("tab closed");
tabClosed.resolve(null);
});
gBrowser.tabContainer.addEventListener("TabClose", function onTabClose() {
gBrowser.tabContainer.removeEventListener("TabClose", onTabClose);
info("tab closed");
tabClosed.resolve(null);
});
gBrowser.tabContainer.addEventListener("TabSelect", function onTabSelect() {
gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect);
if (gBrowser.selectedTab == firstTab) {
info("tab selected");
tabSelected.resolve(null);
}
});
gBrowser.tabContainer.addEventListener("TabSelect", function onTabSelect() {
gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect);
if (gBrowser.selectedTab == firstTab) {
info("tab selected");
tabSelected.resolve(null);
}
});
toolbox.once("destroyed", () => {
info("toolbox destroyed");
toolboxDestroyed.resolve(null);
});
toolbox.once("destroyed", () => {
info("toolbox destroyed");
toolboxDestroyed.resolve(null);
});
promise.all([tabClosed.promise, toolboxDestroyed.promise, tabSelected.promise ]).then(() => {
info("promise.all resolved");
waitForFocus(testBrowserConsole, pageWindow, true);
});
// Get out of the web console initialization.
executeSoon(() => {
EventUtils.synthesizeKey("w", { accelKey: true });
});
// Get out of the web console initialization.
executeSoon(() => {
EventUtils.synthesizeKey("w", { accelKey: true });
});
}
function testBrowserConsole()
{
info("test the Browser Console");
yield promise.all([tabClosed.promise, toolboxDestroyed.promise,
tabSelected.promise]);
info("promise.all resolved. start testing the Browser Console");
HUDService.toggleBrowserConsole().then((hud) => {
ok(hud, "Browser Console opened");
hud = yield HUDService.toggleBrowserConsole();
ok(hud, "Browser Console opened");
Services.obs.addObserver(function onDestroy() {
Services.obs.removeObserver(onDestroy, "web-console-destroyed");
ok(true, "the Browser Console closed");
let deferred = promise.defer();
Services.prefs.clearUserPref("browser.tabs.animate");
waitForFocus(finish, content, true);
}, "web-console-destroyed", false);
Services.obs.addObserver(function onDestroy() {
Services.obs.removeObserver(onDestroy, "web-console-destroyed");
ok(true, "the Browser Console closed");
waitForFocus(() => {
EventUtils.synthesizeKey("w", { accelKey: true }, hud.iframeWindow);
}, hud.iframeWindow);
});
}
}
deferred.resolve(null);
}, "web-console-destroyed", false);
waitForFocus(() => {
EventUtils.synthesizeKey("w", { accelKey: true }, hud.iframeWindow);
}, hud.iframeWindow);
yield deferred.promise;
});

View File

@ -13,16 +13,12 @@ function test()
expectUncaughtException();
addTab(TEST_URI);
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
testOpenUI(true);
}, true);
loadTab(TEST_URI).then(testOpenUI);
}
function testOpenUI(aTestReopen)
{
openConsole(null, function(hud) {
openConsole().then((hud) => {
waitForMessages({
webconsole: hud,
messages: [
@ -48,7 +44,7 @@ function testOpenUI(aTestReopen)
},
],
}).then(() => {
closeConsole(gBrowser.selectedTab, function() {
closeConsole(gBrowser.selectedTab).then(() => {
aTestReopen && info("will reopen the Web Console");
executeSoon(aTestReopen ? testOpenUI : finishTest);
});

View File

@ -7,24 +7,23 @@
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html?" + Date.now();
function test()
{
Services.obs.addObserver(function observer(aSubject) {
Services.obs.removeObserver(observer, "web-console-created");
aSubject.QueryInterface(Ci.nsISupportsString);
"use strict";
let hud = HUDService.getBrowserConsole();
ok(hud, "browser console is open");
is(aSubject.data, hud.hudId, "notification hudId is correct");
let test = asyncTest(function*() {
yield loadTab(TEST_URI);
executeSoon(() => consoleOpened(hud));
}, "web-console-created", false);
let opened = waitForConsole();
let hud = HUDService.getBrowserConsole();
ok(!hud, "browser console is not open");
info("wait for the browser console to open with ctrl-shift-j");
EventUtils.synthesizeKey("j", { accelKey: true, shiftKey: true }, window);
}
hud = yield opened;
ok(hud, "browser console opened");
yield consoleOpened(hud);
});
function consoleOpened(hud)
{
@ -50,7 +49,7 @@ function consoleOpened(hud)
xhr.open("get", TEST_URI, true);
xhr.send();
waitForMessages({
return waitForMessages({
webconsole: hud,
messages: [
{
@ -84,5 +83,22 @@ function consoleOpened(hud)
severity: SEVERITY_LOG,
},
],
}).then(finishTest);
});
}
function waitForConsole() {
let deferred = promise.defer();
Services.obs.addObserver(function observer(aSubject) {
Services.obs.removeObserver(observer, "web-console-created");
aSubject.QueryInterface(Ci.nsISupportsString);
let hud = HUDService.getBrowserConsole();
ok(hud, "browser console is open");
is(aSubject.data, hud.hudId, "notification hudId is correct");
executeSoon(() => deferred.resolve(hud));
}, "web-console-created", false);
return deferred.promise;
}

View File

@ -7,6 +7,8 @@
// opened correctly in View Source from the Browser Console.
// See bug 866950.
"use strict";
const TEST_URI = "data:text/html;charset=utf8,<p>hello world from bug 866950";
function test()

View File

@ -5,69 +5,50 @@
// Check that clear output on page reload works - bug 705921.
function test()
{
"use strict";
let test = asyncTest(function*() {
const PREF = "devtools.webconsole.persistlog";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
let hud = null;
Services.prefs.setBoolPref(PREF, false);
registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
addTab(TEST_URI);
yield loadTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
let hud = yield openConsole();
ok(hud, "Web Console opened");
function consoleOpened(aHud)
{
hud = aHud;
ok(hud, "Web Console opened");
hud.jsterm.clearOutput();
hud.jsterm.execute("console.log('foobarz1')");
hud.jsterm.clearOutput();
content.console.log("foobarz1");
waitForMessages({
webconsole: hud,
messages: [{
text: "foobarz1",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
}).then(onConsoleMessage);
}
yield waitForMessages({
webconsole: hud,
messages: [{
text: "foobarz1",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
});
function onConsoleMessage()
{
browser.addEventListener("load", onReload, true);
content.location.reload();
}
BrowserReload();
yield loadBrowser(gBrowser.selectedBrowser);
function onReload()
{
browser.removeEventListener("load", onReload, true);
hud.jsterm.execute("console.log('foobarz2')");
content.console.log("foobarz2");
yield waitForMessages({
webconsole: hud,
messages: [{
text: "test-console.html",
category: CATEGORY_NETWORK,
},
{
text: "foobarz2",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
});
waitForMessages({
webconsole: hud,
messages: [{
text: "test-console.html",
category: CATEGORY_NETWORK,
},
{
text: "foobarz2",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
}).then(onConsoleMessageAfterReload);
}
function onConsoleMessageAfterReload()
{
is(hud.outputNode.textContent.indexOf("foobarz1"), -1,
"foobarz1 has been removed from output");
finishTest();
}
}
is(hud.outputNode.textContent.indexOf("foobarz1"), -1,
"foobarz1 has been removed from output");
});

View File

@ -5,56 +5,51 @@
// Tests that the input field is focused when the console is opened.
"use strict";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
function test() {
addTab(TEST_URI);
browser.addEventListener("DOMContentLoaded", testInputFocus, false);
}
let test = asyncTest(function*() {
yield loadTab(TEST_URI);
let hud = yield openConsole();
function testInputFocus() {
browser.removeEventListener("DOMContentLoaded", testInputFocus, false);
openConsole().then((hud) => {
waitForMessages({
webconsole: hud,
messages: [{
text: "Dolske Digs Bacon",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
}).then(([result]) => {
let msg = [...result.matched][0];
let outputItem = msg.querySelector(".message-body");
ok(outputItem, "found a logged message");
let inputNode = hud.jsterm.inputNode;
ok(inputNode.getAttribute("focused"), "input node is focused, first");
let lostFocus = () => {
inputNode.removeEventListener("blur", lostFocus);
info("input node lost focus");
}
inputNode.addEventListener("blur", lostFocus);
browser.ownerDocument.getElementById("urlbar").click();
ok(!inputNode.getAttribute("focused"), "input node is not focused");
EventUtils.sendMouseEvent({type: "click"}, hud.outputNode);
ok(inputNode.getAttribute("focused"), "input node is focused, second time")
// test click-drags are not focusing the input element.
EventUtils.sendMouseEvent({type: "mousedown", clientX: 3, clientY: 4},
outputItem);
EventUtils.sendMouseEvent({type: "click", clientX: 15, clientY: 5},
outputItem);
executeSoon(() => {
todo(!inputNode.getAttribute("focused"), "input node is not focused after drag");
finishTest();
});
});
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
text: "Dolske Digs Bacon",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
});
}
let msg = [...result.matched][0];
let outputItem = msg.querySelector(".message-body");
ok(outputItem, "found a logged message");
let inputNode = hud.jsterm.inputNode;
ok(inputNode.getAttribute("focused"), "input node is focused, first");
let lostFocus = () => {
inputNode.removeEventListener("blur", lostFocus);
info("input node lost focus");
}
inputNode.addEventListener("blur", lostFocus);
document.getElementById("urlbar").click();
ok(!inputNode.getAttribute("focused"), "input node is not focused");
EventUtils.sendMouseEvent({type: "click"}, hud.outputNode);
ok(inputNode.getAttribute("focused"), "input node is focused, second time")
// test click-drags are not focusing the input element.
EventUtils.sendMouseEvent({type: "mousedown", clientX: 3, clientY: 4},
outputItem);
EventUtils.sendMouseEvent({type: "click", clientX: 15, clientY: 5},
outputItem);
todo(!inputNode.getAttribute("focused"), "input node is not focused after drag");
});

View File

@ -5,131 +5,133 @@
// Test that Console.jsm outputs messages to the Browser Console, bug 851231.
function test()
{
"use strict";
let test = asyncTest(function*() {
let storage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(Ci.nsIConsoleAPIStorage);
storage.clearEvents();
let console = Cu.import("resource://gre/modules/devtools/Console.jsm", {}).console;
console.log("bug861338-log-cached");
HUDService.toggleBrowserConsole().then(consoleOpened);
let hud = null;
let hud = yield HUDService.toggleBrowserConsole();
function consoleOpened(aHud)
{
hud = aHud;
waitForMessages({
webconsole: hud,
messages: [{
name: "cached console.log message",
text: "bug861338-log-cached",
yield waitForMessages({
webconsole: hud,
messages: [{
name: "cached console.log message",
text: "bug861338-log-cached",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
});
hud.jsterm.clearOutput(true);
function testTrace() {
console.trace();
}
console.time("foobarTimer");
let foobar = { bug851231prop: "bug851231value" };
console.log("bug851231-log");
console.info("bug851231-info");
console.warn("bug851231-warn");
console.error("bug851231-error", foobar);
console.debug("bug851231-debug");
console.dir(document);
testTrace();
console.timeEnd("foobarTimer");
info("wait for the Console.jsm messages");
let results = yield waitForMessages({
webconsole: hud,
messages: [
{
name: "console.log output",
text: "bug851231-log",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
}).then(onCachedMessage);
}
function onCachedMessage()
{
hud.jsterm.clearOutput(true);
console.time("foobarTimer");
let foobar = { bug851231prop: "bug851231value" };
console.log("bug851231-log");
console.info("bug851231-info");
console.warn("bug851231-warn");
console.error("bug851231-error", foobar);
console.debug("bug851231-debug");
console.trace();
console.dir(document);
console.timeEnd("foobarTimer");
info("wait for the Console.jsm messages");
waitForMessages({
webconsole: hud,
messages: [
{
name: "console.log output",
text: "bug851231-log",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
},
{
name: "console.info output",
text: "bug851231-info",
category: CATEGORY_WEBDEV,
severity: SEVERITY_INFO,
},
{
name: "console.warn output",
text: "bug851231-warn",
category: CATEGORY_WEBDEV,
severity: SEVERITY_WARNING,
},
{
name: "console.error output",
text: /\bbug851231-error\b.+\{\s*bug851231prop:\s"bug851231value"\s*\}/,
category: CATEGORY_WEBDEV,
severity: SEVERITY_ERROR,
objects: true,
},
{
name: "console.debug output",
text: "bug851231-debug",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
},
{
name: "console.trace output",
consoleTrace: {
file: "browser_console_consolejsm_output.js",
fn: "testTrace",
},
{
name: "console.info output",
text: "bug851231-info",
category: CATEGORY_WEBDEV,
severity: SEVERITY_INFO,
},
{
name: "console.warn output",
text: "bug851231-warn",
category: CATEGORY_WEBDEV,
severity: SEVERITY_WARNING,
},
{
name: "console.error output",
text: /\bbug851231-error\b.+\{\s*bug851231prop:\s"bug851231value"\s*\}/,
category: CATEGORY_WEBDEV,
severity: SEVERITY_ERROR,
objects: true,
},
{
name: "console.debug output",
text: "bug851231-debug",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
},
{
name: "console.trace output",
consoleTrace: {
file: "browser_console_consolejsm_output.js",
fn: "onCachedMessage",
},
},
{
name: "console.dir output",
consoleDir: /XULDocument\s+.+\s+chrome:\/\/.+\/browser\.xul/,
},
{
name: "console.time output",
consoleTime: "foobarTimer",
},
{
name: "console.timeEnd output",
consoleTimeEnd: "foobarTimer",
},
],
}).then((aResults) => {
let consoleErrorMsg = aResults[3];
ok(consoleErrorMsg, "console.error message element found");
let clickable = consoleErrorMsg.clickableElements[0];
ok(clickable, "clickable object found for console.error");
},
{
name: "console.dir output",
consoleDir: /XULDocument\s+.+\s+chrome:\/\/.+\/browser\.xul/,
},
{
name: "console.time output",
consoleTime: "foobarTimer",
},
{
name: "console.timeEnd output",
consoleTimeEnd: "foobarTimer",
},
],
});
let onFetch = (aEvent, aVar) => {
// Skip the notification from console.dir variablesview-fetched.
if (aVar._variablesView != hud.jsterm._variablesView) {
return;
}
hud.jsterm.off("variablesview-fetched", onFetch);
let consoleErrorMsg = results[3];
ok(consoleErrorMsg, "console.error message element found");
let clickable = consoleErrorMsg.clickableElements[0];
ok(clickable, "clickable object found for console.error");
ok(aVar, "object inspector opened on click");
let deferred = promise.defer();
findVariableViewProperties(aVar, [{
name: "bug851231prop",
value: "bug851231value",
}], { webconsole: hud }).then(finishTest);
};
let onFetch = (aEvent, aVar) => {
// Skip the notification from console.dir variablesview-fetched.
if (aVar._variablesView != hud.jsterm._variablesView) {
return;
}
hud.jsterm.off("variablesview-fetched", onFetch);
hud.jsterm.on("variablesview-fetched", onFetch);
deferred.resolve(aVar);
};
clickable.scrollIntoView(false);
hud.jsterm.on("variablesview-fetched", onFetch);
info("wait for variablesview-fetched");
executeSoon(() =>
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow));
});
}
}
clickable.scrollIntoView(false);
info("wait for variablesview-fetched");
executeSoon(() =>
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow));
let varView = yield deferred.promise;
ok(varView, "object inspector opened on click");
yield findVariableViewProperties(varView, [{
name: "bug851231prop",
value: "bug851231value",
}], { webconsole: hud });
});

View File

@ -12,6 +12,8 @@
// - tries to use the object that was pointing to the now-defunct content
// document. This is the dead object.
"use strict";
const TEST_URI = "data:text/html;charset=utf8,<p>dead objects!";
function test()
@ -33,11 +35,12 @@ function test()
hud = yield HUDService.toggleBrowserConsole();
ok(hud, "browser console opened");
hud.jsterm.clearOutput();
let jsterm = hud.jsterm;
jsterm.clearOutput();
// Add the reference to the content document.
yield execute("Cu = Components.utils;" +
yield jsterm.execute("Cu = Components.utils;" +
"Cu.import('resource://gre/modules/Services.jsm');" +
"chromeWindow = Services.wm.getMostRecentWindow('navigator:browser');" +
"foobarzTezt = chromeWindow.content.document;" +
@ -45,18 +48,18 @@ function test()
gBrowser.removeCurrentTab();
let msg = yield execute("foobarzTezt");
let msg = yield jsterm.execute("foobarzTezt");
isnot(hud.outputNode.textContent.indexOf("[object DeadObject]"), -1,
"dead object found");
hud.jsterm.setInputValue("foobarzTezt");
jsterm.setInputValue("foobarzTezt");
for (let c of ".hello") {
EventUtils.synthesizeKey(c, {}, hud.iframeWindow);
}
yield execute();
yield jsterm.execute();
isnot(hud.outputNode.textContent.indexOf("can't access dead object"), -1,
"'cannot access dead object' message found");
@ -73,19 +76,11 @@ function test()
EventUtils.synthesizeMouseAtCenter(clickable, {}, hud.iframeWindow);
});
yield hud.jsterm.once("variablesview-fetched");
yield jsterm.once("variablesview-fetched");
ok(true, "variables view fetched");
msg = yield execute("delete window.foobarzTezt; 2013-26");
msg = yield jsterm.execute("delete window.foobarzTezt; 2013-26");
isnot(msg.textContent.indexOf("1987"), -1, "result message found");
}
function execute(str) {
let deferred = promise.defer();
hud.jsterm.execute(str, (msg) => {
deferred.resolve(msg);
});
return deferred.promise;
}
}

View File

@ -13,11 +13,9 @@ function test()
{
let hud;
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
loadTab(TEST_URI).then(() => {
HUDService.toggleBrowserConsole().then(browserConsoleOpened);
}, true);
});
function browserConsoleOpened(aHud)
{

View File

@ -6,22 +6,17 @@
// Check that the Browser Console does not use the same filter prefs as the Web
// Console. See bug 878186.
"use strict";
const TEST_URI = "data:text/html;charset=utf8,<p>browser console filters";
const WEB_CONSOLE_PREFIX = "devtools.webconsole.filter.";
const BROWSER_CONSOLE_PREFIX = "devtools.browserconsole.filter.";
function test()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
info("open the web console");
openConsole(null, consoleOpened);
}, true);
}
let test = asyncTest(function*() {
yield loadTab(TEST_URI);
function consoleOpened(hud)
{
info("open the web console");
let hud = yield openConsole();
ok(hud, "web console opened");
is(Services.prefs.getBoolPref(BROWSER_CONSOLE_PREFIX + "exception"), true,
@ -39,17 +34,13 @@ function consoleOpened(hud)
hud.setFilterState("exception", true);
executeSoon(() => closeConsole(null, onWebConsoleClose));
}
// We need to let the console opening event loop to finish.
let deferred = promise.defer();
executeSoon(() => closeConsole().then(() => deferred.resolve(null)));
yield deferred.promise;
function onWebConsoleClose()
{
info("web console closed");
HUDService.toggleBrowserConsole().then(onBrowserConsoleOpen);
}
function onBrowserConsoleOpen(hud)
{
hud = yield HUDService.toggleBrowserConsole();
ok(hud, "browser console opened");
is(Services.prefs.getBoolPref(BROWSER_CONSOLE_PREFIX + "exception"), true,
@ -66,6 +57,4 @@ function onBrowserConsoleOpen(hud)
"'exception' filter is enabled (web console)");
hud.setFilterState("exception", true);
executeSoon(finishTest);
}
});

View File

@ -8,7 +8,7 @@
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-consoleiframes.html";
let expectedMessages = [
const expectedMessages = [
{
text: "main file",
category: CATEGORY_WEBDEV,
@ -35,7 +35,7 @@ let expectedMessages = [
// other in the sequence of messages (depending on timing). If they do not, then
// they will be displayed in the console output independently, as separate
// messages. This is why we need to match any of the following two rules.
let expectedMessagesAny = [
const expectedMessagesAny = [
{
name: "iframe 1 (count: 2)",
text: "iframe 1",
@ -55,12 +55,9 @@ let expectedMessagesAny = [
function test()
{
expectUncaughtException();
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
info("open web console");
openConsole(null, consoleOpened);
}, true);
loadTab(TEST_URI).then(() => {
openConsole().then(consoleOpened);
});
}
function consoleOpened(hud)
@ -77,7 +74,7 @@ function consoleOpened(hud)
messages: expectedMessagesAny,
matchCondition: "any",
}).then(() => {
closeConsole(null, onWebConsoleClose);
closeConsole().then(onWebConsoleClose);
});
});
}
@ -101,7 +98,7 @@ function onBrowserConsoleOpen(hud)
messages: expectedMessagesAny,
matchCondition: "any",
}).then(() => {
closeConsole(null, finishTest);
closeConsole().then(finishTest);
});
});
}

View File

@ -5,86 +5,75 @@
// Check that basic keyboard shortcuts work in the web console.
function test()
{
"use strict";
let test = asyncTest(function*() {
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
let hud = null;
addTab(TEST_URI);
yield loadTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
let hud = yield openConsole();
ok(hud, "Web Console opened");
function consoleOpened(aHud)
{
hud = aHud;
ok(hud, "Web Console opened");
info("dump some spew into the console for scrolling");
hud.jsterm.execute("(function() { for (var i = 0; i < 100; i++) { " +
"console.log('foobarz' + i);" +
"}})();");
info("dump some spew into the console for scrolling");
for (let i = 0; i < 100; i++)
content.console.log("foobarz" + i);
waitForMessages({
webconsole: hud,
messages: [{
text: "foobarz99",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
}).then(onConsoleMessage);
yield waitForMessages({
webconsole: hud,
messages: [{
text: "foobarz99",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
});
let currentPosition = hud.outputNode.parentNode.scrollTop;
let bottom = currentPosition;
EventUtils.synthesizeKey("VK_PAGE_UP", {});
isnot(hud.outputNode.parentNode.scrollTop, currentPosition, "scroll position changed after page up");
currentPosition = hud.outputNode.parentNode.scrollTop;
EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
ok(hud.outputNode.parentNode.scrollTop > currentPosition, "scroll position now at bottom");
EventUtils.synthesizeKey("VK_HOME", {});
is(hud.outputNode.parentNode.scrollTop, 0, "scroll position now at top");
EventUtils.synthesizeKey("VK_END", {});
let scrollTop = hud.outputNode.parentNode.scrollTop;
ok(scrollTop > 0 && Math.abs(scrollTop - bottom) <= 5,
"scroll position now at bottom");
info("try ctrl-l to clear output");
executeSoon(() => { EventUtils.synthesizeKey("l", { ctrlKey: true }); });
yield hud.jsterm.once("messages-cleared");
is(hud.outputNode.textContent.indexOf("foobarz1"), -1, "output cleared");
is(hud.jsterm.inputNode.getAttribute("focused"), "true",
"jsterm input is focused");
info("try ctrl-f to focus filter");
EventUtils.synthesizeKey("F", { accelKey: true });
ok(!hud.jsterm.inputNode.getAttribute("focused"),
"jsterm input is not focused");
is(hud.ui.filterBox.getAttribute("focused"), "true",
"filter input is focused");
if (Services.appinfo.OS == "Darwin") {
ok(hud.ui.getFilterState("network"), "network category is enabled");
EventUtils.synthesizeKey("t", { ctrlKey: true });
ok(!hud.ui.getFilterState("network"), "accesskey for Network works");
EventUtils.synthesizeKey("t", { ctrlKey: true });
ok(hud.ui.getFilterState("network"), "accesskey for Network works (again)");
}
function onConsoleMessage()
{
let currentPosition = hud.outputNode.parentNode.scrollTop;
let bottom = currentPosition;
EventUtils.synthesizeKey("VK_PAGE_UP", {});
isnot(hud.outputNode.parentNode.scrollTop, currentPosition, "scroll position changed after page up");
currentPosition = hud.outputNode.parentNode.scrollTop;
EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
ok(hud.outputNode.parentNode.scrollTop > currentPosition, "scroll position now at bottom");
EventUtils.synthesizeKey("VK_HOME", {});
is(hud.outputNode.parentNode.scrollTop, 0, "scroll position now at top");
EventUtils.synthesizeKey("VK_END", {});
is(hud.outputNode.parentNode.scrollTop, bottom, "scroll position now at bottom");
hud.jsterm.once("messages-cleared", onClear);
info("try ctrl-l to clear output");
EventUtils.synthesizeKey("l", { ctrlKey: true });
else {
EventUtils.synthesizeKey("N", { altKey: true });
let net = hud.ui.document.querySelector("toolbarbutton[category=net]");
is(hud.ui.document.activeElement, net,
"accesskey for Network category focuses the Net button");
}
function onClear()
{
is(hud.outputNode.textContent.indexOf("foobarz1"), -1, "output cleared");
is(hud.jsterm.inputNode.getAttribute("focused"), "true",
"jsterm input is focused");
info("try ctrl-f to focus filter");
EventUtils.synthesizeKey("F", { accelKey: true });
ok(!hud.jsterm.inputNode.getAttribute("focused"),
"jsterm input is not focused");
is(hud.ui.filterBox.getAttribute("focused"), "true",
"filter input is focused");
if (Services.appinfo.OS == "Darwin") {
ok(hud.ui.getFilterState("network"), "network category is enabled");
EventUtils.synthesizeKey("t", { ctrlKey: true });
ok(!hud.ui.getFilterState("network"), "accesskey for Network works");
EventUtils.synthesizeKey("t", { ctrlKey: true });
ok(hud.ui.getFilterState("network"), "accesskey for Network works (again)");
}
else {
EventUtils.synthesizeKey("N", { altKey: true });
let net = hud.ui.document.querySelector("toolbarbutton[category=net]");
is(hud.ui.document.activeElement, net,
"accesskey for Network category focuses the Net button");
}
finishTest();
}
}
});

View File

@ -4,26 +4,18 @@
// Test that objects given to console.log() are inspectable.
function test()
{
waitForExplicitFinish();
"use strict";
addTab("data:text/html;charset=utf8,test for bug 676722 - inspectable objects for window.console");
let test = asyncTest(function*() {
yield loadTab("data:text/html;charset=utf8,test for bug 676722 - inspectable objects for window.console");
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
openConsole(null, performTest);
}, true);
}
function performTest(hud)
{
let hud = yield openConsole();
hud.jsterm.clearOutput(true);
hud.jsterm.execute("myObj = {abba: 'omgBug676722'}");
hud.jsterm.execute("console.log('fooBug676722', myObj)");
waitForMessages({
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
text: "fooBug676722",
@ -31,28 +23,28 @@ function performTest(hud)
severity: SEVERITY_LOG,
objects: true,
}],
}).then(([result]) => {
let msg = [...result.matched][0];
ok(msg, "message element");
let body = msg.querySelector(".message-body");
ok(body, "message body");
let clickable = result.clickableElements[0];
ok(clickable, "the console.log() object anchor was found");
ok(body.textContent.contains('{ abba: "omgBug676722" }'),
"clickable node content is correct");
hud.jsterm.once("variablesview-fetched",
(aEvent, aVar) => {
ok(aVar, "object inspector opened on click");
findVariableViewProperties(aVar, [{
name: "abba",
value: "omgBug676722",
}], { webconsole: hud }).then(finishTest);
});
executeSoon(function() {
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
});
});
}
let msg = [...result.matched][0];
ok(msg, "message element");
let body = msg.querySelector(".message-body");
ok(body, "message body");
let clickable = result.clickableElements[0];
ok(clickable, "the console.log() object anchor was found");
ok(body.textContent.contains('{ abba: "omgBug676722" }'),
"clickable node content is correct");
executeSoon(() => {
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
});
let varView = yield hud.jsterm.once("variablesview-fetched");
ok(varView, "object inspector opened on click");
yield findVariableViewProperties(varView, [{
name: "abba",
value: "omgBug676722",
}], { webconsole: hud });
});

View File

@ -6,116 +6,94 @@
// Check that native getters and setters for DOM elements work as expected in
// variables view - bug 870220.
"use strict";
const TEST_URI = "data:text/html;charset=utf8,<title>bug870220</title>\n" +
"<p>hello world\n<p>native getters!";
let gWebConsole, gJSTerm, gVariablesView;
let test = asyncTest(function*() {
yield loadTab(TEST_URI);
let hud = yield openConsole();
let jsterm = hud.jsterm;
function test()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
}
jsterm.execute("document");
function consoleOpened(hud)
{
gWebConsole = hud;
gJSTerm = hud.jsterm;
gJSTerm.execute("document");
waitForMessages({
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
text: "HTMLDocument \u2192 data:text/html;charset=utf8",
category: CATEGORY_OUTPUT,
objects: true,
}],
}).then(onEvalResult);
}
});
function onEvalResult(aResults)
{
let clickable = aResults[0].clickableElements[0];
let clickable = result.clickableElements[0];
ok(clickable, "clickable object found");
gJSTerm.once("variablesview-fetched", onDocumentFetch);
EventUtils.synthesizeMouse(clickable, 2, 2, {}, gWebConsole.iframeWindow)
}
executeSoon(() => {
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
});
function onDocumentFetch(aEvent, aVar)
{
gVariablesView = aVar._variablesView;
ok(gVariablesView, "variables view object");
let fetchedVar = yield jsterm.once("variablesview-fetched");
findVariableViewProperties(aVar, [
let variablesView = fetchedVar._variablesView;
ok(variablesView, "variables view object");
let results = yield findVariableViewProperties(fetchedVar, [
{ name: "title", value: "bug870220" },
{ name: "bgColor" },
], { webconsole: gWebConsole }).then(onDocumentPropsFound);
}
], { webconsole: hud });
function onDocumentPropsFound(aResults)
{
let prop = aResults[1].matchedProp;
let prop = results[1].matchedProp;
ok(prop, "matched the |bgColor| property in the variables view");
// Check that property value updates work.
updateVariablesViewProperty({
let updatedVar = yield updateVariablesViewProperty({
property: prop,
field: "value",
string: "'red'",
webconsole: gWebConsole,
callback: onFetchAfterBackgroundUpdate,
webconsole: hud,
});
}
function onFetchAfterBackgroundUpdate(aEvent, aVar)
{
info("onFetchAfterBackgroundUpdate");
info("on fetch after background update");
is(content.document.bgColor, "red", "document background color changed");
jsterm.clearOutput(true);
jsterm.execute("document.bgColor");
findVariableViewProperties(aVar, [
[result] = yield waitForMessages({
webconsole: hud,
messages: [{
text: "red",
category: CATEGORY_OUTPUT,
}],
});
yield findVariableViewProperties(updatedVar, [
{ name: "bgColor", value: "red" },
], { webconsole: gWebConsole }).then(testParagraphs);
}
], { webconsole: hud });
function testParagraphs()
{
gJSTerm.execute("$$('p')");
jsterm.execute("$$('p')");
waitForMessages({
webconsole: gWebConsole,
[result] = yield waitForMessages({
webconsole: hud,
messages: [{
text: "NodeList [",
category: CATEGORY_OUTPUT,
objects: true,
}],
}).then(onEvalNodeList);
}
});
function onEvalNodeList(aResults)
{
let clickable = aResults[0].clickableElements[0];
clickable = result.clickableElements[0];
ok(clickable, "clickable object found");
gJSTerm.once("variablesview-fetched", onNodeListFetch);
EventUtils.synthesizeMouse(clickable, 2, 2, {}, gWebConsole.iframeWindow)
}
executeSoon(() => {
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
});
function onNodeListFetch(aEvent, aVar)
{
gVariablesView = aVar._variablesView;
ok(gVariablesView, "variables view object");
fetchedVar = yield jsterm.once("variablesview-fetched");
findVariableViewProperties(aVar, [
yield findVariableViewProperties(fetchedVar, [
{ name: "0.textContent", value: /hello world/ },
{ name: "1.textContent", value: /native getters/ },
], { webconsole: gWebConsole }).then(() => {
gWebConsole = gJSTerm = gVariablesView = null;
finishTest();
});
}
], { webconsole: hud });
});

View File

@ -5,77 +5,71 @@
// Check that the navigation marker shows on page reload - bug 793996.
function test()
{
const PREF = "devtools.webconsole.persistlog";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
let hud = null;
let Messages = require("devtools/webconsole/console-output").Messages;
const PREF = "devtools.webconsole.persistlog";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
let hud;
let test = asyncTest(function* () {
Services.prefs.setBoolPref(PREF, true);
registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
addTab(TEST_URI);
let { browser } = yield loadTab(TEST_URI);
hud = yield openConsole();
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
yield consoleOpened();
function consoleOpened(aHud)
{
hud = aHud;
ok(hud, "Web Console opened");
let loaded = loadBrowser(browser);
BrowserReload();
yield loaded;
hud.jsterm.clearOutput();
content.console.log("foobarz1");
waitForMessages({
webconsole: hud,
messages: [{
text: "foobarz1",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
}).then(onConsoleMessage);
}
yield onReload();
function onConsoleMessage()
{
browser.addEventListener("load", onReload, true);
content.location.reload();
}
isnot(hud.outputNode.textContent.indexOf("foobarz1"), -1,
"foobarz1 is still in the output");
function onReload()
{
browser.removeEventListener("load", onReload, true);
Services.prefs.clearUserPref(PREF);
content.console.log("foobarz2");
hud = null;
});
waitForMessages({
webconsole: hud,
messages: [{
name: "page reload",
text: "test-console.html",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
},
{
text: "foobarz2",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
},
{
name: "navigation marker",
text: "test-console.html",
type: Messages.NavigationMarker,
}],
}).then(onConsoleMessageAfterReload);
}
function consoleOpened()
{
ok(hud, "Web Console opened");
function onConsoleMessageAfterReload()
{
isnot(hud.outputNode.textContent.indexOf("foobarz1"), -1,
"foobarz1 is still in the output");
finishTest();
}
hud.jsterm.clearOutput();
content.console.log("foobarz1");
return waitForMessages({
webconsole: hud,
messages: [{
text: "foobarz1",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
});
}
function onReload()
{
content.console.log("foobarz2");
return waitForMessages({
webconsole: hud,
messages: [{
name: "page reload",
text: "test-console.html",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
},
{
text: "foobarz2",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
},
{
name: "navigation marker",
text: "test-console.html",
type: Messages.NavigationMarker,
}],
});
}

View File

@ -66,7 +66,7 @@ function test()
privateBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
privateContent = privateBrowser.selectedBrowser.contentWindow;
ok(PrivateBrowsingUtils.isBrowserPrivate(privateBrowser.selectedBrowser), "tab window is private");
openConsole(privateTab, consoleOpened);
openConsole(privateTab).then(consoleOpened);
}, true);
}
@ -109,9 +109,9 @@ function test()
function testCachedMessages()
{
info("testCachedMessages()");
closeConsole(privateTab, () => {
closeConsole(privateTab).then(() => {
info("web console closed");
openConsole(privateTab, consoleReopened);
openConsole(privateTab).then(consoleReopened);
});
}
@ -131,7 +131,7 @@ function test()
function testBrowserConsole()
{
info("testBrowserConsole()");
closeConsole(privateTab, () => {
closeConsole(privateTab).then(() => {
info("web console closed");
privateWindow.HUDService.toggleBrowserConsole().then(onBrowserConsoleOpen);
});

View File

@ -9,45 +9,57 @@ const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/te
let gWebConsole, gJSTerm, gVariablesView;
function test()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
}
let hud;
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
hud = yield openConsole();
function consoleOpened(hud)
{
gWebConsole = hud;
gJSTerm = hud.jsterm;
gJSTerm.execute("fooObj", onExecuteFooObj);
}
let msg = yield gJSTerm.execute("fooObj");
function onExecuteFooObj(msg)
{
ok(msg, "output message found");
ok(msg.textContent.contains('{ testProp: "testValue" }'), "message text check");
let anchor = msg.querySelector("a");
ok(anchor, "object link found");
gJSTerm.once("variablesview-fetched", onFooObjFetch);
let fetched = gJSTerm.once("variablesview-fetched");
executeSoon(() =>
EventUtils.synthesizeMouse(anchor, 2, 2, {}, gWebConsole.iframeWindow)
);
}
// executeSoon
EventUtils.synthesizeMouse(anchor, 2, 2, {}, gWebConsole.iframeWindow);
function onFooObjFetch(aEvent, aVar)
let view = yield fetched;
let results = yield onFooObjFetch(view);
let vView = yield onTestPropFound(results);
let results2 = yield onFooObjFetchAfterUpdate(vView);
let vView2 = yield onUpdatedTestPropFound(results2);
let results3 = yield onFooObjFetchAfterPropRename(vView2);
let vView3 = yield onRenamedTestPropFound(results3);
let results4 = yield onPropUpdateError(vView3);
yield onRenamedTestPropFoundAgain(results4);
let prop = results4[0].matchedProp;
yield testPropDelete(prop);
gWebConsole = gJSTerm = gVariablesView = null;
});
function onFooObjFetch(aVar)
{
gVariablesView = aVar._variablesView;
ok(gVariablesView, "variables view object");
findVariableViewProperties(aVar, [
return findVariableViewProperties(aVar, [
{ name: "testProp", value: "testValue" },
], { webconsole: gWebConsole }).then(onTestPropFound);
], { webconsole: gWebConsole });
}
function onTestPropFound(aResults)
@ -55,29 +67,28 @@ function onTestPropFound(aResults)
let prop = aResults[0].matchedProp;
ok(prop, "matched the |testProp| property in the variables view");
is(content.wrappedJSObject.fooObj.testProp, aResults[0].value,
is("testValue", aResults[0].value,
"|fooObj.testProp| value is correct");
// Check that property value updates work and that jsterm functions can be
// used.
updateVariablesViewProperty({
return updateVariablesViewProperty({
property: prop,
field: "value",
string: "document.title + window.location + $('p')",
webconsole: gWebConsole,
callback: onFooObjFetchAfterUpdate,
webconsole: gWebConsole
});
}
function onFooObjFetchAfterUpdate(aEvent, aVar)
function onFooObjFetchAfterUpdate(aVar)
{
info("onFooObjFetchAfterUpdate");
let para = content.wrappedJSObject.document.querySelector("p");
let expectedValue = content.document.title + content.location + para;
let expectedValue = content.document.title + content.location
+ '[object HTMLParagraphElement]';
findVariableViewProperties(aVar, [
return findVariableViewProperties(aVar, [
{ name: "testProp", value: expectedValue },
], { webconsole: gWebConsole }).then(onUpdatedTestPropFound);
], { webconsole: gWebConsole });
}
function onUpdatedTestPropFound(aResults)
@ -89,16 +100,15 @@ function onUpdatedTestPropFound(aResults)
"|fooObj.testProp| value has been updated");
// Check that property name updates work.
updateVariablesViewProperty({
return updateVariablesViewProperty({
property: prop,
field: "name",
string: "testUpdatedProp",
webconsole: gWebConsole,
callback: onFooObjFetchAfterPropRename,
webconsole: gWebConsole
});
}
function onFooObjFetchAfterPropRename(aEvent, aVar)
function onFooObjFetchAfterPropRename(aVar)
{
info("onFooObjFetchAfterPropRename");
@ -106,9 +116,9 @@ function onFooObjFetchAfterPropRename(aEvent, aVar)
let expectedValue = content.document.title + content.location + para;
// Check that the new value is in the variables view.
findVariableViewProperties(aVar, [
return findVariableViewProperties(aVar, [
{ name: "testUpdatedProp", value: expectedValue },
], { webconsole: gWebConsole }).then(onRenamedTestPropFound);
], { webconsole: gWebConsole });
}
function onRenamedTestPropFound(aResults)
@ -123,16 +133,15 @@ function onRenamedTestPropFound(aResults)
// Check that property value updates that cause exceptions are reported in
// the web console output.
updateVariablesViewProperty({
return updateVariablesViewProperty({
property: prop,
field: "value",
string: "foobarzFailure()",
webconsole: gWebConsole,
callback: onPropUpdateError,
webconsole: gWebConsole
});
}
function onPropUpdateError(aEvent, aVar)
function onPropUpdateError(aVar)
{
info("onPropUpdateError");
@ -140,9 +149,9 @@ function onPropUpdateError(aEvent, aVar)
let expectedValue = content.document.title + content.location + para;
// Make sure the property did not change.
findVariableViewProperties(aVar, [
return findVariableViewProperties(aVar, [
{ name: "testUpdatedProp", value: expectedValue },
], { webconsole: gWebConsole }).then(onRenamedTestPropFoundAgain);
], { webconsole: gWebConsole });
}
function onRenamedTestPropFoundAgain(aResults)
@ -152,7 +161,7 @@ function onRenamedTestPropFoundAgain(aResults)
let outputNode = gWebConsole.outputNode;
waitForMessages({
return waitForMessages({
webconsole: gWebConsole,
messages: [{
name: "exception in property update reported in the web console output",
@ -160,7 +169,7 @@ function onRenamedTestPropFoundAgain(aResults)
category: CATEGORY_OUTPUT,
severity: SEVERITY_ERROR,
}],
}).then(testPropDelete.bind(null, prop));
});
}
function testPropDelete(aProp)
@ -170,14 +179,11 @@ function testPropDelete(aProp)
executeSoon(() => {
EventUtils.synthesizeKey("VK_DELETE", {}, gVariablesView.window);
gWebConsole = gJSTerm = gVariablesView = null;
});
waitForSuccess({
return waitForSuccess({
name: "property deleted",
timeout: 60000,
validatorFn: () => !("testUpdatedProp" in content.wrappedJSObject.fooObj),
successFn: finishTest,
failureFn: finishTest,
validator: () => !("testUpdatedProp" in content.wrappedJSObject.fooObj)
});
}

View File

@ -57,7 +57,7 @@ function test() {
// Create an ArrayBuffer of 80 bytes to test TypedArrays. 80 bytes is
// enough to get 10 items in all different TypedArrays.
jsterm.execute("let buf = new ArrayBuffer(80);");
yield jsterm.execute("let buf = new ArrayBuffer(80);");
// Array
yield testNotSorted("Array(0,1,2,3,4,5,6,7,8,9,10)");

View File

@ -12,11 +12,11 @@ let gWebConsole, gJSTerm, gVariablesView, gToolbox;
function test()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
loadTab(TEST_URI).then(() => {
openConsole().then(hud => {
consoleOpened(hud);
})
});
}
function consoleOpened(hud)
@ -24,7 +24,7 @@ function consoleOpened(hud)
gWebConsole = hud;
gJSTerm = hud.jsterm;
gToolbox = gDevTools.getToolbox(hud.target);
gJSTerm.execute("document.querySelectorAll('p')", onQSAexecuted);
gJSTerm.execute("document.querySelectorAll('p')").then(onQSAexecuted);
}
function onQSAexecuted(msg)

View File

@ -14,11 +14,9 @@ let gWebConsole, gJSTerm, gDebuggerWin, gThread, gDebuggerController,
function test()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
loadTab(TEST_URI).then(() => {
openConsole().then(consoleOpened);
});
}
function consoleOpened(hud)
@ -52,8 +50,8 @@ function onFramesAdded()
info("onFramesAdded");
executeSoon(() =>
openConsole(null, () =>
gJSTerm.execute("fooObj", onExecuteFooObj)
openConsole().then(() =>
gJSTerm.execute("fooObj").then(onExecuteFooObj)
)
);
}
@ -95,12 +93,11 @@ function onTestPropFound(aResults)
property: prop,
field: "value",
string: "document.title + foo2 + $('p')",
webconsole: gWebConsole,
callback: onFooObjFetchAfterUpdate,
});
webconsole: gWebConsole
}).then(onFooObjFetchAfterUpdate);
}
function onFooObjFetchAfterUpdate(aEvent, aVar)
function onFooObjFetchAfterUpdate(aVar)
{
info("onFooObjFetchAfterUpdate");
let para = content.wrappedJSObject.document.querySelector("p");
@ -117,7 +114,7 @@ function onUpdatedTestPropFound(aResults)
ok(prop, "matched the updated |testProp2| property value");
// Check that testProp2 was updated.
executeSoon(() => gJSTerm.execute("fooObj.testProp2", onExecuteFooObjTestProp2));
executeSoon(() => gJSTerm.execute("fooObj.testProp2").then(onExecuteFooObjTestProp2));
}
function onExecuteFooObjTestProp2()

View File

@ -13,10 +13,8 @@ let gWebConsole, gJSTerm, gDebuggerWin, gThread, gDebuggerController,
function test()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
loadTab(TEST_URI).then(() => {
openConsole().then(consoleOpened);
}, true);
}
@ -31,16 +29,18 @@ function consoleOpened(hud)
function debuggerOpened(aResult)
{
info("debugger opened");
gDebuggerWin = aResult.panelWin;
gDebuggerController = gDebuggerWin.DebuggerController;
gThread = gDebuggerController.activeThread;
gStackframes = gDebuggerController.StackFrames;
openInspector(inspectorOpened);
openInspector().then(inspectorOpened);
}
function inspectorOpened(aPanel)
{
info("inspector opened");
gThread.addOneTimeListener("framesadded", onFramesAdded);
info("firstCall()");
@ -51,7 +51,7 @@ function onFramesAdded()
{
info("onFramesAdded");
openConsole(null, () => gJSTerm.execute("fooObj", onExecuteFooObj));
openConsole().then(() => gJSTerm.execute("fooObj").then(onExecuteFooObj));
}
function onExecuteFooObj(msg)
@ -90,12 +90,11 @@ function onTestPropFound(aResults)
property: prop,
field: "value",
string: "document.title + foo2 + $('p')",
webconsole: gWebConsole,
callback: onFooObjFetchAfterUpdate,
});
webconsole: gWebConsole
}).then(onFooObjFetchAfterUpdate);
}
function onFooObjFetchAfterUpdate(aEvent, aVar)
function onFooObjFetchAfterUpdate(aVar)
{
info("onFooObjFetchAfterUpdate");
let para = content.wrappedJSObject.document.querySelector("p");
@ -112,7 +111,7 @@ function onUpdatedTestPropFound(aResults)
ok(prop, "matched the updated |testProp2| property value");
// Check that testProp2 was updated.
gJSTerm.execute("fooObj.testProp2", onExecuteFooObjTestProp2);
gJSTerm.execute("fooObj.testProp2").then(onExecuteFooObjTestProp2);
}
function onExecuteFooObjTestProp2()

View File

@ -12,18 +12,16 @@ let gWebConsole, gJSTerm, gDebuggerWin, gThread, gDebuggerController, gStackfram
function test()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
loadTab(TEST_URI).then(() => {
openConsole().then(consoleOpened);
});
}
function consoleOpened(hud)
{
gWebConsole = hud;
gJSTerm = hud.jsterm;
gJSTerm.execute("foo", onExecuteFoo);
gJSTerm.execute("foo").then(onExecuteFoo);
}
function onExecuteFoo()
@ -35,7 +33,7 @@ function onExecuteFoo()
// Test for Bug 690529 - Web Console and Scratchpad should evaluate
// expressions in the scope of the content window, not in a sandbox.
executeSoon(() => gJSTerm.execute("foo2 = 'newFoo'; window.foo2", onNewFoo2));
executeSoon(() => gJSTerm.execute("foo2 = 'newFoo'; window.foo2").then(onNewFoo2));
}
function onNewFoo2(msg)
@ -63,8 +61,8 @@ function debuggerOpened(aResult)
info("openConsole");
executeSoon(() =>
openConsole(null, () =>
gJSTerm.execute("foo + foo2", onExecuteFooAndFoo2)
openConsole().then(() =>
gJSTerm.execute("foo + foo2").then(onExecuteFooAndFoo2)
)
);
}
@ -92,8 +90,8 @@ function onFramesAdded()
{
info("onFramesAdded, openConsole() now");
executeSoon(() =>
openConsole(null, () =>
gJSTerm.execute("foo + foo2", onExecuteFooAndFoo2InSecondCall)
openConsole().then(() =>
gJSTerm.execute("foo + foo2").then(onExecuteFooAndFoo2InSecondCall)
)
);
}
@ -114,8 +112,8 @@ function onExecuteFooAndFoo2InSecondCall()
info("openConsole");
executeSoon(() =>
openConsole(null, () =>
gJSTerm.execute("foo + foo2 + foo3", onExecuteFoo23InFirstCall)
openConsole().then(() =>
gJSTerm.execute("foo + foo2 + foo3").then(onExecuteFoo23InFirstCall)
)
);
});
@ -129,7 +127,7 @@ function onExecuteFoo23InFirstCall()
"|foo + foo2 + foo3| from |firstCall()|");
executeSoon(() =>
gJSTerm.execute("foo = 'abba'; foo3 = 'bug783499'; foo + foo3",
gJSTerm.execute("foo = 'abba'; foo3 = 'bug783499'; foo + foo3").then(
onExecuteFooAndFoo3ChangesInFirstCall));
}

View File

@ -0,0 +1,63 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Test to make sure that web console commands can fire while paused at a breakpoint
// that was triggered from a JS call. Relies on asynchronous js evaluation over the
// protocol - see Bug 1088861.
"use strict";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-eval-in-stackframe.html";
let test = asyncTest(function*() {
yield loadTab(TEST_URI);
info("open the web console");
let hud = yield openConsole();
let {jsterm} = hud;
info("open the debugger");
let {panel,panelWin} = yield openDebugger();
let {DebuggerController} = panelWin;
let {activeThread,StackFrames} = DebuggerController;
let firstCall = promise.defer();
let frameAdded = promise.defer();
executeSoon(() => {
info ("Executing firstCall");
activeThread.addOneTimeListener("framesadded", () => {
executeSoon(frameAdded.resolve);
});
jsterm.execute("firstCall()").then(firstCall.resolve);
});
info ("Waiting for a frame to be added");
yield frameAdded.promise;
info ("Executing basic command while paused");
yield executeAndConfirm(jsterm, "1 + 2", "3");
info ("Executing command using scoped variables while paused");
yield executeAndConfirm(jsterm, "foo + foo2", '"globalFooBug783499foo2SecondCall"');
info ("Resuming the thread");
activeThread.resume();
info ("Checking the first command (which is the last to resolve since it paused");
let node = yield firstCall.promise;
is (node.querySelector(".message-body").textContent,
"undefined",
"firstCall() returned correct value");
});
function* executeAndConfirm(jsterm, input, output) {
info ("Executing command `"+input+"`");
let node = yield jsterm.execute(input);
is (node.querySelector(".message-body").textContent,
output,
"Expected result from call to " + input);
}

View File

@ -5,31 +5,24 @@
// Check that the inspect() jsterm helper function works.
function test()
{
const TEST_URI = "data:text/html;charset=utf8,<p>hello bug 869981";
const TEST_URI = "data:text/html;charset=utf8,<p>hello bug 869981";
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
function consoleOpened(hud)
{
content.wrappedJSObject.testProp = "testValue";
let hud = yield openConsole();
let jsterm = hud.jsterm;
hud.jsterm.once("variablesview-fetched", onObjFetch);
hud.jsterm.execute("inspect(window)");
}
jsterm.execute("testProp = 'testValue'");
function onObjFetch(aEvent, aVar)
{
ok(aVar._variablesView, "variables view object");
let fetched = jsterm.once("variablesview-fetched");
jsterm.execute("inspect(window)");
let variable = yield fetched;
findVariableViewProperties(aVar, [
{ name: "testProp", value: "testValue" },
{ name: "document", value: /HTMLDocument \u2192 data:/ },
], { webconsole: hud }).then(finishTest);
}
}
ok(variable._variablesView, "variables view object");
yield findVariableViewProperties(variable, [
{ name: "testProp", value: "testValue" },
{ name: "document", value: /HTMLDocument \u2192 data:/ },
], { webconsole: hud });
});

View File

@ -4,61 +4,50 @@
// Test that very long strings do not hang the browser.
function test()
{
addTab("http://example.com/browser/browser/devtools/webconsole/test/test-bug-859170-longstring-hang.html");
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug-859170-longstring-hang.html";
let hud = null;
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
openConsole(null, performTest);
}, true);
let hud = yield openConsole();
function performTest(aHud)
{
hud = aHud;
info("wait for the initial long string");
info("wait for the initial long string");
waitForMessages({
webconsole: hud,
messages: [
{
name: "find 'foobar', no 'foobaz', in long string output",
text: "foobar",
noText: "foobaz",
category: CATEGORY_WEBDEV,
longString: true,
},
],
}).then(onInitialString);
}
let results = yield waitForMessages({
webconsole: hud,
messages: [
{
name: "find 'foobar', no 'foobaz', in long string output",
text: "foobar",
noText: "foobaz",
category: CATEGORY_WEBDEV,
longString: true,
},
],
});
function onInitialString(aResults)
{
let clickable = aResults[0].longStrings[0];
ok(clickable, "long string ellipsis is shown");
clickable.scrollIntoView(false);
let clickable = results[0].longStrings[0];
ok(clickable, "long string ellipsis is shown");
clickable.scrollIntoView(false);
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
info("wait for long string expansion");
info("wait for long string expansion");
waitForMessages({
webconsole: hud,
messages: [
{
name: "find 'foobaz' after expand, but no 'boom!' at the end",
text: "foobaz",
noText: "boom!",
category: CATEGORY_WEBDEV,
longString: false,
},
{
text: "too long to be displayed",
longString: false,
},
],
}).then(finishTest);
}
}
yield waitForMessages({
webconsole: hud,
messages: [
{
name: "find 'foobaz' after expand, but no 'boom!' at the end",
text: "foobaz",
noText: "boom!",
category: CATEGORY_WEBDEV,
longString: false,
},
{
text: "too long to be displayed",
longString: false,
},
],
});
});

View File

@ -21,11 +21,9 @@ const TEST_IMG_BASE64 =
let testDriver;
function test() {
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, testNetworkPanel);
}, true);
loadTab(TEST_URI).then(() => {
openConsole().then(testNetworkPanel);
});
}
function testNetworkPanel() {

View File

@ -5,27 +5,20 @@
// Make sure that the Web Console output does not break after we try to call
// console.dir() for objects that are not inspectable.
function test()
{
waitForExplicitFinish();
const TEST_URI = "data:text/html;charset=utf8,test for bug 773466";
addTab("data:text/html;charset=utf8,test for bug 773466");
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
openConsole(null, performTest);
}, true);
}
let hud = yield openConsole();
function performTest(hud)
{
hud.jsterm.clearOutput(true);
hud.jsterm.execute("console.log('fooBug773466a')");
hud.jsterm.execute("myObj = Object.create(null)");
hud.jsterm.execute("console.dir(myObj)");
waitForMessages({
yield waitForMessages({
webconsole: hud,
messages: [{
text: "fooBug773466a",
@ -36,15 +29,16 @@ function performTest(hud)
name: "console.dir output",
consoleDir: "[object Object]",
}],
}).then(() => {
content.console.log("fooBug773466b");
waitForMessages({
webconsole: hud,
messages: [{
text: "fooBug773466b",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
}).then(finishTest);
})
content.console.log("fooBug773466b");
yield waitForMessages({
webconsole: hud,
messages: [{
text: "fooBug773466b",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
});
}
});

View File

@ -4,10 +4,9 @@
// Test that long strings can be expanded in the console output.
function test()
{
waitForExplicitFinish();
const TEST_URI = "data:text/html;charset=utf8,test for bug 787981 - check that long strings can be expanded in the output.";
let test = asyncTest(function* () {
let tempScope = {};
Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope);
let DebuggerServer = tempScope.DebuggerServer;
@ -17,77 +16,68 @@ function test()
let initialString =
longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
addTab("data:text/html;charset=utf8,test for bug 787981 - check that long strings can be expanded in the output.");
yield loadTab(TEST_URI);
let hud = null;
let hud = yield openConsole();
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
openConsole(null, performTest);
}, true);
hud.jsterm.clearOutput(true);
hud.jsterm.execute("console.log('bazbaz', '" + longString +"', 'boom')");
function performTest(aHud)
{
hud = aHud;
hud.jsterm.clearOutput(true);
hud.jsterm.execute("console.log('bazbaz', '" + longString +"', 'boom')");
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
name: "console.log output",
text: ["bazbaz", "boom", initialString],
noText: "foobar",
longString: true,
}],
});
waitForMessages({
webconsole: hud,
messages: [{
name: "console.log output",
text: ["bazbaz", "boom", initialString],
noText: "foobar",
longString: true,
}],
}).then(onConsoleMessage);
}
let clickable = result.longStrings[0];
ok(clickable, "long string ellipsis is shown");
function onConsoleMessage([result])
{
let clickable = result.longStrings[0];
ok(clickable, "long string ellipsis is shown");
clickable.scrollIntoView(false);
clickable.scrollIntoView(false);
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
yield waitForMessages({
webconsole: hud,
messages: [{
name: "full string",
text: ["bazbaz", "boom", longString],
category: CATEGORY_WEBDEV,
longString: false,
}],
});
waitForMessages({
webconsole: hud,
messages: [{
name: "full string",
text: ["bazbaz", "boom", longString],
category: CATEGORY_WEBDEV,
longString: false,
}],
}).then(() => {
hud.jsterm.clearOutput(true);
hud.jsterm.execute("'" + longString +"'", onExecute);
});
}
hud.jsterm.clearOutput(true);
let msg = yield execute(hud, "'" + longString +"'");
function onExecute(msg)
{
isnot(msg.textContent.indexOf(initialString), -1,
"initial string is shown");
is(msg.textContent.indexOf(longString), -1,
"full string is not shown");
isnot(msg.textContent.indexOf(initialString), -1,
"initial string is shown");
is(msg.textContent.indexOf(longString), -1,
"full string is not shown");
let clickable = msg.querySelector(".longStringEllipsis");
ok(clickable, "long string ellipsis is shown");
clickable = msg.querySelector(".longStringEllipsis");
ok(clickable, "long string ellipsis is shown");
clickable.scrollIntoView(false);
clickable.scrollIntoView(false);
EventUtils.synthesizeMouse(clickable, 3, 4, {}, hud.iframeWindow);
EventUtils.synthesizeMouse(clickable, 3, 4, {}, hud.iframeWindow);
waitForMessages({
webconsole: hud,
messages: [{
name: "full string",
text: longString,
category: CATEGORY_OUTPUT,
longString: false,
}],
}).then(finishTest);
}
yield waitForMessages({
webconsole: hud,
messages: [{
name: "full string",
text: longString,
category: CATEGORY_OUTPUT,
longString: false,
}],
})
});
function execute(hud, str) {
let deferred = promise.defer();
hud.jsterm.execute(str, deferred.resolve);
return deferred.promise;
}

View File

@ -8,25 +8,36 @@
// different lines of code, or from different severities, etc.
// See bugs 720180 and 800510.
"use strict";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-repeated-messages.html";
const PREF = "devtools.webconsole.persistlog";
function test() {
const PREF = "devtools.webconsole.persistlog";
let test = asyncTest(function* () {
Services.prefs.setBoolPref(PREF, true);
registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
}
let { browser } = yield loadTab(TEST_URI);
let hud = yield openConsole();
yield consoleOpened(hud);
let loaded = loadBrowser(browser);
BrowserReload();
yield loaded;
yield testCSSRepeats(hud);
yield testCSSRepeatsAfterReload(hud);
yield testConsoleRepeats(hud);
Services.prefs.clearUserPref(PREF);
});
function consoleOpened(hud) {
// Check that css warnings are not coalesced if they come from different lines.
info("waiting for 2 css warnings");
waitForMessages({
return waitForMessages({
webconsole: hud,
messages: [{
name: "two css warnings",
@ -34,35 +45,30 @@ function consoleOpened(hud) {
count: 2,
repeats: 1,
}],
}).then(testCSSRepeats.bind(null, hud));
});
}
function testCSSRepeats(hud) {
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
info("wait for repeats after page reload");
info("wait for repeats after page reload");
waitForMessages({
webconsole: hud,
messages: [{
name: "two css warnings, repeated twice",
category: CATEGORY_CSS,
repeats: 2,
count: 2,
}],
}).then(testCSSRepeatsAfterReload.bind(null, hud));
}, true);
content.location.reload();
return waitForMessages({
webconsole: hud,
messages: [{
name: "two css warnings, repeated twice",
category: CATEGORY_CSS,
repeats: 2,
count: 2,
}],
});
}
function testCSSRepeatsAfterReload(hud) {
hud.jsterm.clearOutput(true);
content.wrappedJSObject.testConsole();
hud.jsterm.execute("testConsole()");
info("wait for repeats with the console API");
waitForMessages({
return waitForMessages({
webconsole: hud,
messages: [
{
@ -84,17 +90,18 @@ function testCSSRepeatsAfterReload(hud) {
repeats: 1,
},
],
}).then(testConsoleRepeats.bind(null, hud));
})
}
function testConsoleRepeats(hud) {
hud.jsterm.clearOutput(true);
hud.jsterm.execute("undefined");
content.console.log("undefined");
info("make sure console API messages are not coalesced with jsterm output");
waitForMessages({
return waitForMessages({
webconsole: hud,
messages: [
{
@ -114,5 +121,5 @@ function testConsoleRepeats(hud) {
repeats: 1,
},
],
}).then(finishTest);
});
}

View File

@ -5,7 +5,7 @@
///////////////////
//
// Whitelisting this test.
// As part of bug 1077403, the leaking uncaught rejection should be fixed.
// As part of bug 1077403, the leaking uncaught rejection should be fixed.
//
thisTestLeaksUncaughtRejectionsAndShouldBeFixed("Error: Connection closed");
@ -13,36 +13,31 @@ thisTestLeaksUncaughtRejectionsAndShouldBeFixed("Error: Connection closed");
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-result-format-as-string.html";
function test()
{
waitForExplicitFinish();
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
addTab(TEST_URI);
let hud = yield openConsole();
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
openConsole(null, performTest);
}, true);
}
function performTest(hud)
{
hud.jsterm.clearOutput(true);
hud.jsterm.execute("document.querySelector('p')", (msg) => {
is(hud.outputNode.textContent.indexOf("bug772506_content"), -1,
"no content element found");
ok(!hud.outputNode.querySelector("#foobar"), "no #foobar element found");
let msg = yield execute(hud, "document.querySelector('p')");
ok(msg, "eval output node found");
is(msg.textContent.indexOf("<div>"), -1,
"<div> string is not displayed");
isnot(msg.textContent.indexOf("<p>"), -1,
"<p> string is displayed");
is(hud.outputNode.textContent.indexOf("bug772506_content"), -1,
"no content element found");
ok(!hud.outputNode.querySelector("#foobar"), "no #foobar element found");
EventUtils.synthesizeMouseAtCenter(msg, {type: "mousemove"});
ok(!gBrowser._bug772506, "no content variable");
ok(msg, "eval output node found");
is(msg.textContent.indexOf("<div>"), -1,
"<div> string is not displayed");
isnot(msg.textContent.indexOf("<p>"), -1,
"<p> string is displayed");
finishTest();
});
}
EventUtils.synthesizeMouseAtCenter(msg, {type: "mousemove"});
ok(!gBrowser._bug772506, "no content variable");
});
function execute(hud, str) {
let deferred = promise.defer();
hud.jsterm.execute(str, deferred.resolve);
return deferred.promise;
}

View File

@ -5,75 +5,77 @@
const TEST_REPLACED_API_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-replaced-api.html";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/testscript.js";
const PREF = "devtools.webconsole.persistlog";
function test() {
waitForExplicitFinish();
const PREF = "devtools.webconsole.persistlog";
let test = asyncTest(function* () {
Services.prefs.setBoolPref(PREF, true);
registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
// First test that the warning does not appear on a page that doesn't override
// the window.console object.
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, testWarningNotPresent);
}, true);
let { browser } = yield loadTab(TEST_URI);
let hud = yield openConsole();
function testWarningNotPresent(hud)
{
yield testWarningNotPresent(hud);
let loaded = loadBrowser(browser);
content.location = TEST_REPLACED_API_URI;
yield loaded;
let hud2 = yield openConsole();
yield testWarningPresent(hud2);
Services.prefs.clearUserPref(PREF);
});
function testWarningNotPresent(hud)
{
let deferred = promise.defer();
is(hud.outputNode.textContent.indexOf("logging API"), -1,
"no warning displayed");
// Bug 862024: make sure the warning doesn't show after page reload.
info("reload " + TEST_URI);
executeSoon(() => content.location.reload());
waitForMessages({
webconsole: hud,
messages: [{
text: "testscript.js",
category: CATEGORY_NETWORK,
}],
}).then(() => executeSoon(() => {
is(hud.outputNode.textContent.indexOf("logging API"), -1,
"no warning displayed");
closeConsole().then(deferred.resolve);
}));
// Bug 862024: make sure the warning doesn't show after page reload.
info("reload " + TEST_URI);
executeSoon(() => content.location.reload());
waitForMessages({
webconsole: hud,
messages: [{
text: "testscript.js",
category: CATEGORY_NETWORK,
}],
}).then(() => executeSoon(() => {
is(hud.outputNode.textContent.indexOf("logging API"), -1,
"no warning displayed");
closeConsole(null, loadTestPage);
}));
}
function loadTestPage()
{
info("load test " + TEST_REPLACED_API_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, testWarningPresent);
}, true);
content.location = TEST_REPLACED_API_URI;
}
function testWarningPresent(hud)
{
info("wait for the warning to show");
let warning = {
webconsole: hud,
messages: [{
text: /logging API .+ disabled by a script/,
category: CATEGORY_JS,
severity: SEVERITY_WARNING,
}],
};
waitForMessages(warning).then(() => {
hud.jsterm.clearOutput();
executeSoon(() => {
info("reload the test page and wait for the warning to show");
waitForMessages(warning).then(finishTest);
content.location.reload();
});
});
}
return deferred.promise;
}
function testWarningPresent(hud)
{
info("wait for the warning to show");
let deferred = promise.defer();
let warning = {
webconsole: hud,
messages: [{
text: /logging API .+ disabled by a script/,
category: CATEGORY_JS,
severity: SEVERITY_WARNING,
}],
};
waitForMessages(warning).then(() => {
hud.jsterm.clearOutput();
executeSoon(() => {
info("reload the test page and wait for the warning to show");
waitForMessages(warning).then(deferred.resolve);
content.location.reload();
});
});
return deferred.promise;
}

View File

@ -12,41 +12,45 @@
const TEST_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-mixedcontent-securityerrors.html";
const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Security/MixedContent";
function test()
let test = asyncTest(function* () {
yield pushPrefEnv();
yield loadTab(TEST_URI);
let hud = yield openConsole();
let results = yield waitForMessages({
webconsole: hud,
messages: [
{
name: "Logged mixed active content",
text: "Loading mixed (insecure) active content on a secure page \"http://example.com/\"",
category: CATEGORY_SECURITY,
severity: SEVERITY_WARNING,
objects: true,
},
{
name: "Logged mixed passive content - image",
text: "Loading mixed (insecure) display content on a secure page \"http://example.com/tests/image/test/mochitest/blue.png\"",
category: CATEGORY_SECURITY,
severity: SEVERITY_WARNING,
objects: true,
},
],
});
testClickOpenNewTab(hud, results);
});
function pushPrefEnv()
{
SpecialPowers.pushPrefEnv({"set":
let deferred = promise.defer();
let options = {"set":
[["security.mixed_content.block_active_content", false],
["security.mixed_content.block_display_content", false]
]}, loadingMixedContentTest);
}
function loadingMixedContentTest()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad(aEvent) {
browser.removeEventListener(aEvent.type, onLoad, true);
openConsole(null, function testSecurityErrorLogged (hud) {
waitForMessages({
webconsole: hud,
messages: [
{
name: "Logged mixed active content",
text: "Loading mixed (insecure) active content on a secure page \"http://example.com/\"",
category: CATEGORY_SECURITY,
severity: SEVERITY_WARNING,
objects: true,
},
{
name: "Logged mixed passive content - image",
text: "Loading mixed (insecure) display content on a secure page \"http://example.com/tests/image/test/mochitest/blue.png\"",
category: CATEGORY_SECURITY,
severity: SEVERITY_WARNING,
objects: true,
},
],
}).then((results) => testClickOpenNewTab(hud, results));
});
}, true);
]};
SpecialPowers.pushPrefEnv(options, deferred.resolve);
return deferred.promise;
}
function testClickOpenNewTab(hud, results) {
@ -67,6 +71,4 @@ function testClickOpenNewTab(hud, results) {
warningNode.ownerDocument.defaultView);
ok(linkOpened, "Clicking the Learn More Warning node opens the desired page");
window.openUILinkIn = oldOpenUILinkIn;
finishTest();
}

View File

@ -7,16 +7,17 @@
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-assert.html";
function test() {
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
}
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
let hud = yield openConsole();
yield consoleOpened(hud);
});
function consoleOpened(hud) {
waitForMessages({
hud.jsterm.execute("test()");
return waitForMessages({
webconsole: hud,
messages: [{
text: "start",
@ -40,11 +41,6 @@ function consoleOpened(hud) {
}],
}).then(() => {
let nodes = hud.outputNode.querySelectorAll(".message");
is(nodes.length, 4, "only four messages are displayed, no output from the true assert");
finishTest();
is(nodes.length, 6, "only six messages are displayed, no output from the true assert");
});
let button = content.document.querySelector("button");
ok(button, "we have the button");
EventUtils.sendMouseEvent({ type: "click" }, button, content);
}

View File

@ -9,34 +9,32 @@
// Test that properties starting with underscores or dollars can be
// autocompleted (bug 967468).
function test() {
let test = asyncTest(function*() {
const TEST_URI = "data:text/html;charset=utf8,test autocompletion with $ or _";
Task.spawn(runner).then(finishTest);
yield loadTab(TEST_URI);
function* runner() {
function autocomplete(term) {
let deferred = promise.defer();
function autocomplete(term) {
let deferred = promise.defer();
jsterm.setInputValue(term);
jsterm.complete(jsterm.COMPLETE_HINT_ONLY, deferred.resolve);
jsterm.setInputValue(term);
jsterm.complete(jsterm.COMPLETE_HINT_ONLY, deferred.resolve);
yield deferred.promise;
yield deferred.promise;
ok(popup.itemCount > 0, "There's suggestions for '" + term + "'");
}
yield addTab(TEST_URI);
let { jsterm } = yield openConsole(tab);
let popup = jsterm.autocompletePopup;
jsterm.execute("let testObject = {$$aaab: '', $$aaac: ''}");
// Should work with bug 967468.
yield autocomplete("Object.__d");
yield autocomplete("testObject.$$a");
// Here's when things go wrong in bug 967468.
yield autocomplete("Object.__de");
yield autocomplete("testObject.$$aa");
ok(popup.itemCount > 0, "There's suggestions for '" + term + "'");
}
}
let { jsterm } = yield openConsole();
let popup = jsterm.autocompletePopup;
yield jsterm.execute("let testObject = {$$aaab: '', $$aaac: ''}");
// Should work with bug 967468.
yield autocomplete("Object.__d");
yield autocomplete("testObject.$$a");
// Here's when things go wrong in bug 967468.
yield autocomplete("Object.__de");
yield autocomplete("testObject.$$aa");
});

View File

@ -9,7 +9,17 @@ XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper",
"nsIClipboardHelper");
let WebConsoleUtils = require("devtools/toolkit/webconsole/utils").Utils;
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
let hud = yield openConsole();
yield consoleOpened(hud);
});
function consoleOpened(HUD) {
let deferred = promise.defer();
let jsterm = HUD.jsterm;
let stringToCopy = "foobazbarBug642615";
@ -99,7 +109,7 @@ function consoleOpened(HUD) {
ok(!jsterm.completeNode.value, "no completion value after paste (ctrl-v)");
// using executeSoon() to get out of the webconsole event loop.
executeSoon(finishTest);
executeSoon(deferred.resolve);
});
// Get out of the webconsole event loop.
@ -112,12 +122,6 @@ function consoleOpened(HUD) {
jsterm.once("autocomplete-updated", onCompletionValue);
EventUtils.synthesizeKey("u", {});
}
function test() {
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
return deferred.promise;
}

View File

@ -13,14 +13,12 @@ let testDriver, gStackframes;
function test()
{
requestLongerTimeout(2);
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, function(hud) {
loadTab(TEST_URI).then(() => {
openConsole().then((hud) => {
testDriver = testCompletion(hud);
testDriver.next();
});
}, true);
});
}
function testNext() {
@ -140,7 +138,7 @@ function testCompletion(hud) {
gStackframes.selectFrame(1);
info("openConsole");
executeSoon(() => openConsole(null, () => testDriver.next()));
executeSoon(() => openConsole().then(() => testDriver.next()));
});
yield undefined;
@ -235,7 +233,7 @@ function debuggerOpened(aResult)
function onFramesAdded()
{
info("onFramesAdded, openConsole() now");
executeSoon(() => openConsole(null, testNext));
executeSoon(() => openConsole().then(testNext));
}
function finishUp() {

View File

@ -7,36 +7,27 @@
const TEST_URI = "data:text/html;charset=utf-8,<p>bug 900448 - autocomplete popup closes on tab switch";
let popup = null;
let test = asyncTest(function*() {
yield loadTab(TEST_URI);
let hud = yield openConsole();
let popup = hud.jsterm.autocompletePopup;
let popupShown = onPopupShown(popup._panel);
registerCleanupFunction(function() {
popup = null;
hud.jsterm.setInputValue("sc");
EventUtils.synthesizeKey("r", {});
yield popupShown;
ok(!popup.isOpen, "Popup closes on tab switch");
});
function test() {
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
}
function onPopupShown(panel) {
let finished = promise.defer();
function consoleOpened(HUD) {
popup = HUD.jsterm.autocompletePopup;
popup._panel.addEventListener("popupshown", function popupOpened() {
popup._panel.removeEventListener("popupshown", popupOpened, false);
addTab("data:text/html;charset=utf-8,<p>testing autocomplete closes");
gBrowser.selectedBrowser.addEventListener("load", tab2Loaded, true);
panel.addEventListener("popupshown", function popupOpened() {
panel.removeEventListener("popupshown", popupOpened, false);
loadTab("data:text/html;charset=utf-8,<p>testing autocomplete closes").then(finished.resolve);
}, false);
HUD.jsterm.setInputValue("sc");
EventUtils.synthesizeKey("r", {});
}
function tab2Loaded() {
gBrowser.selectedBrowser.removeEventListener("load", tab2Loaded, true);
ok(!popup.isOpen, "Popup closes on tab switch");
gBrowser.removeCurrentTab();
finishTest();
return finished.promise;
}

View File

@ -6,39 +6,37 @@
// Tests that the page's resources are displayed in the console as they're
// loaded
"use strict";
const TEST_NETWORK_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-network.html" + "?_date=" + Date.now();
function test() {
addTab("data:text/html;charset=utf-8,Web Console basic network logging test");
browser.addEventListener("load", onLoad, true);
let test = asyncTest(function* () {
yield loadTab("data:text/html;charset=utf-8,Web Console basic network logging test");
let hud = yield openConsole();
function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, function(hud) {
content.location = TEST_NETWORK_URI;
waitForMessages({
webconsole: hud,
messages: [{
text: "running network console",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
},
{
text: "test-network.html",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
},
{
text: "testscript.js",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
},
{
text: "test-image.png",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
}],
}).then(finishTest);
});
}
}
content.location = TEST_NETWORK_URI;
yield waitForMessages({
webconsole: hud,
messages: [{
text: "running network console",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
},
{
text: "test-network.html",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
},
{
text: "testscript.js",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
},
{
text: "test-image.png",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
}],
});
});

View File

@ -15,46 +15,51 @@
const TEST_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-mixedcontent-securityerrors.html";
const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Security/MixedContent";
function test()
let test = asyncTest(function* () {
yield pushPrefEnv();
let { browser } = yield loadTab(TEST_URI);
let hud = yield openConsole();
let results = yield waitForMessages({
webconsole: hud,
messages: [
{
name: "Logged blocking mixed active content",
text: "Blocked loading mixed active content \"http://example.com/\"",
category: CATEGORY_SECURITY,
severity: SEVERITY_ERROR,
objects: true,
},
{
name: "Logged blocking mixed passive content - image",
text: "Blocked loading mixed active content \"http://example.com/\"",
category: CATEGORY_SECURITY,
severity: SEVERITY_ERROR,
objects: true,
},
],
});
testClickOpenNewTab(hud, results[0]);
let results2 = yield mixedContentOverrideTest2(hud, browser);
testClickOpenNewTab(hud, results2[0]);
});
function pushPrefEnv()
{
SpecialPowers.pushPrefEnv({"set": [["security.mixed_content.block_active_content", true],
["security.mixed_content.block_display_content", true]]}, blockMixedContentTest1);
let deferred = promise.defer();
let options = {"set": [["security.mixed_content.block_active_content", true],
["security.mixed_content.block_display_content", true]]};
SpecialPowers.pushPrefEnv(options, deferred.resolve);
return deferred.promise;
}
function blockMixedContentTest1()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad(aEvent) {
browser.removeEventListener(aEvent.type, onLoad, true);
openConsole(null, function testSecurityErrorLogged (hud) {
waitForMessages({
webconsole: hud,
messages: [
{
name: "Logged blocking mixed active content",
text: "Blocked loading mixed active content \"http://example.com/\"",
category: CATEGORY_SECURITY,
severity: SEVERITY_ERROR,
objects: true,
},
{
name: "Logged blocking mixed passive content - image",
text: "Blocked loading mixed active content \"http://example.com/\"",
category: CATEGORY_SECURITY,
severity: SEVERITY_ERROR,
objects: true,
},
],
}).then(([result]) => {
testClickOpenNewTab(hud, result);
// Call the second (MCB override) test.
mixedContentOverrideTest2(hud);
});
});
}, true);
}
function mixedContentOverrideTest2(hud)
function mixedContentOverrideTest2(hud, browser)
{
var notification = PopupNotifications.getNotification("bad-content", browser);
ok(notification, "Mixed Content Doorhanger did appear");
@ -64,7 +69,7 @@ function mixedContentOverrideTest2(hud)
PopupNotifications.panel.firstChild.disableMixedContentProtection();
notification.remove();
waitForMessages({
return waitForMessages({
webconsole: hud,
messages: [
{
@ -84,9 +89,6 @@ function mixedContentOverrideTest2(hud)
objects: true,
},
],
}).then(([result]) => {
testClickOpenNewTab(hud, result);
finishTest();
});
}
@ -109,5 +111,4 @@ function testClickOpenNewTab(hud, match) {
warningNode.ownerDocument.defaultView);
ok(linkOpened, "Clicking the Learn More Warning node opens the desired page");
window.openUILinkIn = oldOpenUILinkIn;
}

View File

@ -2,6 +2,8 @@
* 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";
function test() {
Task.spawn(runner).then(finishTest);
@ -37,4 +39,3 @@ function test() {
ok(Math.abs(maxTimestamp - minTimestamp) < 1000, "console.log message timestamp spread < 1000ms confirmed");
}
}

View File

@ -14,46 +14,34 @@ So we expect a warning (image has been blocked) and a report
The expected console messages in the constants CSP_VIOLATION_MSG and CSP_REPORT_MSG are confirmed to be found in the console messages.
*/
"use strict";
const TEST_URI = "data:text/html;charset=utf8,Web Console CSP report only test (bug 1010953)";
const TEST_VIOLATION = "http://example.com/browser/browser/devtools/webconsole/test/test_bug_1010953_cspro.html";
const CSP_VIOLATION_MSG = 'Content Security Policy: The page\'s settings blocked the loading of a resource at http://some.example.com/test.png ("img-src http://example.com").';
const CSP_REPORT_MSG = 'Content Security Policy: The page\'s settings observed the loading of a resource at http://some.example.com/test_bug_1010953_cspro.js ("script-src http://example.com"). A CSP report is being sent.';
let test = asyncTest(function* () {
let { browser } = yield loadTab(TEST_URI);
let hud = undefined;
let hud = yield openConsole();
function test() {
addTab("data:text/html;charset=utf8,Web Console CSP report only test (bug 1010953)");
browser.addEventListener("load", function _onLoad() {
browser.removeEventListener("load", _onLoad, true);
openConsole(null, loadDocument);
}, true);
}
hud.jsterm.clearOutput();
function loadDocument(theHud){
hud = theHud;
hud.jsterm.clearOutput()
browser.addEventListener("load", onLoad, true);
let loaded = loadBrowser(browser);
content.location = TEST_VIOLATION;
}
yield loaded;
function onLoad(aEvent) {
browser.removeEventListener("load", onLoad, true);
testViolationMessage();
}
function testViolationMessage(){
let aOutputNode = hud.outputNode;
waitForSuccess({
name: "Confirmed that CSP and CSP-Report-Only log different messages to the console.",
validatorFn: function() {
console.log(hud.outputNode.textContent);
let success = false;
success = hud.outputNode.textContent.indexOf(CSP_VIOLATION_MSG) > -1 &&
hud.outputNode.textContent.indexOf(CSP_REPORT_MSG) > -1;
return success;
},
successFn: finishTest,
failureFn: finishTest,
});
}
yield waitForSuccess({
name: "Confirmed that CSP and CSP-Report-Only log different messages to the console.",
validator: function() {
console.log(hud.outputNode.textContent);
let success = false;
success = hud.outputNode.textContent.indexOf(CSP_VIOLATION_MSG) > -1 &&
hud.outputNode.textContent.indexOf(CSP_REPORT_MSG) > -1;
return success;
}
});
});

View File

@ -6,20 +6,20 @@
// Tests that the console object still exists after a page reload.
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
let browser;
function test() {
addTab(TEST_URI);
loadTab(TEST_URI).then({
openConsole().then((tab) => {
browser = tab.browser;
browser.addEventListener("DOMContentLoaded", testPageReload, false);
content.location.reload();
});
});
browser.addEventListener("DOMContentLoaded", onLoad, false);
}
function onLoad() {
browser.removeEventListener("DOMContentLoaded", onLoad, false);
openConsole();
browser.addEventListener("DOMContentLoaded", testPageReload, false);
content.location.reload();
}
function testPageReload() {
browser.removeEventListener("DOMContentLoaded", testPageReload, false);
@ -33,6 +33,7 @@ function testPageReload() {
is(typeof console.error, "function", "console.error is a function");
is(typeof console.exception, "function", "console.exception is a function");
browser = null;
finishTest();
}

View File

@ -5,21 +5,15 @@
// Tests that the input field is focused when the console is opened.
"use strict";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
function test() {
addTab(TEST_URI);
browser.addEventListener("DOMContentLoaded", testInputFocus, false);
}
function testInputFocus() {
browser.removeEventListener("DOMContentLoaded", testInputFocus, false);
openConsole(null, function(hud) {
let inputNode = hud.jsterm.inputNode;
ok(inputNode.getAttribute("focused"), "input node is focused");
finishTest();
});
}
let test = asyncTest(function*() {
yield loadTab(TEST_URI);
let hud = yield openConsole();
hud.jsterm.clearOutput();
let inputNode = hud.jsterm.inputNode;
ok(inputNode.getAttribute("focused"), "input node is focused");
});

View File

@ -8,15 +8,17 @@
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
function test() {
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, testClosingAfterCompletion);
}, true);
}
function testClosingAfterCompletion(hud) {
let test = asyncTest(function* () {
let { browser } = yield loadTab(TEST_URI);
let hud = yield openConsole();
yield testClosingAfterCompletion(hud, browser);
});
function testClosingAfterCompletion(hud, browser) {
let deferred = promise.defer();
let inputNode = hud.jsterm.inputNode;
let errorWhileClosing = false;
@ -32,7 +34,7 @@ function testClosingAfterCompletion(hud) {
gDevTools.once("toolbox-destroyed", function() {
browser.removeEventListener("error", errorListener, false);
is(errorWhileClosing, false, "no error while closing the WebConsole");
finishTest();
deferred.resolve();
});
if (Services.appinfo.OS == "Darwin") {
@ -40,5 +42,7 @@ function testClosingAfterCompletion(hud) {
} else {
EventUtils.synthesizeKey("i", { accelKey: true, shiftKey: true });
}
return deferred.promise;
}

View File

@ -10,27 +10,21 @@
// Tests that appropriately-localized timestamps are printed.
"use strict";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
function test() {
addTab(TEST_URI);
browser.addEventListener("DOMContentLoaded", testTimestamp, false);
function testTimestamp()
{
browser.removeEventListener("DOMContentLoaded", testTimestamp, false);
const TEST_TIMESTAMP = 12345678;
let date = new Date(TEST_TIMESTAMP);
let localizedString = WCU_l10n.timestampString(TEST_TIMESTAMP);
isnot(localizedString.indexOf(date.getHours()), -1, "the localized " +
"timestamp contains the hours");
isnot(localizedString.indexOf(date.getMinutes()), -1, "the localized " +
"timestamp contains the minutes");
isnot(localizedString.indexOf(date.getSeconds()), -1, "the localized " +
"timestamp contains the seconds");
isnot(localizedString.indexOf(date.getMilliseconds()), -1, "the localized " +
"timestamp contains the milliseconds");
finishTest();
}
}
let test = asyncTest(function*() {
yield loadTab(TEST_URI);
const TEST_TIMESTAMP = 12345678;
let date = new Date(TEST_TIMESTAMP);
let localizedString = WCU_l10n.timestampString(TEST_TIMESTAMP);
isnot(localizedString.indexOf(date.getHours()), -1, "the localized " +
"timestamp contains the hours");
isnot(localizedString.indexOf(date.getMinutes()), -1, "the localized " +
"timestamp contains the minutes");
isnot(localizedString.indexOf(date.getSeconds()), -1, "the localized " +
"timestamp contains the seconds");
isnot(localizedString.indexOf(date.getMilliseconds()), -1, "the localized " +
"timestamp contains the milliseconds");
});

View File

@ -6,42 +6,39 @@
// Tests that exceptions thrown by content don't show up twice in the Web
// Console.
const TEST_DUPLICATE_ERROR_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-duplicate-error.html";
"use strict";
function test() {
addTab("data:text/html;charset=utf8,hello world");
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
const INIT_URI = "data:text/html;charset=utf8,hello world";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-duplicate-error.html";
function consoleOpened(hud)
{
expectUncaughtException();
content.location = TEST_DUPLICATE_ERROR_URI;
let test = asyncTest(function* () {
yield loadTab(INIT_URI);
waitForMessages({
webconsole: hud,
messages: [{
text: "fooDuplicateError1",
category: CATEGORY_JS,
severity: SEVERITY_ERROR,
},
{
text: "test-duplicate-error.html",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
}],
}).then(() => {
let text = hud.outputNode.textContent;
let error1pos = text.indexOf("fooDuplicateError1");
ok(error1pos > -1, "found fooDuplicateError1");
if (error1pos > -1) {
ok(text.indexOf("fooDuplicateError1", error1pos + 1) == -1,
"no duplicate for fooDuplicateError1");
}
let hud = yield openConsole();
finishTest();
});
expectUncaughtException();
content.location = TEST_URI;
yield waitForMessages({
webconsole: hud,
messages: [{
text: "fooDuplicateError1",
category: CATEGORY_JS,
severity: SEVERITY_ERROR,
},
{
text: "test-duplicate-error.html",
category: CATEGORY_NETWORK,
severity: SEVERITY_LOG,
}],
});
let text = hud.outputNode.textContent;
let error1pos = text.indexOf("fooDuplicateError1");
ok(error1pos > -1, "found fooDuplicateError1");
if (error1pos > -1) {
ok(text.indexOf("fooDuplicateError1", error1pos + 1) == -1,
"no duplicate for fooDuplicateError1");
}
}
});

View File

@ -5,13 +5,12 @@
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/browser/test-console.html";
function test() {
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, testCompletion);
}, true);
}
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
let hud = yield openConsole();
testCompletion(hud);
});
function testCompletion(hud) {
var jsterm = hud.jsterm;
@ -29,7 +28,4 @@ function testCompletion(hud) {
is(jsterm.completeNode.value, " <- no result", "completenode content - matched");
is(input.value, "window.Bug583816", "inputnode content - matched");
is(input.getAttribute("focused"), "true", "input is still focused");
jsterm = input = null;
finishTest();
}

Some files were not shown because too many files have changed in this diff Show More