Merge fx-team to m-c.

This commit is contained in:
Ryan VanderMeulen 2014-01-07 16:15:43 -05:00
commit 23c63aae9b
19 changed files with 162 additions and 80 deletions

View File

@ -18,8 +18,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "console",
// Returns the principal for a given |frame| contained in a given |docShell|.
function getPrincipalForFrame(docShell, frame) {
let ssm = Services.scriptSecurityManager;
let doc = frame && frame.document;
let uri = Services.io.newURI(doc.documentURI, null, null);
let uri = frame.document.documentURIObject;
return ssm.getDocShellCodebasePrincipal(uri, docShell);
}

View File

@ -59,12 +59,12 @@ add_task(function flush_on_duplicate() {
"sessionStorage data has been flushed when duplicating tabs");
yield promiseTabRestored(tab2);
let {storage} = JSON.parse(ss.getTabState(tab2));
gBrowser.removeTab(tab2)
let [{state: {storage}}] = JSON.parse(ss.getClosedTabData(window));
is(storage["http://example.com"].test, "on-duplicate",
"sessionStorage data has been flushed when duplicating tabs");
gBrowser.removeTab(tab);
gBrowser.removeTab(tab2);
});
/**

View File

@ -333,9 +333,14 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY customizeMenu.addToPanel.label "Add to Menu">
<!ENTITY customizeMenu.addToPanel.accesskey "M">
<!ENTITY customizeMenu.moveToToolbar.label "Move to Toolbar">
<!ENTITY customizeMenu.moveToToolbar.accesskey "M">
<!ENTITY customizeMenu.moveToToolbar.accesskey "o">
<!-- LOCALIZATION NOTE (customizeMenu.moveToPanel.accesskey) can appear on the
same context menu as menubarCmd and personalbarCmd, so they should have
different access keys. customizeMenu.moveToToolbar and
customizeMenu.moveToPanel are mutually exclusive, so can share access
keys. -->
<!ENTITY customizeMenu.moveToPanel.label "Move to Menu">
<!ENTITY customizeMenu.moveToPanel.accesskey "M">
<!ENTITY customizeMenu.moveToPanel.accesskey "o">
<!ENTITY customizeMenu.removeFromToolbar.label "Remove from Toolbar">
<!ENTITY customizeMenu.removeFromToolbar.accesskey "R">
<!ENTITY customizeMenu.removeFromMenu.label "Remove from Menu">

View File

@ -30,7 +30,8 @@
</content>
<handlers>
<handler event="click" clickcount="1" action="this._onClick()"/>
<handler event="click" button="0" clickcount="1" action="this._onClick()"/>
<handler event="click" button="1" clickcount="1" action="event.stopPropagation(); this._onClose()"/>
<handler event="dblclick" action="this._onDoubleClick(); event.stopPropagation();"/>
</handlers>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 695 B

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -41,10 +41,10 @@ CheckLength(ExclusiveContext *cx, size_t length)
}
static bool
SetSourceURL(ExclusiveContext *cx, TokenStream &tokenStream, ScriptSource *ss)
SetDisplayURL(ExclusiveContext *cx, TokenStream &tokenStream, ScriptSource *ss)
{
if (tokenStream.hasSourceURL()) {
if (!ss->setSourceURL(cx, tokenStream.sourceURL()))
if (tokenStream.hasDisplayURL()) {
if (!ss->setDisplayURL(cx, tokenStream.displayURL()))
return false;
}
return true;
@ -368,7 +368,7 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
if (!MaybeCheckEvalFreeVariables(cx, evalCaller, scopeChain, parser, pc.ref()))
return nullptr;
if (!SetSourceURL(cx, parser.tokenStream, ss))
if (!SetDisplayURL(cx, parser.tokenStream, ss))
return nullptr;
if (!SetSourceMap(cx, parser.tokenStream, ss))
@ -597,7 +597,7 @@ CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, const ReadOnlyComp
JS_ASSERT(IsAsmJSModuleNative(fun->native()));
}
if (!SetSourceURL(cx, parser.tokenStream, ss))
if (!SetDisplayURL(cx, parser.tokenStream, ss))
return false;
if (!SetSourceMap(cx, parser.tokenStream, ss))

View File

@ -273,7 +273,7 @@ TokenStream::TokenStream(ExclusiveContext *cx, const ReadOnlyCompileOptions &opt
prevLinebase(nullptr),
userbuf(cx, base - options.column, length + options.column), // See comment below
filename(options.filename()),
sourceURL_(nullptr),
displayURL_(nullptr),
sourceMapURL_(nullptr),
tokenbuf(cx),
cx(cx),
@ -333,7 +333,7 @@ TokenStream::TokenStream(ExclusiveContext *cx, const ReadOnlyCompileOptions &opt
TokenStream::~TokenStream()
{
js_free(sourceURL_);
js_free(displayURL_);
js_free(sourceMapURL_);
JS_ASSERT_IF(originPrincipals, originPrincipals->refcount);
@ -808,7 +808,7 @@ TokenStream::getDirectives(bool isMultiline, bool shouldWarnDeprecated)
// comment. To avoid potentially expensive lookahead and backtracking, we
// only check for this case if we encounter a '#' character.
if (!getSourceURL(isMultiline, shouldWarnDeprecated))
if (!getDisplayURL(isMultiline, shouldWarnDeprecated))
return false;
if (!getSourceMappingURL(isMultiline, shouldWarnDeprecated))
return false;
@ -864,13 +864,18 @@ TokenStream::getDirective(bool isMultiline, bool shouldWarnDeprecated,
}
bool
TokenStream::getSourceURL(bool isMultiline, bool shouldWarnDeprecated)
TokenStream::getDisplayURL(bool isMultiline, bool shouldWarnDeprecated)
{
// Match comments of the form "//# sourceURL=<url>" or
// "/\* //# sourceURL=<url> *\/"
//
// Note that while these are labeled "sourceURL" in the source text,
// internally we refer to it as a "displayURL" to distinguish what the
// developer would like to refer to the source as from the source's actual
// URL.
return getDirective(isMultiline, shouldWarnDeprecated, " sourceURL=", 11,
"sourceURL", &sourceURL_);
"sourceURL", &displayURL_);
}
bool

View File

@ -628,12 +628,12 @@ class MOZ_STACK_CLASS TokenStream
return userbuf.limit();
}
bool hasSourceURL() const {
return sourceURL_ != nullptr;
bool hasDisplayURL() const {
return displayURL_ != nullptr;
}
jschar *sourceURL() {
return sourceURL_;
jschar *displayURL() {
return displayURL_;
}
bool hasSourceMapURL() const {
@ -848,7 +848,7 @@ class MOZ_STACK_CLASS TokenStream
bool getDirective(bool isMultiline, bool shouldWarnDeprecated,
const char *directive, int directiveLength,
const char *errorMsgPragma, jschar **destination);
bool getSourceURL(bool isMultiline, bool shouldWarnDeprecated);
bool getDisplayURL(bool isMultiline, bool shouldWarnDeprecated);
bool getSourceMappingURL(bool isMultiline, bool shouldWarnDeprecated);
// |expect| cannot be an EOL char.
@ -889,7 +889,7 @@ class MOZ_STACK_CLASS TokenStream
const jschar *prevLinebase; // start of previous line; nullptr if on the first line
TokenBuf userbuf; // user input buffer
const char *filename; // input filename or null
jschar *sourceURL_; // the user's requested source URL or null
jschar *displayURL_; // the user's requested source URL or null
jschar *sourceMapURL_; // source map's filename or null
CharBuffer tokenbuf; // current token string buffer
bool maybeEOL[256]; // probabilistic EOL lookup table

View File

@ -0,0 +1,39 @@
// In a debuggee with multiple scripts with varying displayURLs (aka //#
// sourceURL), findScripts can filter by displayURL.
var g = newGlobal();
g.eval("function f(){} //# sourceURL=f.js");
g.eval("function g(){} //# sourceURL=g.js");
g.eval("function h(){}");
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var fw = gw.makeDebuggeeValue(g.f);
var ggw = gw.makeDebuggeeValue(g.g);
var hw = gw.makeDebuggeeValue(g.h);
var fScripts = dbg.findScripts({ displayURL: "f.js" });
assertEq(fScripts.indexOf(fw.script) != -1, true);
assertEq(fScripts.indexOf(ggw.script), -1);
assertEq(fScripts.indexOf(hw.script), -1);
var gScripts = dbg.findScripts({ displayURL: "g.js" });
assertEq(gScripts.indexOf(ggw.script) != -1, true);
assertEq(gScripts.indexOf(fw.script), -1);
assertEq(gScripts.indexOf(hw.script), -1);
var allScripts = dbg.findScripts();
assertEq(allScripts.indexOf(fw.script) != -1, true);
assertEq(allScripts.indexOf(ggw.script) != -1, true);
assertEq(allScripts.indexOf(hw.script) != -1, true);
try {
dbg.findScripts({ displayURL: 3 });
// Should never get here because the above line should throw
// JSMSG_UNEXPECTED_TYPE.
assertEq(true, false);
} catch(e) {
assertEq(e.name, "TypeError");
assertEq(e.message.contains("displayURL"), true);
}

View File

@ -1,5 +1,5 @@
/* -*- Mode: javascript; js-indent-level: 4; -*- */
// Source.prototype.sourceURL can be a string or null.
// Source.prototype.displayURL can be a string or null.
let g = newGlobal('new-compartment');
let dbg = new Debugger;

