merge m-c to fx-team

This commit is contained in:
Tim Taubert 2012-08-09 20:48:53 +02:00
commit 87ee5e0faf
15 changed files with 305 additions and 54 deletions

View File

@ -25,11 +25,6 @@ let gBrowserThumbnails = {
*/
_timeouts: null,
/**
* Cache for the PageThumbs module.
*/
_pageThumbs: null,
/**
* List of tab events we want to listen for.
*/
@ -52,9 +47,6 @@ let gBrowserThumbnails = {
}, this);
this._timeouts = new WeakMap();
XPCOMUtils.defineLazyModuleGetter(this, "_pageThumbs",
"resource:///modules/PageThumbs.jsm", "PageThumbs");
},
uninit: function Thumbnails_uninit() {
@ -100,7 +92,7 @@ let gBrowserThumbnails = {
_capture: function Thumbnails_capture(aBrowser) {
if (this._shouldCapture(aBrowser))
this._pageThumbs.captureAndStore(aBrowser);
PageThumbs.captureAndStore(aBrowser);
},
_delayedCapture: function Thumbnails_delayedCapture(aBrowser) {

View File

@ -140,6 +140,9 @@ XPCOMUtils.defineLazyGetter(this, "Social", function() {
return tmp.Social;
});
XPCOMUtils.defineLazyModuleGetter(this, "PageThumbs",
"resource:///modules/PageThumbs.jsm");
#ifdef MOZ_SAFE_BROWSING
XPCOMUtils.defineLazyGetter(this, "SafeBrowsing", function() {
let tmp = {};

View File

@ -3407,7 +3407,20 @@
// Set the cursor to an arrow during tab drags.
dt.mozCursor = "default";
let canvas = tabPreviews.capture(tab, false);
// Create a canvas to which we capture the current tab.
let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
canvas.mozOpaque = true;
// We want drag images to be about 1/6th of the available screen width.
const widthFactor = 0.1739; // 1:5.75 inverse
canvas.width = Math.ceil(screen.availWidth * widthFactor);
// Maintain a 16:9 aspect ratio for drag images.
const aspectRatio = 0.5625; // 16:9 inverse
canvas.height = Math.round(canvas.width * aspectRatio);
let browser = tab.linkedBrowser;
PageThumbs.captureToCanvas(browser.contentWindow, canvas);
dt.setDragImage(canvas, 0, 0);
// _dragOffsetX/Y give the coordinates that the mouse should be

View File

@ -116,11 +116,26 @@ let PageThumbs = {
return;
}
let telemetryCaptureTime = new Date();
let [sw, sh, scale] = this._determineCropSize(aWindow);
let canvas = this._createCanvas();
let ctx = canvas.getContext("2d");
this.captureToCanvas(aWindow, canvas);
// Fetch the canvas data on the next event loop tick so that we allow
// some event processing in between drawing to the canvas and encoding
// its data. We want to block the UI as short as possible. See bug 744100.
Services.tm.currentThread.dispatch(function () {
canvas.mozFetchAsStream(aCallback, this.contentType);
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
},
/**
* Captures a thumbnail from a given window and draws it to the given canvas.
* @param aWindow The DOM window to capture a thumbnail from.
* @param aCanvas The canvas to draw to.
*/
captureToCanvas: function PageThumbs_captureToCanvas(aWindow, aCanvas) {
let telemetryCaptureTime = new Date();
let [sw, sh, scale] = this._determineCropSize(aWindow, aCanvas);
let ctx = aCanvas.getContext("2d");
// Scale the canvas accordingly.
ctx.scale(scale, scale);
@ -136,13 +151,6 @@ let PageThumbs = {
let telemetry = Services.telemetry;
telemetry.getHistogramById("FX_THUMBNAILS_CAPTURE_TIME_MS")
.add(new Date() - telemetryCaptureTime);
// Fetch the canvas data on the next event loop tick so that we allow
// some event processing in between drawing to the canvas and encoding
// its data. We want to block the UI as short as possible. See bug 744100.
Services.tm.currentThread.dispatch(function () {
canvas.mozFetchAsStream(aCallback, this.contentType);
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
},
/**
@ -193,13 +201,14 @@ let PageThumbs = {
/**
* Determines the crop size for a given content window.
* @param aWindow The content window.
* @param aCanvas The target canvas.
* @return An array containing width, height and scale.
*/
_determineCropSize: function PageThumbs_determineCropSize(aWindow) {
_determineCropSize: function PageThumbs_determineCropSize(aWindow, aCanvas) {
let sw = aWindow.innerWidth;
let sh = aWindow.innerHeight;
let [thumbnailWidth, thumbnailHeight] = this._getThumbnailSize();
let {width: thumbnailWidth, height: thumbnailHeight} = aCanvas;
let scale = Math.max(thumbnailWidth / sw, thumbnailHeight / sh);
let scaledWidth = sw * scale;
let scaledHeight = sh * scale;

View File

@ -11,8 +11,6 @@ registerCleanupFunction(function () {
gBrowser.removeTab(gBrowser.tabs[1]);
});
let cachedXULDocument;
/**
* Provide the default test function to start our test runner.
*/

View File

@ -51,15 +51,16 @@ let DebuggerController = {
window.removeEventListener("DOMContentLoaded", this._startupDebugger, true);
DebuggerView.initializePanes();
DebuggerView.initializeEditor();
DebuggerView.StackFrames.initialize();
DebuggerView.Breakpoints.initialize();
DebuggerView.Properties.initialize();
DebuggerView.Scripts.initialize();
DebuggerView.showCloseButton(!this._isRemoteDebugger && !this._isChromeDebugger);
DebuggerView.initializeEditor(function() {
DebuggerView.Scripts.initialize();
DebuggerView.StackFrames.initialize();
DebuggerView.Breakpoints.initialize();
DebuggerView.Properties.initialize();
DebuggerView.showCloseButton(!this._isRemoteDebugger && !this._isChromeDebugger);
this.dispatchEvent("Debugger:Loaded");
this._connect();
this.dispatchEvent("Debugger:Loaded");
this._connect();
}.bind(this));
},
/**
@ -934,7 +935,7 @@ SourceScripts.prototype = {
// Select the preferred script if one exists, the first entry otherwise.
let preferredScriptUrl = DebuggerView.Scripts.preferredScriptUrl;
if (preferredScriptUrl) {
if (preferredScriptUrl && DebuggerView.Scripts.contains(preferredScriptUrl)) {
DebuggerView.Scripts.selectScript(preferredScriptUrl);
} else {
DebuggerView.Scripts.selectIndex(0);

View File

@ -32,8 +32,11 @@ let DebuggerView = {
/**
* Initializes the SourceEditor instance.
*
* @param function aCallback
* Called after the editor finishes initializing.
*/
initializeEditor: function DV_initializeEditor() {
initializeEditor: function DV_initializeEditor(aCallback) {
let placeholder = document.getElementById("editor");
let config = {
@ -45,7 +48,10 @@ let DebuggerView = {
};
this.editor = new SourceEditor();
this.editor.init(placeholder, config, this._onEditorLoad.bind(this));
this.editor.init(placeholder, config, function() {
this._onEditorLoad();
aCallback();
}.bind(this));
},
/**
@ -474,7 +480,7 @@ ScriptsView.prototype = {
for (let i = 0, l = scripts.itemCount; i < l; i++) {
scripts.getItemAtIndex(i).hidden = false;
}
} else {
} else if (this._prevSearchedFile !== file) {
let found = false;
for (let i = 0, l = scripts.itemCount; i < l; i++) {
@ -502,15 +508,18 @@ ScriptsView.prototype = {
scripts.removeAttribute("tooltiptext");
}
}
if (line > -1) {
if (this._prevSearchedLine !== line && line > -1) {
editor.setCaretPosition(line - 1);
}
if (token.length) {
if (this._prevSearchedToken !== token && token.length > 0) {
let offset = editor.find(token, { ignoreCase: true });
if (offset > -1) {
editor.setSelection(offset, offset + token.length)
}
}
this._prevSearchedFile = file;
this._prevSearchedLine = line;
this._prevSearchedToken = token;
},
/**

View File

@ -44,6 +44,7 @@ MOCHITEST_BROWSER_TESTS = \
browser_dbg_stack-04.js \
browser_dbg_stack-05.js \
browser_dbg_location-changes.js \
browser_dbg_location-changes-new.js \
browser_dbg_location-changes-blank.js \
browser_dbg_script-switching.js \
browser_dbg_scripts-sorting.js \

View File

@ -0,0 +1,91 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Make sure that changing the tab location URL to a page with other scripts works.
*/
var gPane = null;
var gTab = null;
var gDebuggee = null;
var gDebugger = null;
function test()
{
debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
gTab = aTab;
gDebuggee = aDebuggee;
gPane = aPane;
gDebugger = gPane.contentWindow;
testSimpleCall();
});
}
function testSimpleCall() {
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
Services.tm.currentThread.dispatch({
run: function() {
var frames = gDebugger.DebuggerView.StackFrames._frames,
childNodes = frames.childNodes;
is(gDebugger.DebuggerController.activeThread.state, "paused",
"Should only be getting stack frames while paused.");
is(frames.querySelectorAll(".dbg-stackframe").length, 1,
"Should have only one frame.");
is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
"All children should be frames.");
isnot(gDebugger.DebuggerView.Scripts.selected, null,
"There should be a selected script.");
isnot(gDebugger.editor.getText().length, 0,
"The source editor should have some text displayed.");
testLocationChange();
}
}, 0);
});
gDebuggee.simpleCall();
}
function testLocationChange()
{
gDebugger.DebuggerController.activeThread.resume(function() {
gDebugger.DebuggerController.client.addOneTimeListener("tabNavigated", function(aEvent, aPacket) {
ok(true, "tabNavigated event was fired.");
gDebugger.DebuggerController.client.addOneTimeListener("tabAttached", function(aEvent, aPacket) {
ok(true, "Successfully reattached to the tab again.");
// Wait for the initial resume...
gDebugger.gClient.addOneTimeListener("resumed", function() {
isnot(gDebugger.DebuggerView.Scripts.selected, null,
"There should be a selected script.");
isnot(gDebugger.editor.getText().length, 0,
"The source editor should have some text displayed.");
let menulist = gDebugger.DebuggerView.Scripts._scripts;
let noScripts = gDebugger.L10N.getStr("noScriptsText");
isnot(menulist.getAttribute("label"), noScripts,
"The menulist should not display a notice that there are no scripts availalble.");
isnot(menulist.getAttribute("tooltiptext"), "",
"The menulist should have a tooltip text attributed.");
closeDebuggerAndFinish();
});
});
});
content.location = EXAMPLE_URL + "browser_dbg_iframes.html";
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -191,6 +191,11 @@ function clear() {
function write(text) {
clear();
append(text);
}
function append(text) {
gSearchBox.focus();
for (let i = 0; i < text.length; i++) {
EventUtils.sendChar(text[i]);

View File

@ -96,6 +96,8 @@ function secondSearch() {
window.removeEventListener(aEvent.type, _onEvent);
executeSoon(function() {
append("#" + token);
info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length,
@ -103,6 +105,49 @@ function secondSearch() {
is(gScripts.visibleItemsCount, 1,
"Not all the correct scripts are shown after the search. (2)");
waitForFirstScript();
});
}
});
gScripts.selectIndex(1);
}
function waitForFirstScript() {
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
info("Current script url:\n" + aEvent.detail.url + "\n");
info("Debugger editor text:\n" + gEditor.getText() + "\n");
let url = aEvent.detail.url;
if (url.indexOf("-01.js") != -1) {
window.removeEventListener(aEvent.type, _onEvent);
executeSoon(function() {
thirdSearch();
});
}
});
gScripts.selectIndex(0);
}
function thirdSearch() {
let token = "deb";
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
info("Current script url:\n" + aEvent.detail.url + "\n");
info("Debugger editor text:\n" + gEditor.getText() + "\n");
let url = aEvent.detail.url;
if (url.indexOf("-02.js") != -1) {
window.removeEventListener(aEvent.type, _onEvent);
executeSoon(function() {
info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length,
"The editor didn't jump to the correct line. (3)");
is(gScripts.visibleItemsCount, 1,
"Not all the correct scripts are shown after the search. (3)");
finalCheck(0, "ugger;", token);
});
}
@ -115,7 +160,7 @@ function finalCheck(i, string, token) {
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (3)");
"The editor didn't remain at the correct token. (4)");
if (string[i]) {
EventUtils.sendChar(string[i]);
@ -126,7 +171,7 @@ 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)");
"The editor didn't remain at the correct token. (5)");
executeSoon(function() {
let noMatchingScripts = gDebugger.L10N.getStr("noMatchingScriptsText");
@ -139,7 +184,7 @@ function finalCheck(i, string, token) {
write("BOGUS");
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (5)");
"The editor didn't remain at the correct token. (6)");
is(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should display a notice that no scripts match the searched token.");
@ -151,7 +196,7 @@ 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. (6)");
"The editor didn't remain at the correct token. (7)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice after the searchbox was emptied.");
@ -171,6 +216,11 @@ function clear() {
function write(text) {
clear();
append(text);
}
function append(text) {
gSearchBox.focus();
for (let i = 0; i < text.length; i++) {
EventUtils.sendChar(text[i]);

View File

@ -550,7 +550,7 @@ function OutputPanel(aChromeDoc, aInput, aLoadCallback)
this._loadCallback = aLoadCallback;
/*
<panel id="gcli-output"
<tooltip id="gcli-output"
noautofocus="true"
noautohide="true"
class="gcli-panel">
@ -558,13 +558,15 @@ function OutputPanel(aChromeDoc, aInput, aLoadCallback)
id="gcli-output-frame"
src="chrome://browser/content/devtools/gclioutput.xhtml"
flex="1"/>
</panel>
</tooltip>
*/
this._panel = aChromeDoc.createElement("panel");
// TODO: Switch back from tooltip to panel when metacity focus issue is fixed:
// https://bugzilla.mozilla.org/show_bug.cgi?id=780102
this._panel = aChromeDoc.createElement("tooltip");
this._panel.id = "gcli-output";
this._panel.classList.add("gcli-panel");
this._panel.setAttribute("noautofocus", "true");
this._panel.setAttribute("noautohide", "true");
this._toolbar.parentElement.insertBefore(this._panel, this._toolbar);
this._frame = aChromeDoc.createElementNS(NS_XHTML, "iframe");
@ -579,6 +581,10 @@ function OutputPanel(aChromeDoc, aInput, aLoadCallback)
this._frame.addEventListener("load", this._onload, true);
this.loaded = false;
this.canHide = false;
this._onpopuphiding = this._onpopuphiding.bind(this);
this._panel.addEventListener("popuphiding", this._onpopuphiding, true);
}
/**
@ -606,6 +612,18 @@ OutputPanel.prototype._onload = function OP_onload()
}
};
/**
* Prevent the popup from hiding if it is not permitted via this.canHide.
*/
OutputPanel.prototype._onpopuphiding = function OP_onpopuphiding(aEvent)
{
// TODO: When we switch back from tooltip to panel we can remove this hack:
// https://bugzilla.mozilla.org/show_bug.cgi?id=780102
if (!this.canHide) {
aEvent.preventDefault();
}
};
/**
* Display the OutputPanel.
*/
@ -618,6 +636,8 @@ OutputPanel.prototype.show = function OP_show()
this._resize();
}.bind(this), 0);
this.canHide = false;
this._panel.openPopup(this._input, "before_start", 0, 0, false, false, null);
this._resize();
@ -677,6 +697,7 @@ OutputPanel.prototype.update = function OP_update()
*/
OutputPanel.prototype.remove = function OP_remove()
{
this.canHide = true;
this._panel.hidePopup();
if (this.displayedOutput) {
@ -693,11 +714,15 @@ OutputPanel.prototype.destroy = function OP_destroy()
{
this.remove();
this._panel.removeEventListener("popuphiding", this._onpopuphiding, true);
this._panel.removeChild(this._frame);
this._toolbar.parentElement.removeChild(this._panel);
delete this._input;
delete this._toolbar;
delete this._onload;
delete this._onpopuphiding;
delete this._panel;
delete this._frame;
delete this._content;
@ -714,6 +739,7 @@ OutputPanel.prototype._visibilityChanged = function OP_visibilityChanged(aEvent)
if (aEvent.outputVisible === true) {
// this.show is called by _outputChanged
} else {
this.canHide = true;
this._panel.hidePopup();
}
};
@ -734,7 +760,7 @@ function TooltipPanel(aChromeDoc, aInput, aLoadCallback)
this._onload = this._onload.bind(this);
this._loadCallback = aLoadCallback;
/*
<panel id="gcli-tooltip"
<tooltip id="gcli-tooltip"
type="arrow"
noautofocus="true"
noautohide="true"
@ -743,13 +769,15 @@ function TooltipPanel(aChromeDoc, aInput, aLoadCallback)
id="gcli-tooltip-frame"
src="chrome://browser/content/devtools/gclitooltip.xhtml"
flex="1"/>
</panel>
</tooltip>
*/
this._panel = aChromeDoc.createElement("panel");
// TODO: Switch back from tooltip to panel when metacity focus issue is fixed:
// https://bugzilla.mozilla.org/show_bug.cgi?id=780102
this._panel = aChromeDoc.createElement("tooltip");
this._panel.id = "gcli-tooltip";
this._panel.classList.add("gcli-panel");
this._panel.setAttribute("noautofocus", "true");
this._panel.setAttribute("noautohide", "true");
this._toolbar.parentElement.insertBefore(this._panel, this._toolbar);
this._frame = aChromeDoc.createElementNS(NS_XHTML, "iframe");
@ -759,7 +787,12 @@ function TooltipPanel(aChromeDoc, aInput, aLoadCallback)
this._panel.appendChild(this._frame);
this._frame.addEventListener("load", this._onload, true);
this.loaded = false;
this.canHide = false;
this._onpopuphiding = this._onpopuphiding.bind(this);
this._panel.addEventListener("popuphiding", this._onpopuphiding, true);
}
/**
@ -785,6 +818,18 @@ TooltipPanel.prototype._onload = function TP_onload()
}
};
/**
* Prevent the popup from hiding if it is not permitted via this.canHide.
*/
TooltipPanel.prototype._onpopuphiding = function TP_onpopuphiding(aEvent)
{
// TODO: When we switch back from tooltip to panel we can remove this hack:
// https://bugzilla.mozilla.org/show_bug.cgi?id=780102
if (!this.canHide) {
aEvent.preventDefault();
}
};
/**
* Display the TooltipPanel.
*/
@ -802,6 +847,8 @@ TooltipPanel.prototype.show = function TP_show(aDimensions)
this._resize();
}.bind(this), 0);
this.canHide = false;
this._resize();
this._panel.openPopup(this._input, "before_start", aDimensions.start * 10, 0, false, false, null);
this._input.focus();
@ -845,6 +892,7 @@ TooltipPanel.prototype._resize = function TP_resize()
*/
TooltipPanel.prototype.remove = function TP_remove()
{
this.canHide = true;
this._panel.hidePopup();
};
@ -855,6 +903,8 @@ TooltipPanel.prototype.destroy = function TP_destroy()
{
this.remove();
this._panel.removeEventListener("popuphiding", this._onpopuphiding, true);
this._panel.removeChild(this._frame);
this._toolbar.parentElement.removeChild(this._panel);
@ -862,6 +912,7 @@ TooltipPanel.prototype.destroy = function TP_destroy()
delete this._dimensions;
delete this._input;
delete this._onload;
delete this._onpopuphiding;
delete this._panel;
delete this._frame;
delete this._toolbar;
@ -879,6 +930,7 @@ TooltipPanel.prototype._visibilityChanged = function TP_visibilityChanged(aEvent
if (aEvent.tooltipVisible === true) {
this.show(aEvent.dimensions);
} else {
this.canHide = true;
this._panel.hidePopup();
}
};

View File

@ -25,10 +25,15 @@ function ThreadActor(aHooks)
this._frameActors = [];
this._environmentActors = [];
this._hooks = aHooks ? aHooks : {};
this._breakpointStore = {};
this._scripts = {};
}
/**
* The breakpoint store must be shared across instances of ThreadActor so that
* page reloads don't blow away all of our breakpoints.
*/
ThreadActor._breakpointStore = {};
ThreadActor.prototype = {
actorPrefix: "context",
@ -36,6 +41,8 @@ ThreadActor.prototype = {
get dbg() { return this._dbg; },
get _breakpointStore() { return ThreadActor._breakpointStore; },
get threadLifetimePool() {
if (!this._threadLifetimePool) {
this._threadLifetimePool = new ActorPool(this.conn);

View File

@ -0,0 +1,19 @@
/* -*- Mode: js; js-indent-level: 2; -*- */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Note: Removing this test will regress bug 754251. See comment above
// ThreadActor._breakpointStore.
function run_test()
{
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://global/content/devtools/dbg-script-actors.js");
let instance1 = new ThreadActor();
let instance2 = new ThreadActor();
do_check_eq(instance1._breakpointStore, ThreadActor._breakpointStore);
do_check_eq(instance2._breakpointStore, ThreadActor._breakpointStore);
do_check_eq(instance1._breakpointStore, instance2._breakpointStore);
}

View File

@ -60,3 +60,4 @@ tail =
[test_framebindings-05.js]
[test_pause_exceptions-01.js]
[test_pause_exceptions-02.js]
[test_breakpointstore.js]