merge m-c to fx-team

This commit is contained in:
Tim Taubert 2012-07-19 16:38:20 +02:00
commit 84ac6d69de
12 changed files with 266 additions and 6 deletions

View File

@ -149,6 +149,8 @@ ScriptsView.prototype = {
*/
empty: function DVS_empty() {
this._scripts.selectedIndex = -1;
this._scripts.setAttribute("label", L10N.getStr("noScriptsText"));
this._scripts.removeAttribute("tooltiptext");
while (this._scripts.firstChild) {
this._scripts.removeChild(this._scripts.firstChild);
@ -425,9 +427,9 @@ ScriptsView.prototype = {
return;
}
let script = selectedItem.getUserData("sourceScript");
this._preferredScript = script;
DebuggerController.SourceScripts.showScript(script);
this._preferredScript = selectedItem;
this._scripts.setAttribute("tooltiptext", selectedItem.value);
DebuggerController.SourceScripts.showScript(selectedItem.getUserData("sourceScript"));
},
/**
@ -438,8 +440,15 @@ ScriptsView.prototype = {
let scripts = this._scripts;
let [file, line, token] = this._getSearchboxInfo();
// If the webpage has no scripts, searching is redundant.
if (!scripts.itemCount) {
return;
}
// Presume we won't find anything.
scripts.selectedItem = this._preferredScript;
scripts.setAttribute("label", this._preferredScript.label);
scripts.setAttribute("tooltiptext", this._preferredScript.value);
// If we're not searching for a file anymore, unhide all the scripts.
if (!file) {
@ -447,7 +456,9 @@ ScriptsView.prototype = {
scripts.getItemAtIndex(i).hidden = false;
}
} else {
for (let i = 0, l = scripts.itemCount, found = false; i < l; i++) {
let found = false;
for (let i = 0, l = scripts.itemCount; i < l; i++) {
let item = scripts.getItemAtIndex(i);
let target = item.label.toLowerCase();
@ -458,6 +469,8 @@ ScriptsView.prototype = {
if (!found) {
found = true;
scripts.selectedItem = item;
scripts.setAttribute("label", item.label);
scripts.setAttribute("tooltiptext", item.value);
}
}
// Hide what doesn't match our search.
@ -465,6 +478,10 @@ ScriptsView.prototype = {
item.hidden = true;
}
}
if (!found) {
scripts.setAttribute("label", L10N.getStr("noMatchingScriptsText"));
scripts.removeAttribute("tooltiptext");
}
}
if (line > -1) {
editor.setCaretPosition(line - 1);

View File

@ -64,6 +64,7 @@
tabindex="0"/>
</hbox>
<menulist id="scripts" class="devtools-menulist"
sizetopopup="always"
label="&debuggerUI.emptyScriptText;"/>
<textbox id="scripts-search" type="search"
class="devtools-searchinput"

View File

@ -67,6 +67,13 @@ function testLocationChange()
is(gDebugger.editor.getText().length, 0,
"The source editor not have any text displayed.");
let menulist = gDebugger.DebuggerView.Scripts._scripts;
let noScripts = gDebugger.L10N.getStr("noScriptsText");
is(menulist.getAttribute("label"), noScripts,
"The menulist should display a notice that there are no scripts availalble.");
is(menulist.getAttribute("tooltiptext"), "",
"The menulist shouldn't have any tooltip text attributed when there are no scripts available.");
closeDebuggerAndFinish();
});
});

View File

@ -124,10 +124,41 @@ function finalCheck(i, string, token) {
}
clear();
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (4)");
executeSoon(function() {
let noMatchingScripts = gDebugger.L10N.getStr("noMatchingScriptsText");
is(gScripts.visibleItemsCount, 2,
"Not all the scripts are shown after the searchbox was emptied.");
is(gMenulist.selectedIndex, 1,
"The menulist should have retained its selected index after the searchbox was emptied.");
write("BOGUS");
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (5)");
is(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should display a notice that no scripts match the searched token.");
is(gScripts.visibleItemsCount, 0,
"No scripts should be displayed in the menulist after a bogus search.");
is(gMenulist.selectedIndex, 1,
"The menulist should retain its selected index after a bogus search.");
clear();
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (6)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice after the searchbox was emptied.");
is(gScripts.visibleItemsCount, 2,
"Not all the scripts are shown after the searchbox was emptied.");
is(gMenulist.selectedIndex, 1,
"The menulist should have retained its selected index after the searchbox was emptied of a bogus search.");
closeDebuggerAndFinish();
});

View File

@ -441,7 +441,7 @@ TiltUtils.DOM = {
}
// prepare the queue array
Array.prototype.push.apply(queue, name === "iframe" ?
Array.prototype.push.apply(queue, name === "iframe" || name === "frame" ?
node.contentDocument.childNodes :
node.childNodes);
}

View File

@ -56,6 +56,7 @@ MOCHITEST_BROWSER_FILES += \
browser_tilt_utils04.js \
browser_tilt_utils05.js \
browser_tilt_utils06.js \
browser_tilt_utils07.js \
browser_tilt_visualizer.js \
browser_tilt_zoom.js \
$(NULL)

View File

@ -0,0 +1,192 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function init(callback) {
let iframe = gBrowser.ownerDocument.createElement("iframe");
iframe.addEventListener("load", function onLoad() {
iframe.removeEventListener("load", onLoad, true);
callback(iframe);
gBrowser.parentNode.removeChild(iframe);
finish();
}, true);
iframe.setAttribute("src", ["data:text/html,",
"<!DOCTYPE html>",
"<html>",
"<body style='margin: 0;'>",
"<frameset cols='50%,50%'>",
"<frame src='",
["data:text/html,",
"<!DOCTYPE html>",
"<html>",
"<body style='margin: 0;'>",
"<div id='test-div' style='width: 123px; height: 456px;'></div>",
"</body>",
"</html>"
].join(""),
"' />",
"<frame src='",
["data:text/html,",
"<!DOCTYPE html>",
"<html>",
"<body style='margin: 0;'>",
"<span></span>",
"</body>",
"</html>"
].join(""),
"' />",
"</frameset>",
"<iframe src='",
["data:text/html,",
"<!DOCTYPE html>",
"<html>",
"<body>",
"<span></span>",
"</body>",
"</html>"
].join(""),
"'></iframe>",
"<frame src='",
["data:text/html,",
"<!DOCTYPE html>",
"<html>",
"<body style='margin: 0;'>",
"<span></span>",
"</body>",
"</html>"
].join(""),
"' />",
"<frame src='",
["data:text/html,",
"<!DOCTYPE html>",
"<html>",
"<body style='margin: 0;'>",
"<iframe src='",
["data:text/html,",
"<!DOCTYPE html>",
"<html>",
"<body>",
"<div></div>",
"</body>",
"</html>"
].join(""),
"'></iframe>",
"</body>",
"</html>"
].join(""),
"' />",
"</body>",
"</html>"
].join(""));
gBrowser.parentNode.appendChild(iframe);
}
function test() {
waitForExplicitFinish();
ok(TiltUtils, "The TiltUtils object doesn't exist.");
let dom = TiltUtils.DOM;
ok(dom, "The TiltUtils.DOM wasn't found.");
init(function(iframe) {
let cwDimensions = dom.getContentWindowDimensions(iframe.contentWindow);
is(cwDimensions.width - iframe.contentWindow.scrollMaxX,
iframe.contentWindow.innerWidth,
"The content window width wasn't calculated correctly.");
is(cwDimensions.height - iframe.contentWindow.scrollMaxY,
iframe.contentWindow.innerHeight,
"The content window height wasn't calculated correctly.");
let nodeCoordinates = LayoutHelpers.getRect(
iframe.contentDocument.getElementById("test-div"), iframe.contentWindow);
let frameOffset = LayoutHelpers.getIframeContentOffset(iframe);
let frameRect = iframe.getBoundingClientRect();
is(nodeCoordinates.top, frameRect.top + frameOffset[0],
"The node coordinates top value wasn't calculated correctly.");
is(nodeCoordinates.left, frameRect.left + frameOffset[1],
"The node coordinates left value wasn't calculated correctly.");
is(nodeCoordinates.width, 123,
"The node coordinates width value wasn't calculated correctly.");
is(nodeCoordinates.height, 456,
"The node coordinates height value wasn't calculated correctly.");
let store = dom.traverse(iframe.contentWindow);
is(store.nodes.length, 16,
"The traverse() function didn't walk the correct number of nodes.");
is(store.info.length, 16,
"The traverse() function didn't examine the correct number of nodes.");
is(store.info[0].name, "html",
"the 1st traversed node isn't the expected one.");
is(store.info[0].depth, 0,
"the 1st traversed node doesn't have the expected depth.");
is(store.info[1].name, "head",
"the 2nd traversed node isn't the expected one.");
is(store.info[1].depth, 1,
"the 2nd traversed node doesn't have the expected depth.");
is(store.info[2].name, "body",
"the 3rd traversed node isn't the expected one.");
is(store.info[2].depth, 1,
"the 3rd traversed node doesn't have the expected depth.");
is(store.info[3].name, "div",
"the 4th traversed node isn't the expected one.");
is(store.info[3].depth, 2,
"the 4th traversed node doesn't have the expected depth.");
is(store.info[4].name, "span",
"the 5th traversed node isn't the expected one.");
is(store.info[4].depth, 2,
"the 5th traversed node doesn't have the expected depth.");
is(store.info[5].name, "iframe",
"the 6th traversed node isn't the expected one.");
is(store.info[5].depth, 2,
"the 6th traversed node doesn't have the expected depth.");
is(store.info[6].name, "span",
"the 7th traversed node isn't the expected one.");
is(store.info[6].depth, 2,
"the 7th traversed node doesn't have the expected depth.");
is(store.info[7].name, "iframe",
"the 8th traversed node isn't the expected one.");
is(store.info[7].depth, 2,
"the 8th traversed node doesn't have the expected depth.");
is(store.info[8].name, "html",
"the 9th traversed node isn't the expected one.");
is(store.info[8].depth, 3,
"the 9th traversed node doesn't have the expected depth.");
is(store.info[9].name, "html",
"the 10th traversed node isn't the expected one.");
is(store.info[9].depth, 3,
"the 10th traversed node doesn't have the expected depth.");
is(store.info[10].name, "head",
"the 11th traversed node isn't the expected one.");
is(store.info[10].depth, 4,
"the 11th traversed node doesn't have the expected depth.");
is(store.info[11].name, "body",
"the 12th traversed node isn't the expected one.");
is(store.info[11].depth, 4,
"the 12th traversed node doesn't have the expected depth.");
is(store.info[12].name, "head",
"the 13th traversed node isn't the expected one.");
is(store.info[12].depth, 4,
"the 13th traversed node doesn't have the expected depth.");
is(store.info[13].name, "body",
"the 14th traversed node isn't the expected one.");
is(store.info[13].depth, 4,
"the 14th traversed node doesn't have the expected depth.");
is(store.info[14].name, "span",
"the 15th traversed node isn't the expected one.");
is(store.info[14].depth, 5,
"the 15th traversed node doesn't have the expected depth.");
is(store.info[15].name, "div",
"the 16th traversed node isn't the expected one.");
is(store.info[15].depth, 5,
"the 16th traversed node doesn't have the expected depth.");
});
}

View File

@ -67,4 +67,4 @@
<!-- LOCALIZATION NOTE (emptyScriptText): The text to display in the menulist when
- there are no scripts. -->
<!ENTITY debuggerUI.emptyScriptText "No scripts.">
<!ENTITY debuggerUI.emptyScriptText "No scripts">

View File

@ -59,6 +59,14 @@ emptyStackText=No stacks to display.
# breakpoints list when there are no breakpoints to display.
emptyBreakpointsText=No breakpoints to display.
# LOCALIZATION NOTE (noScriptsText): The text to display in the menulist when
# there are no scripts.
noScriptsText=No scripts
# LOCALIZATION NOTE (noMatchingScriptsText): The text to display in the
# menulist when there are no matching scripts after filtering.
noMatchingScriptsText=No matching scripts
# LOCALIZATION NOTE (breakpointMenuItem): The text for all the elements that
# are displayed in the breakpoints menu item popup.
breakpointMenuItem.enableSelf=Enable breakpoint

View File

@ -18,6 +18,7 @@
#scripts {
max-width: 350px;
min-width: 150px;
}
/**

View File

@ -20,6 +20,7 @@
#scripts {
max-width: 350px;
min-width: 150px;
}
/**

View File

@ -18,6 +18,7 @@
#scripts {
max-width: 350px;
min-width: 150px;
}
/**