View File

@ -1,5 +1,5 @@
/* -*- Mode: javascript; js-indent-level: 4; -*- */
// Source.prototype.sourceURL can be a string or null.
// Source.prototype.displayURL can be a string or null.
let g = newGlobal('new-compartment');
let dbg = new Debugger;
@ -15,7 +15,7 @@ g.evaluate("function f(x) { return 2*x; }");
assertEq(getDisplayURL(), null);
// With a source url
g.evaluate("function f(x) { return 2*x; }", {sourceURL: 'file:///var/foo.js'});
g.evaluate("function f(x) { return 2*x; }", {displayURL: 'file:///var/foo.js'});
assertEq(getDisplayURL(), 'file:///var/foo.js');
// Nested functions
@ -25,7 +25,7 @@ dbg.onDebuggerStatement = function (frame) {
assertEq(frame.script.source.displayURL, 'file:///var/bar.js');
};
g.evaluate('(function () { (function () { debugger; })(); })();',
{sourceURL: 'file:///var/bar.js'});
{displayURL: 'file:///var/bar.js'});
assertEq(fired, true);
// Comment pragmas
@ -66,6 +66,6 @@ assertEq(getDisplayURL(), 'http://example.com/bar.js');
// With both a comment and the evaluate option.
g.evaluate('function f() {}\n' +
'//# sourceURL=http://example.com/foo.js',
{sourceMapURL: 'http://example.com/bar.js'});
{displayURL: 'http://example.com/bar.js'});
assertEq(getDisplayURL(), 'http://example.com/foo.js');

View File

@ -1326,7 +1326,7 @@ ScriptSource::destroy()
JS_ASSERT(ready());
adjustDataSize(0);
js_free(filename_);
js_free(sourceURL_);
js_free(displayURL_);
js_free(sourceMapURL_);
if (originPrincipals_)
JS_DropPrincipals(TlsPerThreadData.get()->runtimeFromMainThread(), originPrincipals_);
@ -1417,29 +1417,29 @@ ScriptSource::performXDR(XDRState<mode> *xdr)
sourceMapURL_[sourceMapURLLen] = '\0';
}
uint8_t haveSourceURL = hasSourceURL();
if (!xdr->codeUint8(&haveSourceURL))
uint8_t haveDisplayURL = hasDisplayURL();
if (!xdr->codeUint8(&haveDisplayURL))
return false;
if (haveSourceURL) {
uint32_t sourceURLLen = (mode == XDR_DECODE) ? 0 : js_strlen(sourceURL_);
if (!xdr->codeUint32(&sourceURLLen))
if (haveDisplayURL) {
uint32_t displayURLLen = (mode == XDR_DECODE) ? 0 : js_strlen(displayURL_);
if (!xdr->codeUint32(&displayURLLen))
return false;
if (mode == XDR_DECODE) {
size_t byteLen = (sourceURLLen + 1) * sizeof(jschar);
sourceURL_ = static_cast<jschar *>(xdr->cx()->malloc_(byteLen));
if (!sourceURL_)
size_t byteLen = (displayURLLen + 1) * sizeof(jschar);
displayURL_ = static_cast<jschar *>(xdr->cx()->malloc_(byteLen));
if (!displayURL_)
return false;
}
if (!xdr->codeChars(sourceURL_, sourceURLLen)) {
if (!xdr->codeChars(displayURL_, displayURLLen)) {
if (mode == XDR_DECODE) {
js_free(sourceURL_);
sourceURL_ = nullptr;
js_free(displayURL_);
displayURL_ = nullptr;
}
return false;
}
sourceURL_[sourceURLLen] = '\0';
displayURL_[displayURLLen] = '\0';
}
uint8_t haveFilename = !!filename_;
@ -1475,10 +1475,10 @@ ScriptSource::setFilename(ExclusiveContext *cx, const char *filename)
}
bool
ScriptSource::setSourceURL(ExclusiveContext *cx, const jschar *sourceURL)
ScriptSource::setDisplayURL(ExclusiveContext *cx, const jschar *displayURL)
{
JS_ASSERT(sourceURL);
if (hasSourceURL()) {
JS_ASSERT(displayURL);
if (hasDisplayURL()) {
if (cx->isJSContext() &&
!JS_ReportErrorFlagsAndNumber(cx->asJSContext(), JSREPORT_WARNING,
js_GetErrorMessage, nullptr,
@ -1488,20 +1488,20 @@ ScriptSource::setSourceURL(ExclusiveContext *cx, const jschar *sourceURL)
return false;
}
}
size_t len = js_strlen(sourceURL) + 1;
size_t len = js_strlen(displayURL) + 1;
if (len == 1)
return true;
sourceURL_ = js_strdup(cx, sourceURL);
if (!sourceURL_)
displayURL_ = js_strdup(cx, displayURL);
if (!displayURL_)
return false;
return true;
}
const jschar *
ScriptSource::sourceURL()
ScriptSource::displayURL()
{
JS_ASSERT(hasSourceURL());
return sourceURL_;
JS_ASSERT(hasDisplayURL());
return displayURL_;
}
bool

View File

@ -375,7 +375,7 @@ class ScriptSource
uint32_t length_;
uint32_t compressedLength_;
char *filename_;
jschar *sourceURL_;
jschar *displayURL_;
jschar *sourceMapURL_;
JSPrincipals *originPrincipals_;
@ -392,7 +392,7 @@ class ScriptSource
length_(0),
compressedLength_(0),
filename_(nullptr),
sourceURL_(nullptr),
displayURL_(nullptr),
sourceMapURL_(nullptr),
originPrincipals_(originPrincipals),
sourceRetrievable_(false),
@ -440,10 +440,10 @@ class ScriptSource
return filename_;
}
// Source URLs
bool setSourceURL(ExclusiveContext *cx, const jschar *sourceURL);
const jschar *sourceURL();
bool hasSourceURL() const { return sourceURL_ != nullptr; }
// Display URLs
bool setDisplayURL(ExclusiveContext *cx, const jschar *displayURL);
const jschar *displayURL();
bool hasDisplayURL() const { return displayURL_ != nullptr; }
// Source maps
bool setSourceMapURL(ExclusiveContext *cx, const jschar *sourceMapURL);

View File

@ -862,7 +862,7 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
RootedObject element(cx);
RootedString elementProperty(cx);
JSAutoByteString fileNameBytes;
RootedString sourceURL(cx);
RootedString displayURL(cx);
RootedString sourceMapURL(cx);
unsigned lineNumber = 1;
RootedObject global(cx, nullptr);
@ -920,11 +920,11 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
return false;
}
if (!JS_GetProperty(cx, opts, "sourceURL", &v))
if (!JS_GetProperty(cx, opts, "displayURL", &v))
return false;
if (!v.isUndefined()) {
sourceURL = ToString(cx, v);
if (!sourceURL)
displayURL = ToString(cx, v);
if (!displayURL)
return false;
}
@ -1031,11 +1031,11 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
return false;
}
if (sourceURL && !script->scriptSource()->hasSourceURL()) {
const jschar *surl = JS_GetStringCharsZ(cx, sourceURL);
if (!surl)
if (displayURL && !script->scriptSource()->hasDisplayURL()) {
const jschar *durl = JS_GetStringCharsZ(cx, displayURL);
if (!durl)
return false;
if (!script->scriptSource()->setSourceURL(cx, surl))
if (!script->scriptSource()->setDisplayURL(cx, durl))
return false;
}
if (sourceMapURL && !script->scriptSource()->hasSourceMapURL()) {

View File

@ -52,6 +52,7 @@
macro(defineSetter, defineSetter, "__defineSetter__") \
macro(delete, delete_, "delete") \
macro(deleteProperty, deleteProperty, "deleteProperty") \
macro(displayURL, displayURL, "displayURL") \
macro(done, done, "done") \
macro(each, each, "each") \
macro(elementType, elementType, "elementType") \

View File

@ -2321,8 +2321,8 @@ class Debugger::ScriptQuery {
public:
/* Construct a ScriptQuery to use matching scripts for |dbg|. */
ScriptQuery(JSContext *cx, Debugger *dbg):
cx(cx), debugger(dbg), compartments(cx->runtime()), url(cx),
innermostForCompartment(cx->runtime())
cx(cx), debugger(dbg), compartments(cx->runtime()), url(cx), displayURL(cx),
displayURLChars(nullptr), innermostForCompartment(cx->runtime())
{}
/*
@ -2419,6 +2419,16 @@ class Debugger::ScriptQuery {
}
}
/* Check for a 'displayURL' property. */
if (!JSObject::getProperty(cx, query, query, cx->names().displayURL, &displayURL))
return false;
if (!displayURL.isUndefined() && !displayURL.isString()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
"query object's 'displayURL' property",
"neither undefined nor a string");
return false;
}
return true;
}
@ -2427,6 +2437,7 @@ class Debugger::ScriptQuery {
url.setUndefined();
hasLine = false;
innermost = false;
displayURLChars = nullptr;
return matchAllDebuggeeGlobals();
}
@ -2490,6 +2501,14 @@ class Debugger::ScriptQuery {
/* url as a C string. */
JSAutoByteString urlCString;
/* If this is a string, matching scripts' sources have displayURLs equal to
* it. */
RootedValue displayURL;
/* displayURL as a jschar* */
const jschar *displayURLChars;
size_t displayURLLength;
/* True if the query contained a 'line' property. */
bool hasLine;
@ -2553,15 +2572,23 @@ class Debugger::ScriptQuery {
}
/*
* Given that parseQuery or omittedQuery has been called, prepare to
* match scripts. Set urlCString as appropriate.
* Given that parseQuery or omittedQuery has been called, prepare to match
* scripts. Set urlCString and displayURLChars as appropriate.
*/
bool prepareQuery() {
/* Compute urlCString, if a url was given. */
/* Compute urlCString and displayURLChars, if a url or displayURL was
* given respectively. */
if (url.isString()) {
if (!urlCString.encodeLatin1(cx, url.toString()))
return false;
}
if (displayURL.isString()) {
JSString *s = displayURL.toString();
displayURLChars = s->getChars(cx);
displayURLLength = s->length();
if (!displayURLChars)
return false;
}
return true;
}
@ -2590,6 +2617,15 @@ class Debugger::ScriptQuery {
if (line < script->lineno() || script->lineno() + js_GetScriptLineExtent(script) < line)
return;
}
if (displayURLChars) {
if (!script->scriptSource() || !script->scriptSource()->hasDisplayURL())
return;
const jschar *s = script->scriptSource()->displayURL();
if (CompareChars(s, js_strlen(s), displayURLChars, displayURLLength) != 0) {
return;
}
}
if (innermost) {
/*
* For 'innermost' queries, we don't place scripts in |vector| right
@ -3807,8 +3843,8 @@ DebuggerSource_getDisplayURL(JSContext *cx, unsigned argc, Value *vp)
ScriptSource *ss = sourceObject->source();
JS_ASSERT(ss);
if (ss->hasSourceURL()) {
JSString *str = JS_NewUCStringCopyZ(cx, ss->sourceURL());
if (ss->hasDisplayURL()) {
JSString *str = JS_NewUCStringCopyZ(cx, ss->displayURL());
if (!str)
return false;
args.rval().setString(str);

View File

@ -22,6 +22,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/TabRowTextAppearance.Url"
android:textSize="14sp"/>
android:textSize="14sp"
android:maxLength="1024"/>
</LinearLayout>

View File

@ -28,7 +28,8 @@
style="@style/Widget.TwoLinePageRow.Url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawablePadding="5dp"/>
android:drawablePadding="5dp"
android:maxLength="1024"/>
</LinearLayout>

View File

@ -75,13 +75,7 @@ var SelectionHandler = {
observe: function sh_observe(aSubject, aTopic, aData) {
switch (aTopic) {
case "Gesture:SingleTap": {
if (this._activeType == this.TYPE_SELECTION) {
let data = JSON.parse(aData);
if (this._pointInSelection(data.x, data.y))
this.copySelection();
else
this._closeSelection();
} else if (this._activeType == this.TYPE_CURSOR) {
if (this._activeType == this.TYPE_CURSOR) {
// attachCaret() is called in the "Gesture:SingleTap" handler in BrowserEventHandler
// We're guaranteed to call this first, because this observer was added last
this._deactivate();