Merge mozilla-central into mozilla-inbound

This commit is contained in:
Ehsan Akhgari 2012-07-18 09:38:49 -04:00
commit 13792204c3
76 changed files with 861 additions and 2563 deletions

View File

@ -107,12 +107,17 @@ let gDrag = {
* @return Whether we should handle this drag and drop operation.
*/
isValid: function Drag_isValid(aEvent) {
let dt = aEvent.dataTransfer;
let mimeType = "text/x-moz-url";
let link = gDragDataHelper.getLinkFromDragEvent(aEvent);
// Check that the drag data is non-empty.
// Can happen when dragging places folders.
return dt && dt.types.contains(mimeType) && dt.getData(mimeType);
if (!link || !link.url) {
return false;
}
// Check that we're not accepting URLs which would inherit the caller's
// principal (such as javascript: or data:).
return gLinkChecker.checkLoadURI(link.url);
},
/**

View File

@ -0,0 +1,22 @@
#ifdef 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/. */
#endif
let gDragDataHelper = {
get mimeType() {
return "text/x-moz-url";
},
getLinkFromDragEvent: function DragDataHelper_getLinkFromDragEvent(aEvent) {
let dt = aEvent.dataTransfer;
if (!dt || !dt.types.contains(this.mimeType)) {
return null;
}
let data = dt.getData(this.mimeType) || "";
let [url, title] = data.split(/[\r\n]+/);
return {url: url, title: title};
}
};

View File

@ -90,14 +90,14 @@ let gDrop = {
if (aCell != draggedSite.cell)
draggedSite.pin(index);
} else {
// A new link was dragged onto the grid. Create it by pinning its URL.
let dt = aEvent.dataTransfer;
let [url, title] = dt.getData("text/x-moz-url").split(/[\r\n]+/);
let link = {url: url, title: title};
gPinnedLinks.pin(link, index);
let link = gDragDataHelper.getLinkFromDragEvent(aEvent);
if (link) {
// A new link was dragged onto the grid. Create it by pinning its URL.
gPinnedLinks.pin(link, index);
// Make sure the newly added link is not blocked.
gBlockedLinks.unblock(link);
// Make sure the newly added link is not blocked.
gBlockedLinks.unblock(link);
}
}
},

View File

@ -18,6 +18,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "Rect",
let {
links: gLinks,
allPages: gAllPages,
linkChecker: gLinkChecker,
pinnedLinks: gPinnedLinks,
blockedLinks: gBlockedLinks
} = NewTabUtils;
@ -53,6 +54,7 @@ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
#include cells.js
#include sites.js
#include drag.js
#include dragDataHelper.js
#include drop.js
#include dropTargetShim.js
#include dropPreview.js

View File

@ -28,6 +28,7 @@ _BROWSER_FILES = \
browser_newtab_bug725996.js \
browser_newtab_bug734043.js \
browser_newtab_bug735987.js \
browser_newtab_bug765628.js \
head.js \
$(NULL)

View File

@ -0,0 +1,27 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const BAD_DRAG_DATA = "javascript:alert('h4ck0rz');\nbad stuff";
const GOOD_DRAG_DATA = "http://example.com/#99\nsite 99";
function runTests() {
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();
checkGrid("0,1,2,3,4,5,6,7,8");
sendDropEvent(0, BAD_DRAG_DATA);
sendDropEvent(1, GOOD_DRAG_DATA);
yield whenPagesUpdated();
checkGrid("0,99p,1,2,3,4,5,6,7");
}
function sendDropEvent(aCellIndex, aDragData) {
let ifaceReq = getContentWindow().QueryInterface(Ci.nsIInterfaceRequestor);
let windowUtils = ifaceReq.getInterface(Ci.nsIDOMWindowUtils);
let event = createDragEvent("drop", aDragData);
windowUtils.dispatchDOMEventViaPresShell(getCell(aCellIndex).node, event, true);
}

View File

@ -373,17 +373,24 @@ Rule.prototype = {
this._title += ":" + this.ruleLine;
}
return this._title + (this.mediaText ? " @media " + this.mediaText : "");
},
get inheritedSource()
{
if (this._inheritedSource) {
return this._inheritedSource;
}
this._inheritedSource = "";
if (this.inherited) {
let eltText = this.inherited.tagName.toLowerCase();
if (this.inherited.id) {
eltText += "#" + this.inherited.id;
}
let args = [eltText, this._title];
this._title = CssLogic._strings.formatStringFromName("rule.inheritedSource",
args, args.length);
this._inheritedSource =
CssLogic._strings.formatStringFromName("rule.inheritedSource", [eltText], 1);
}
return this._title + (this.mediaText ? " @media " + this.mediaText : "");
return this._inheritedSource;
},
/**
@ -958,6 +965,8 @@ CssRuleView.prototype = {
return;
}
this._clearRules();
// Repopulate the element style.
this._elementStyle.populate();
@ -1023,23 +1032,23 @@ CssRuleView.prototype = {
{
// Run through the current list of rules, attaching
// their editors in order. Create editors if needed.
let last = null;
let lastInheritedSource = "";
for each (let rule in this._elementStyle.rules) {
let inheritedSource = rule.inheritedSource;
if (inheritedSource != lastInheritedSource) {
let h2 = this.doc.createElementNS(HTML_NS, "div");
h2.className = "ruleview-rule-inheritance";
h2.textContent = inheritedSource;
lastInheritedSource = inheritedSource;
this.element.appendChild(h2);
}
if (!rule.editor) {
new RuleEditor(this, rule);
}
let target = last ? last.nextSibling : this.element.firstChild;
this.element.insertBefore(rule.editor.element, target);
last = rule.editor.element;
}
// ... and now editors for rules that don't exist anymore
// have been pushed to the end of the list, go ahead and
// delete their nodes. The rules they edit have already been
// forgotten.
while (last && last.nextSibling) {
this.element.removeChild(last.nextSibling);
this.element.appendChild(rule.editor.element);
}
},
@ -1154,16 +1163,6 @@ CssRuleView.prototype = {
let rx = new RegExp("^" + inline + "\\r?\\n?", "g");
text = text.replace(rx, "");
// Remove file:line
text = text.replace(/[\w\.]+:\d+(\r?\n)/g, "$1");
// Remove inherited from: line
let inheritedFrom = _strings.
GetStringFromName("rule.inheritedSource");
inheritedFrom = inheritedFrom.replace(/\s%S\s\(%S\)/g, "");
rx = new RegExp("(\r?\n)" + inheritedFrom + ".*", "g");
text = text.replace(rx, "$1");
clipboardHelper.copyString(text, this.doc);
if (aEvent) {
@ -1184,9 +1183,9 @@ CssRuleView.prototype = {
return;
}
if (node.className != "rule-view-row") {
if (node.className != "ruleview-rule") {
while (node = node.parentElement) {
if (node.className == "rule-view-row") {
if (node.className == "ruleview-rule") {
break;
}
}
@ -1332,7 +1331,7 @@ RuleEditor.prototype = {
_create: function RuleEditor_create()
{
this.element = this.doc.createElementNS(HTML_NS, "div");
this.element.className = "rule-view-row";
this.element.className = "ruleview-rule";
this.element._ruleEditor = this;
// Give a relative position for the inplace editor's measurement
@ -1705,6 +1704,7 @@ TextPropertyEditor.prototype = {
textContent: computed.name
});
appendText(li, ": ");
createChild(li, "span", {
class: "ruleview-propertyvalue",
textContent: computed.value

View File

@ -43,7 +43,7 @@
}
.ruleview-property:not(:hover) > .ruleview-enableproperty {
visibility: hidden;
pointer-events: none;
}
.ruleview-namecontainer {

View File

@ -122,7 +122,7 @@ function checkCopyRule() {
function checkCopyRuleWithEditorSelected()
{
let contentDoc = ruleViewFrame().contentDocument;
let rows = contentDoc.querySelectorAll(".rule-view-row");
let rules = contentDoc.querySelectorAll(".ruleview-rule");
let propNodes = contentDoc.querySelectorAll(".ruleview-property");
let propNode = propNodes[2];
let propNameNode = propNode.querySelector(".ruleview-propertyname");
@ -137,7 +137,7 @@ function checkCopyRuleWithEditorSelected()
" color: rgb\\(170, 170, 170\\);[\\r\\n]+" +
"}[\\r\\n]*";
let elementRuleEditor = rows[0]._ruleEditor;
let elementRuleEditor = rules[0]._ruleEditor;
waitForEditorFocus(elementRuleEditor.element, function onNewElement(aEditor) {
ok(aEditor, "we have the editor");

View File

@ -1176,12 +1176,13 @@ let ConsoleAPIObserver = {
aRemoteMessage.objectsCacheId = Manager.sequenceId;
aRemoteMessage.argumentsToString = [];
let mapFunction = function(aItem) {
aRemoteMessage.argumentsToString.push(this._formatObject(aItem));
let formattedObject = this._formatObject(aItem);
aRemoteMessage.argumentsToString.push(formattedObject);
if (WebConsoleUtils.isObjectInspectable(aItem)) {
return JSTerm.prepareObjectForRemote(aItem,
aRemoteMessage.objectsCacheId);
}
return aItem;
return formattedObject;
}.bind(this);
aRemoteMessage.apiMessage.arguments =

View File

@ -4236,7 +4236,7 @@ ConsoleUtils = {
treeView.data = {
rootCacheId: body.cacheId,
panelCacheId: body.cacheId,
remoteObject: body.remoteObject,
remoteObject: Array.isArray(body.remoteObject) ? body.remoteObject : [],
remoteObjectProvider: body.remoteObjectProvider,
};

View File

@ -111,6 +111,7 @@ MOCHITEST_BROWSER_FILES = \
browser_webconsole_menustatus.js \
browser_result_format_as_string.js \
browser_webconsole_bug_737873_mixedcontent.js \
browser_output_breaks_after_console_dir_uninspectable.js \
head.js \
$(NULL)

View File

@ -0,0 +1,55 @@
/* 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 the Web Console output does not break after we try to call
// console.dir() for objects that are not inspectable.
function test()
{
waitForExplicitFinish();
addTab("data:text/html;charset=utf8,test for bug 773466");
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
openConsole(null, performTest);
}, true);
}
function performTest(hud)
{
hud.jsterm.clearOutput(true);
content.console.log("fooBug773466a");
content.console.dir(function funBug773466(){});
waitForSuccess({
name: "eval results are shown",
validatorFn: function()
{
return hud.outputNode.textContent.indexOf("funBug773466") > -1;
},
successFn: function()
{
isnot(hud.outputNode.textContent.indexOf("fooBug773466a"), -1,
"fooBug773466a shows");
ok(hud.outputNode.querySelector(".webconsole-msg-inspector"),
"the console.dir() tree shows");
content.console.log("fooBug773466b");
waitForSuccess(waitForAnotherConsoleLogCall);
},
failureFn: finishTest,
});
let waitForAnotherConsoleLogCall = {
name: "eval result after console.dir()",
validatorFn: function()
{
return hud.outputNode.textContent.indexOf("fooBug773466b") > -1;
},
successFn: finishTest,
failureFn: finishTest,
};
}

View File

@ -33,8 +33,8 @@ rule.sourceElement=element
# LOCALIZATION NOTE (rule.inheritedSource): Shown for CSS rules
# that were inherited from a parent node. Will be passed a node
# identifier and a source location.
# e.g "Inherited from body#bodyID (styles.css:20)"
rule.inheritedSource=Inherited from %S (%S)
# e.g "Inherited from body#bodyID"
rule.inheritedSource=Inherited from %S
# LOCALIZATION NOTE (style.highlighter.button): These strings are used inside
# sidebar of the Highlighter for the style inspector button.

View File

@ -16,6 +16,11 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "gPrincipal", function () {
let uri = Services.io.newURI("about:newtab", null, null);
return Services.scriptSecurityManager.getCodebasePrincipal(uri);
});
// The preference that tells whether this feature is enabled.
const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
@ -33,11 +38,8 @@ let Storage = {
* The dom storage instance used to persist data belonging to the New Tab Page.
*/
get domStorage() {
let uri = Services.io.newURI("about:newtab", null, null);
let principal = Services.scriptSecurityManager.getCodebasePrincipal(uri);
let sm = Services.domStorageManager;
let storage = sm.getLocalStorageForPrincipal(principal, "");
let storage = sm.getLocalStorageForPrincipal(gPrincipal, "");
// Cache this value, overwrite the getter.
let descriptor = {value: storage, enumerable: true};
@ -363,8 +365,10 @@ let PlacesProvider = {
while (row = aResultSet.getNextRow()) {
let url = row.getResultByIndex(1);
let title = row.getResultByIndex(2);
links.push({url: url, title: title});
if (LinkChecker.checkLoadURI(url)) {
let title = row.getResultByIndex(2);
links.push({url: url, title: title});
}
}
},
@ -549,6 +553,37 @@ let Telemetry = {
Telemetry.init();
/**
* Singleton that checks if a given link should be displayed on about:newtab
* or if we should rather not do it for security reasons. URIs that inherit
* their caller's principal will be filtered.
*/
let LinkChecker = {
_cache: {},
get flags() {
return Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL;
},
checkLoadURI: function LinkChecker_checkLoadURI(aURI) {
if (!(aURI in this._cache))
this._cache[aURI] = this._doCheckLoadURI(aURI);
return this._cache[aURI];
},
_doCheckLoadURI: function Links_doCheckLoadURI(aURI) {
try {
Services.scriptSecurityManager.
checkLoadURIStrWithPrincipal(gPrincipal, aURI, this.flags);
return true;
} catch (e) {
// We got a weird URI or one that would inherit the caller's principal.
return false;
}
}
};
/**
* Singleton that provides the public API of this JSM.
*/
@ -567,8 +602,9 @@ let NewTabUtils = {
}, true);
},
allPages: AllPages,
links: Links,
allPages: AllPages,
linkChecker: LinkChecker,
pinnedLinks: PinnedLinks,
blockedLinks: BlockedLinks
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 882 B

After

Width:  |  Height:  |  Size: 804 B

View File

@ -143,22 +143,38 @@
*/
.ruleview {
background-color: #FFF;
background-color: white;
}
.ruleview-rule-source {
background-color: -moz-dialog;
color: -moz-dialogText;
padding: 2px 5px;
color: hsl(121,42%,43%); /* green */
-moz-padding-start: 5px;
cursor: pointer;
text-align: right;
float: right;
-moz-user-select: -moz-none;
}
.ruleview-rule-inheritance {
background-color: hsl(0,0%,90%);
color: hsl(0,0%,50%);
border-top: 1px solid hsl(0,0%,65%);
border-bottom: 1px solid hsl(0,0%,65%);
padding: 1px 4px;
margin-top: 4px;
-moz-user-select: -moz-none;
}
.ruleview-rule-source:hover {
text-decoration: underline;
}
.ruleview-code {
padding: 2px 5px;
.ruleview-rule {
padding: 2px 4px;
}
.ruleview-rule + .ruleview-rule {
border-top: 1px dotted #cddae5;
}
.ruleview-warning {
@ -187,8 +203,15 @@
.ruleview-enableproperty {
height: 10px;
width: 10px;
-moz-margin-start: 2px;
-moz-margin-start: 1px;
-moz-margin-end: 0;
transition: opacity 100ms;
transition-delay: 200ms;
}
.ruleview-property:not(:hover) > .ruleview-enableproperty {
opacity: 0;
transition: none;
}
.ruleview-expander {
@ -211,7 +234,11 @@
.ruleview-propertyname {
padding: 1px 0;
color: #0060C0;
color: hsl(210,100%,38%); /* blue */
}
.ruleview-propertyvalue {
padding: 1px 0;
}
.ruleview-namecontainer,
@ -250,10 +277,10 @@
.ruleview-namecontainer > .ruleview-propertyname,
.ruleview-propertycontainer > .ruleview-propertyvalue {
border-bottom: 1px dotted transparent;
border-bottom: 1px dashed transparent;
}
.ruleview-namecontainer:hover > .ruleview-propertyname,
.ruleview-propertycontainer:hover > .ruleview-propertyvalue {
border-bottom-color: black;
border-bottom-color: hsl(0,0%,50%);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 882 B

After

Width:  |  Height:  |  Size: 804 B

View File

@ -145,22 +145,38 @@
*/
.ruleview {
background-color: #FFF;
background-color: white;
}
.ruleview-rule-source {
background-color: -moz-dialog;
color: -moz-dialogText;
padding: 2px 5px;
color: hsl(121,42%,43%); /* green */
-moz-padding-start: 5px;
cursor: pointer;
text-align: right;
float: right;
-moz-user-select: -moz-none;
}
.ruleview-rule-inheritance {
background-color: hsl(0,0%,90%);
color: hsl(0,0%,50%);
border-top: 1px solid hsl(0,0%,65%);
border-bottom: 1px solid hsl(0,0%,65%);
padding: 1px 4px;
margin-top: 4px;
-moz-user-select: -moz-none;
}
.ruleview-rule-source:hover {
text-decoration: underline;
}
.ruleview-code {
padding: 2px 5px;
.ruleview-rule {
padding: 2px 4px;
}
.ruleview-rule + .ruleview-rule {
border-top: 1px dotted #cddae5;
}
.ruleview-warning {
@ -189,8 +205,15 @@
.ruleview-enableproperty {
height: 10px;
width: 10px;
-moz-margin-start: 2px;
-moz-margin-start: 1px;
-moz-margin-end: 0;
transition: opacity 100ms;
transition-delay: 200ms;
}
.ruleview-property:not(:hover) > .ruleview-enableproperty {
opacity: 0;
transition: none;
}
.ruleview-expander {
@ -213,7 +236,11 @@
.ruleview-propertyname {
padding: 1px 0;
color: #0060C0;
color: hsl(210,100%,38%); /* blue */
}
.ruleview-propertyvalue {
padding: 1px 0;
}
.ruleview-namecontainer,
@ -252,10 +279,10 @@
.ruleview-namecontainer > .ruleview-propertyname,
.ruleview-propertycontainer > .ruleview-propertyvalue {
border-bottom: 1px dotted transparent;
border-bottom: 1px dashed transparent;
}
.ruleview-namecontainer:hover > .ruleview-propertyname,
.ruleview-propertycontainer:hover > .ruleview-propertyvalue {
border-bottom-color: black;
border-bottom-color: hsl(0,0%,50%);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 882 B

After

Width:  |  Height:  |  Size: 804 B

View File

@ -144,22 +144,38 @@
*/
.ruleview {
background-color: #FFF;
background-color: white;
}
.ruleview-rule-source {
background-color: -moz-dialog;
color: -moz-dialogText;
padding: 2px 5px;
color: hsl(121,42%,43%); /* green */
-moz-padding-start: 5px;
cursor: pointer;
text-align: right;
float: right;
-moz-user-select: -moz-none;
}
.ruleview-rule-inheritance {
background-color: hsl(0,0%,90%);
color: hsl(0,0%,50%);
border-top: 1px solid hsl(0,0%,65%);
border-bottom: 1px solid hsl(0,0%,65%);
padding: 1px 4px;
margin-top: 4px;
-moz-user-select: -moz-none;
}
.ruleview-rule-source:hover {
text-decoration: underline;
}
.ruleview-code {
padding: 2px 5px;
.ruleview-rule {
padding: 2px 4px;
}
.ruleview-rule + .ruleview-rule {
border-top: 1px dotted #cddae5;
}
.ruleview-warning {
@ -188,8 +204,15 @@
.ruleview-enableproperty {
height: 10px;
width: 10px;
-moz-margin-start: 2px;
-moz-margin-start: 1px;
-moz-margin-end: 0;
transition: opacity 100ms;
transition-delay: 200ms;
}
.ruleview-property:not(:hover) > .ruleview-enableproperty {
opacity: 0;
transition: none;
}
.ruleview-expander {
@ -212,7 +235,11 @@
.ruleview-propertyname {
padding: 1px 0;
color: #0060C0;
color: hsl(210,100%,38%); /* blue */
}
.ruleview-propertyvalue {
padding: 1px 0;
}
.ruleview-namecontainer,
@ -251,10 +278,10 @@
.ruleview-namecontainer > .ruleview-propertyname,
.ruleview-propertycontainer > .ruleview-propertyvalue {
border-bottom: 1px dotted transparent;
border-bottom: 1px dashed transparent;
}
.ruleview-namecontainer:hover > .ruleview-propertyname,
.ruleview-propertycontainer:hover > .ruleview-propertyvalue {
border-bottom-color: black;
border-bottom-color: hsl(0,0%,50%);
}

View File

@ -649,7 +649,47 @@ nsRange::ComparePoint(nsIDOMNode* aParent, PRInt32 aOffset, PRInt16* aResult)
return NS_OK;
}
NS_IMETHODIMP
nsRange::IntersectsNode(nsIDOMNode* aNode, bool* aResult)
{
*aResult = false;
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
// TODO: This should throw a TypeError.
NS_ENSURE_ARG(node);
NS_ENSURE_TRUE(mIsPositioned, NS_ERROR_NOT_INITIALIZED);
// Step 3.
nsINode* parent = node->GetNodeParent();
if (!parent) {
// Steps 2 and 4.
// |parent| is null, so |node|'s root is |node| itself.
*aResult = (GetRoot() == node);
return NS_OK;
}
// Step 5.
PRInt32 nodeIndex = parent->IndexOf(node);
// Steps 6-7.
// Note: if disconnected is true, ComparePoints returns 1.
bool disconnected = false;
*aResult = nsContentUtils::ComparePoints(mStartParent, mStartOffset,
parent, nodeIndex + 1,
&disconnected) < 0 &&
nsContentUtils::ComparePoints(parent, nodeIndex,
mEndParent, mEndOffset,
&disconnected) < 0;
// Step 2.
if (disconnected) {
*aResult = false;
}
return NS_OK;
}
/******************************************************
* Private helper routines
******************************************************/

View File

@ -524,13 +524,12 @@ nsDOMEvent::PreventDefault()
return NS_OK;
}
nsresult
void
nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
{
mEvent->userType =
nsContentUtils::GetEventIdAndAtom(aEventTypeArg, mEvent->eventStructType,
&(mEvent->message));
return NS_OK;
}
NS_IMETHODIMP
@ -551,7 +550,7 @@ nsDOMEvent::InitEvent(const nsAString& aEventTypeArg, bool aCanBubbleArg, bool a
}
}
NS_ENSURE_SUCCESS(SetEventType(aEventTypeArg), NS_ERROR_FAILURE);
SetEventType(aEventTypeArg);
if (aCanBubbleArg) {
mEvent->flags &= ~NS_EVENT_FLAG_CANT_BUBBLE;

View File

@ -224,7 +224,7 @@ public:
protected:
// Internal helper functions
nsresult SetEventType(const nsAString& aEventTypeArg);
void SetEventType(const nsAString& aEventTypeArg);
already_AddRefed<nsIContent> GetTargetFromFrame();
nsEvent* mEvent;

View File

@ -6,6 +6,7 @@ DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
FAIL_ON_WARNINGS := 1
include $(DEPTH)/config/autoconf.mk

View File

@ -6,6 +6,7 @@ DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
FAIL_ON_WARNINGS := 1
include $(DEPTH)/config/autoconf.mk

View File

@ -6,6 +6,7 @@ DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
FAIL_ON_WARNINGS := 1
include $(DEPTH)/config/autoconf.mk

View File

@ -7,6 +7,7 @@ DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
FAIL_ON_WARNINGS := 1
include $(DEPTH)/config/autoconf.mk

View File

@ -6,6 +6,7 @@ DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
FAIL_ON_WARNINGS := 1
include $(DEPTH)/config/autoconf.mk

View File

@ -6,6 +6,7 @@ DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
FAIL_ON_WARNINGS := 1
include $(DEPTH)/config/autoconf.mk

View File

@ -258,7 +258,7 @@ DOMSVGLengthList::InsertItemBefore(nsIDOMSVGLength *newItem,
if (mAList->IsAnimating()) {
Element()->AnimationNeedsResample();
}
*_retval = domItem.forget().get();
domItem.forget(_retval);
return NS_OK;
}

View File

@ -259,7 +259,7 @@ DOMSVGNumberList::InsertItemBefore(nsIDOMSVGNumber *newItem,
if (mAList->IsAnimating()) {
Element()->AnimationNeedsResample();
}
*_retval = domItem.forget().get();
domItem.forget(_retval);
return NS_OK;
}

View File

@ -384,7 +384,7 @@ DOMSVGPathSegList::InsertItemBefore(nsIDOMSVGPathSeg *aNewItem,
if (AttrIsAnimating()) {
Element()->AnimationNeedsResample();
}
*_retval = domItem.forget().get();
domItem.forget(_retval);
return NS_OK;
}

View File

@ -317,7 +317,7 @@ DOMSVGPointList::InsertItemBefore(nsIDOMSVGPoint *aNewItem,
if (AttrIsAnimating()) {
Element()->AnimationNeedsResample();
}
*_retval = domItem.forget().get();
domItem.forget(_retval);
return NS_OK;
}

View File

@ -273,7 +273,7 @@ DOMSVGTransformList::InsertItemBefore(nsIDOMSVGTransform *newItem,
if (mAList->IsAnimating()) {
Element()->AnimationNeedsResample();
}
*_retval = domItem.forget().get();
domItem.forget(_retval);
return NS_OK;
}

View File

@ -588,8 +588,6 @@ NS_NewSVG##_elementName##Element(nsIContent **aResult, \
{ \
nsRefPtr<nsSVG##_elementName##Element> it = \
new nsSVG##_elementName##Element(aNodeInfo); \
if (!it) \
return NS_ERROR_OUT_OF_MEMORY; \
\
nsresult rv = it->Init(); \
\
@ -597,7 +595,7 @@ NS_NewSVG##_elementName##Element(nsIContent **aResult, \
return rv; \
} \
\
*aResult = it.forget().get(); \
it.forget(aResult); \
\
return rv; \
}
@ -610,8 +608,6 @@ NS_NewSVG##_elementName##Element(nsIContent **aResult, \
{ \
nsRefPtr<nsSVG##_elementName##Element> it = \
new nsSVG##_elementName##Element(aNodeInfo, aFromParser); \
if (!it) \
return NS_ERROR_OUT_OF_MEMORY; \
\
nsresult rv = it->Init(); \
\
@ -619,7 +615,7 @@ NS_NewSVG##_elementName##Element(nsIContent **aResult, \
return rv; \
} \
\
*aResult = it.forget().get(); \
it.forget(aResult); \
\
return rv; \
}

View File

@ -472,7 +472,7 @@ NS_ScriptErrorReporter(JSContext *cx,
const PRUnichar* m = static_cast<const PRUnichar*>(report->ucmessage);
if (m) {
const PRUnichar* n = static_cast<const PRUnichar*>
(js::GetErrorTypeNameFromNumber(cx, report->errorNumber));
(js::GetErrorTypeName(cx, report->exnType));
if (n) {
msg.Assign(n);
msg.AppendLiteral(": ");

View File

@ -4,6 +4,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/. */
#include <stdarg.h>
#include "BindingUtils.h"
#include "xpcprivate.h"
@ -12,6 +14,32 @@
namespace mozilla {
namespace dom {
JSErrorFormatString ErrorFormatString[] = {
#define MSG_DEF(_name, _argc, _str) \
{ _str, _argc, JSEXN_TYPEERR },
#include "mozilla/dom/Errors.msg"
#undef MSG_DEF
};
const JSErrorFormatString*
GetErrorMessage(void* aUserRef, const char* aLocale,
const unsigned aErrorNumber)
{
MOZ_ASSERT(aErrorNumber < ArrayLength(ErrorFormatString));
return &ErrorFormatString[aErrorNumber];
}
bool
ThrowErrorMessage(JSContext* aCx, const ErrNum aErrorNumber, ...)
{
va_list ap;
va_start(ap, aErrorNumber);
JS_ReportErrorNumberVA(aCx, GetErrorMessage, NULL,
static_cast<const unsigned>(aErrorNumber), ap);
va_end(ap);
return false;
}
bool
DefineConstants(JSContext* cx, JSObject* obj, ConstantSpec* cs)
{

View File

@ -29,6 +29,17 @@ class nsGlobalWindow;
namespace mozilla {
namespace dom {
enum ErrNum {
#define MSG_DEF(_name, _argc, _str) \
_name,
#include "mozilla/dom/Errors.msg"
#undef MSG_DEF
Err_Limit
};
bool
ThrowErrorMessage(JSContext* aCx, const ErrNum aErrorNumber, ...);
template<bool mainThread>
inline bool
Throw(JSContext* cx, nsresult rv)
@ -414,8 +425,38 @@ struct EnumEntry {
size_t length;
};
template<bool Fatal>
inline bool
EnumValueNotFound(JSContext* cx, const jschar* chars, size_t length,
const char* type)
{
return false;
}
template<>
inline bool
EnumValueNotFound<false>(JSContext* cx, const jschar* chars, size_t length,
const char* type)
{
// TODO: Log a warning to the console.
return true;
}
template<>
inline bool
EnumValueNotFound<true>(JSContext* cx, const jschar* chars, size_t length,
const char* type)
{
NS_LossyConvertUTF16toASCII deflated(static_cast<const PRUnichar*>(chars),
length);
return ThrowErrorMessage(cx, MSG_INVALID_ENUM_VALUE, deflated.get(), type);
}
template<bool InvalidValueFatal>
inline int
FindEnumStringIndex(JSContext* cx, JS::Value v, const EnumEntry* values, bool* ok)
FindEnumStringIndex(JSContext* cx, JS::Value v, const EnumEntry* values,
const char* type, bool* ok)
{
// JS_StringEqualsAscii is slow as molasses, so don't use it here.
JSString* str = JS_ValueToString(cx, v);
@ -451,7 +492,7 @@ FindEnumStringIndex(JSContext* cx, JS::Value v, const EnumEntry* values, bool* o
}
}
*ok = true;
*ok = EnumValueNotFound<InvalidValueFatal>(cx, chars, length, type);
return -1;
}

View File

@ -2006,20 +2006,27 @@ for (uint32_t i = 0; i < length; ++i) {
raise TypeError("We don't support nullable enumerated arguments "
"yet")
enum = type.inner.identifier.name
if invalidEnumValueFatal:
handleInvalidEnumValueCode = " MOZ_ASSERT(index >= 0);\n"
else:
handleInvalidEnumValueCode = (
" if (index < 0) {\n"
" return true;\n"
" }\n")
return (
"{\n"
" bool ok;\n"
" int index = FindEnumStringIndex(cx, ${val}, %(values)s, &ok);\n"
" int index = FindEnumStringIndex<%(invalidEnumValueFatal)s>(cx, ${val}, %(values)s, \"%(enumtype)s\", &ok);\n"
" if (!ok) {\n"
" return false;\n"
" }\n"
" if (index < 0) {\n"
" return %(failureCode)s;\n"
" }\n"
"%(handleInvalidEnumValueCode)s"
" ${declName} = static_cast<%(enumtype)s>(index);\n"
"}" % { "enumtype" : enum,
"values" : enum + "Values::strings",
"failureCode" : "Throw<false>(cx, NS_ERROR_XPC_BAD_CONVERT_JS)" if invalidEnumValueFatal else "true" },
"invalidEnumValueFatal" : toStringBool(invalidEnumValueFatal),
"handleInvalidEnumValueCode" : handleInvalidEnumValueCode },
CGGeneric(enum), None, isOptional)
if type.isCallback():
@ -2762,6 +2769,8 @@ class CGMethodCall(CGThing):
def __init__(self, argsPre, nativeMethodName, static, descriptor, method):
CGThing.__init__(self)
methodName = '"%s.%s"' % (descriptor.interface.identifier.name, method.identifier.name)
def requiredArgCount(signature):
arguments = signature[1]
if len(arguments) == 0:
@ -2785,18 +2794,15 @@ class CGMethodCall(CGThing):
signature = signatures[0]
self.cgRoot = CGList([ CGIndenter(getPerSignatureCall(signature)) ])
requiredArgs = requiredArgCount(signature)
if requiredArgs > 0:
code = (
"if (argc < %d) {\n"
" return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, %s);\n"
"}" % (requiredArgs, methodName))
self.cgRoot.prepend(
CGWrapper(
CGIndenter(
CGGeneric(
"if (argc < %d) {\n"
" return Throw<%s>(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);\n"
"}" % (requiredArgs,
toStringBool(not descriptor.workers)))
),
pre="\n", post="\n")
)
CGWrapper(CGIndenter(CGGeneric(code)), pre="\n", post="\n"))
return
# Need to find the right overload
@ -2978,11 +2984,10 @@ class CGMethodCall(CGThing):
overloadCGThings.append(
CGSwitch("argcount",
argCountCases,
CGGeneric("return Throw<%s>(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);" %
toStringBool(not descriptor.workers))))
CGGeneric("return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, %s);\n" % methodName)))
overloadCGThings.append(
CGGeneric('MOZ_NOT_REACHED("We have an always-returning default case");\n'
'return false;'))
CGGeneric('MOZ_NOT_REACHED("We have an always-returning default case");\n'
'return false;'))
self.cgRoot = CGWrapper(CGIndenter(CGList(overloadCGThings, "\n")),
pre="\n")

23
dom/bindings/Errors.msg Normal file
View File

@ -0,0 +1,23 @@
/* 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/. */
/*
* The format for each error message is:
*
* MSG_DEF(<SYMBOLIC_NAME>, <ARGUMENT_COUNT>, <FORMAT_STRING>)
*
* where
*
* <SYMBOLIC_NAME> is a legal C++ identifer that will be used in the source.
*
* <ARGUMENT_COUNT> is an integer literal specifying the total number of
* replaceable arguments in the following format string.
*
* <FORMAT_STRING> is a string literal, containing <ARGUMENT_COUNT> sequences
* {X} where X is an integer representing the argument number that will
* be replaced with a string value when the error is reported.
*/
MSG_DEF(MSG_INVALID_ENUM_VALUE, 2, "Value '{0}' is not a valid value for enumeration '{1}'.")
MSG_DEF(MSG_MISSING_ARGUMENTS, 1, "Not enough arguments to {0}.")

View File

@ -63,6 +63,7 @@ EXPORTS_mozilla = \
EXPORTS_$(binding_include_path) = \
DOMJSClass.h \
Errors.msg \
PrototypeList.h \
RegisterBindings.h \
Nullable.h \
@ -156,4 +157,4 @@ GARBAGE += \
# don't have issues with .cpp files being compiled before we've generated the
# headers they depend on. This is really only needed for the test files, since
# the non-test headers are all exported above anyway.
export:: $(binding_header_files)
export:: $(binding_header_files)

View File

@ -49,6 +49,18 @@ Source; Usage and purpose; License
use with outstanding changes in either directory.
MPL
* parseFailures.py
Parses failures out of a mochitest log and writes out JSON files and Makefiles
into the correct failures/ folder.
The mochitest log should be produced by setting the 'dumpFailures' flag in
testharnessreport.js; this will print out the encountered failures, marked
by @ signs.
MPL
* writeMakefile.py
Helper functions to write out Makefiles.
MPL
* Makefile.in
Integration with our build system. Installs support files into /resources and
includes a .mk file for each repository.

View File

@ -14,13 +14,12 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
$(NULL)
MOCHITEST_FILES += \
_FILES = \
implementation.js \
tests.js \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -11,14 +11,13 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
_FILES = \
test_runtest.html \
test_event.html \
$(NULL)
MOCHITEST_FILES += \
data.js \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -11,12 +11,11 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
$(NULL)
MOCHITEST_FILES += \
_FILES = \
reset.css \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -11,8 +11,9 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
_FILES = \
test_addRange.html \
test_collapse.html \
test_collapseToStartEnd.html \
@ -25,11 +26,9 @@ MOCHITEST_FILES = \
test_isCollapsed.html \
test_removeAllRanges.html \
test_selectAllChildren.html \
$(NULL)
MOCHITEST_FILES += \
common.js \
test-iframe.html \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -378,7 +378,6 @@
"Range interface: attribute endOffset": true,
"Range interface: attribute collapsed": true,
"Range interface: attribute commonAncestorContainer": true,
"Range interface: operation intersectsNode(Node)": true,
"Range interface: calling setStart(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: calling setEnd(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: calling setStartBefore(Node) on document.createRange() with too few arguments must throw TypeError": true,
@ -393,7 +392,6 @@
"Range interface: calling surroundContents(Node) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: calling isPointInRange(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: calling comparePoint(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: document.createRange() must inherit property \"intersectsNode\" with the proper type (29)": true,
"Range interface: calling intersectsNode(Node) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: calling setStart(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
"Range interface: calling setEnd(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
@ -409,7 +407,6 @@
"Range interface: calling surroundContents(Node) on detachedRange with too few arguments must throw TypeError": true,
"Range interface: calling isPointInRange(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
"Range interface: calling comparePoint(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
"Range interface: detachedRange must inherit property \"intersectsNode\" with the proper type (29)": true,
"Range interface: calling intersectsNode(Node) on detachedRange with too few arguments must throw TypeError": true,
"NodeIterator interface: existence and properties of interface object": true,
"NodeIterator interface: existence and properties of interface prototype object": true,

View File

@ -1,9 +1,5 @@
{
"XMLHttpRequest interface constructor": true,
"XMLHttpRequest interface: calling open(DOMString,DOMString,boolean,DOMString,DOMString) on new XMLHttpRequest() with too few arguments must throw TypeError": true,
"XMLHttpRequest interface: calling setRequestHeader(DOMString,DOMString) on new XMLHttpRequest() with too few arguments must throw TypeError": true,
"XMLHttpRequest interface: calling getResponseHeader(DOMString) on new XMLHttpRequest() with too few arguments must throw TypeError": true,
"XMLHttpRequest interface: calling overrideMimeType(DOMString) on new XMLHttpRequest() with too few arguments must throw TypeError": true,
"FormData interface: existence and properties of interface object": true,
"FormData interface constructor": true,
"FormData interface: existence and properties of interface prototype object": true,

View File

@ -11,8 +11,9 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
_FILES = \
test_body-onload.html \
test_pageload-image.html \
test_pageload-video.html \
@ -20,10 +21,8 @@ MOCHITEST_FILES = \
test_window-onerror-parse-error.html \
test_window-onerror-runtime-error.html \
test_window-onerror-runtime-error-throw.html \
$(NULL)
MOCHITEST_FILES += \
nested-document-write-external.js \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -11,12 +11,11 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
_FILES = \
test_001.html \
$(NULL)
MOCHITEST_FILES += \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -17,6 +17,7 @@ import subprocess
import sys
import parseManifest
import writeMakefile
def parseManifestFile(dest, dir):
subdirs, mochitests, _, __, supportfiles = parseManifest.parseManifestFile("hg-%s/%s/MANIFEST" % (dest, dir))
@ -77,11 +78,6 @@ def copy(thissrcdir, dest, directories):
# Empty directory, i.e., the repository root
importDirs(thissrcdir, dest, subdirs)
def makefileString(entries):
if not len(entries):
return " $(NULL)"
return "\n".join([" %s \\" % (entry, ) for entry in entries]) + "\n $(NULL)"
def printMakefile(dest, directories):
"""Create a .mk file to be included into the main Makefile.in, which lists the
directories with tests.
@ -90,37 +86,11 @@ def printMakefile(dest, directories):
path = dest + ".mk"
fp = open(path, "wb")
fp.write("DIRS += \\\n")
fp.write(makefileString([makePath(dest, d) for d in directories]))
fp.write(writeMakefile.makefileString([makePath(dest, d) for d in directories]))
fp.write("\n")
fp.close()
subprocess.check_call(["hg", "add", path])
makefileTemplate = """# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
DEPTH = ${depth}
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = ${relativesrcdir}
DIRS = \\
${dirs}
include $$(DEPTH)/config/autoconf.mk
include $$(topsrcdir)/config/rules.mk
"""
testsTemplate = """
_TESTS = \\
${tests}
_TESTS += \\
${support}
libs:: $$(_TESTS)
\t$$(INSTALL) $$(foreach f,$$^,"$$f") $$(DEPTH)/_tests/testing/mochitest/tests/$$(relativesrcdir)
"""
def printMakefiles(thissrcdir, dest, directories):
"""Create Makefile.in files for each directory that contains tests we import.
"""
@ -131,24 +101,17 @@ def printMakefiles(thissrcdir, dest, directories):
else:
# Empty directory, i.e., the repository root
path = dest
abspath = "%s/%s" % (thissrcdir, path)
print "Creating Makefile.in in %s..." % (path, )
subdirs, mochitests, supportfiles = parseManifestFile(dest, d)
abspath = "%s/%s" % (thissrcdir, path)
files = ["test_%s" % (mochitest, ) for mochitest in mochitests]
files.extend(supportfiles)
result = writeMakefile.substMakefile("importTestsuite.py", abspath, subdirs, files)
fp = open(path + "/Makefile.in", "wb")
result = string.Template(makefileTemplate).substitute({
"depth": "..%s" % ("/.." * abspath.count("/"), ),
"relativesrcdir": "%s/%s" % (thissrcdir, path),
"dirs": makefileString(subdirs)
})
if len(mochitests) + len(supportfiles):
result += string.Template(testsTemplate).substitute({
"tests": makefileString(["test_%s" % (mochitest, ) for mochitest in mochitests]),
"support": makefileString(supportfiles)
})
fp.write(result)
fp.close()

View File

@ -0,0 +1,68 @@
# 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/.
import json
import os
import sys
import writeMakefile
def extractLines(fp):
lines = []
watch = False
for line in fp:
if line == '@@@ @@@ Failures\n':
watch = True
elif watch:
watch = False
idx = line.index('@@@')
lines.append((line[:idx], line[idx + 3:]))
return lines
def ensuredir(path):
dir = path[:path.rfind('/')]
if not os.path.exists(dir):
os.makedirs(dir)
def dumpFailures(lines):
files = []
for url, objstr in lines:
if objstr == '{}\n':
continue
jsonpath = 'failures/' + url + '.json'
files.append(jsonpath)
ensuredir(jsonpath)
obj = json.loads(objstr)
formattedobj = json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': '))
fp = open(jsonpath, 'w')
fp.write(formattedobj + '\n')
fp.close()
return files
def writeMakefiles(files):
pathmap = {}
for path in files:
dirp, leaf = path.rsplit('/', 1)
pathmap.setdefault(dirp, []).append(leaf)
for k, v in pathmap.iteritems():
result = writeMakefile.substMakefile('parseFailures.py', 'dom/imptests/' + k, [], v)
fp = open(k + '/Makefile.in', 'wb')
fp.write(result)
fp.close()
def main(logPath):
fp = open(logPath, 'rb')
lines = extractLines(fp)
fp.close()
files = dumpFailures(lines)
writeMakefiles(files)
if __name__ == '__main__':
if len(sys.argv) < 2:
print "Please pass the path to the logfile from which failures should be extracted."
main(sys.argv[1])

View File

@ -12,6 +12,17 @@ var W3CTest = {
*/
"expectedFailures": {},
/**
* If set to true, we will dump the test failures to the console.
*/
"dumpFailures": false,
/**
* If dumpFailures is true, this holds a structure like necessary for
* expectedFailures, for ease of updating the expectations.
*/
"failures": {},
/**
* List of test results, needed by TestRunner to update the UI.
*/
@ -58,6 +69,17 @@ var W3CTest = {
this.runner[(test.result === !test.todo) ? "log" : "error"](msg);
},
"_logCollapsedMessages": function() {
if (this.collapsedMessages) {
this._log({
"result": true,
"todo": false,
"message": "Elided " + this.collapsedMessages + " passes or known failures."
});
}
this.collapsedMessages = 0;
},
/**
* Maybe logs a result, eliding up to MAX_COLLAPSED_MESSAGES consecutive
* passes.
@ -67,14 +89,7 @@ var W3CTest = {
if (success && ++this.collapsedMessages < this.MAX_COLLAPSED_MESSAGES) {
return;
}
if (this.collapsedMessages) {
this._log({
"result": true,
"todo": false,
"message": "Elided " + this.collapsedMessages + " passes or known failures."
});
}
this.collapsedMessages = 0;
this._logCollapsedMessages();
this._log(test);
},
@ -113,6 +128,9 @@ var W3CTest = {
"result": test.status === test.PASS,
"todo": this._todo(test)
});
if (this.dumpFailures && test.status !== test.PASS) {
this.failures[test.name] = true;
}
},
/**
@ -128,6 +146,13 @@ var W3CTest = {
url in this.expectedFailures &&
this.expectedFailures[url] === "error"
});
this._logCollapsedMessages();
if (this.dumpFailures) {
dump("@@@ @@@ Failures\n");
dump(url + "@@@" + JSON.stringify(this.failures) + "\n");
}
this.runner.testFinished(this.tests);
},
@ -148,6 +173,7 @@ var W3CTest = {
* from tests.
*/
"timeout": function() {
this.logFailure("Test runner timed us out.");
timeout();
}
};

View File

@ -1,6 +1,6 @@
DIRS += \
webapps/DOMCore/tests/approved \
webapps/DOMCore/tests/submissions/Opera \
webapps/XMLHttpRequest/tests/submissions/Ms2ger \
webapps/WebStorage/tests/submissions \
webapps/XMLHttpRequest/tests/submissions/Ms2ger \
$(NULL)

View File

@ -11,8 +11,9 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
_FILES = \
test_interfaces.html \
test_Range-cloneContents.html \
test_Range-cloneRange.html \
@ -29,11 +30,9 @@ MOCHITEST_FILES = \
test_Range-selectNode.html \
test_Range-set.html \
test_Range-surroundContents.html \
$(NULL)
MOCHITEST_FILES += \
common.js \
Range-test-iframe.html \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -11,8 +11,9 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
_FILES = \
test_getElementsByClassName-01.htm \
test_getElementsByClassName-02.htm \
test_getElementsByClassName-03.htm \
@ -33,7 +34,5 @@ MOCHITEST_FILES = \
test_getElementsByClassName-18.htm \
$(NULL)
MOCHITEST_FILES += \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -12,8 +12,9 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
_FILES = \
test_event_constructor.html \
test_event_local_key.html \
test_event_local_newvalue.html \
@ -42,7 +43,5 @@ MOCHITEST_FILES = \
test_storage_session_setitem.html \
$(NULL)
MOCHITEST_FILES += \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -11,11 +11,9 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
$(NULL)
MOCHITEST_FILES += \
_FILES = \
local_change_item_iframe.html \
local_security_iframe.html \
local_set_item_clear_iframe.html \
@ -25,4 +23,5 @@ MOCHITEST_FILES += \
session_set_item_iframe.html \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -11,8 +11,9 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
_FILES = \
test_event_constructor_js.html \
test_missing_arguments.html \
test_storage_local_clear_js.html \
@ -31,7 +32,5 @@ MOCHITEST_FILES = \
test_storage_session_setitem_js.html \
$(NULL)
MOCHITEST_FILES += \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -11,13 +11,12 @@ DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MOCHITEST_FILES = \
_FILES = \
test_interfaces.html \
test_setrequestheader-invalid-arguments.htm \
$(NULL)
MOCHITEST_FILES += \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -0,0 +1,49 @@
# 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/.
import string
makefileTemplate = """# THIS FILE IS AUTOGENERATED BY ${caller} - DO NOT EDIT
DEPTH = ${depth}
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = ${relativesrcdir}
DIRS = \\
${dirs}
include $$(DEPTH)/config/autoconf.mk
include $$(topsrcdir)/config/rules.mk
"""
filesTemplate = """
_FILES = \\
${files}
libs:: $$(_FILES)
\t$$(INSTALL) $$(foreach f,$$^,"$$f") $$(DEPTH)/_tests/testing/mochitest/tests/$$(relativesrcdir)
"""
def makefileString(entries):
if not len(entries):
return " $(NULL)"
return "\n".join([" %s \\" % (entry, ) for entry in entries]) + "\n $(NULL)"
def substMakefile(caller, path, subdirs, files):
result = string.Template(makefileTemplate).substitute({
"caller": caller,
"depth": "..%s" % ("/.." * path.count("/"), ),
"relativesrcdir": path,
"dirs": makefileString(subdirs)
})
if files:
result += string.Template(filesTemplate).substitute({
"files": makefileString(files)
})
return result

View File

@ -12,7 +12,7 @@
* http://www.w3.org/TR/DOM-Level-2-Traversal-Range/
*/
[scriptable, builtinclass, uuid(a059eea8-fece-4c14-93d3-7f50a944ae43)]
[scriptable, builtinclass, uuid(1f94055c-42e7-4a30-96a1-6a804f1c2d1e)]
interface nsIDOMRange : nsISupports
{
readonly attribute nsIDOMNode startContainer;
@ -65,6 +65,11 @@ interface nsIDOMRange : nsISupports
// Sort of a strcmp for ranges.
short comparePoint(in nsIDOMNode parent, in long offset);
/**
* Returns whether the range intersects node.
*/
boolean intersectsNode(in nsIDOMNode node);
// These methods come from
// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-range-interface
nsIDOMClientRectList getClientRects();

View File

@ -1,28 +1,25 @@
#
# 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/.
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/tests/browser
DEPTH := ../../..
topsrcdir := @top_srcdir@
srcdir := @srcdir@
VPATH := @srcdir@
relativesrcdir := dom/tests/browser
include $(DEPTH)/config/autoconf.mk
MOCHITEST_BROWSER_FILES := \
browser_focus_steal_from_chrome.js \
browser_focus_steal_from_chrome_during_mousedown.js \
browser_autofocus_background.js \
browser_ConsoleAPITests.js \
test-console-api.html \
browser_ConsoleStorageAPITests.js \
browser_ConsoleStoragePBTest.js \
browser_autofocus_preference.js \
browser_bug396843.js \
$(NULL)
include $(topsrcdir)/config/rules.mk
_BROWSER_FILES = \
browser_focus_steal_from_chrome.js \
browser_focus_steal_from_chrome_during_mousedown.js \
browser_autofocus_background.js \
browser_ConsoleAPITests.js \
test-console-api.html \
browser_ConsoleStorageAPITests.js \
browser_ConsoleStoragePBTest.js \
browser_autofocus_preference.js \
browser_bug396843.js \
$(NULL)
libs:: $(_BROWSER_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)

View File

@ -318,6 +318,44 @@ var WifiManager = (function() {
});
}
function getConnectionInfoGB(callback) {
var rval = {};
getRssiApproxCommand(function(rssi) {
rval.rssi = rssi;
getLinkSpeedCommand(function(linkspeed) {
rval.linkspeed = linkspeed;
callback(rval);
});
});
}
function getConnectionInfoICS(callback) {
doStringCommand("SIGNAL_POLL", function(reply) {
if (!reply) {
callback(null);
return;
}
let rval = {};
var lines = reply.split("\n");
for (let i = 0; i < lines.length; ++i) {
let [key, value] = lines[i].split("=");
switch (key.toUpperCase()) {
case "RSSI":
rval.rssi = value | 0;
break;
case "LINKSPEED":
rval.linkspeed = value | 0;
break;
default:
// Ignore.
}
}
callback(rval);
});
}
function getMacAddressCommand(callback) {
doStringCommand("DRIVER MACADDR", function(reply) {
if (reply)
@ -1096,6 +1134,9 @@ var WifiManager = (function() {
manager.getRssiApprox = getRssiApproxCommand;
manager.getLinkSpeed = getLinkSpeedCommand;
manager.getDhcpInfo = function() { return dhcpInfo; }
manager.getConnectionInfo = (sdkVersion >= 15)
? getConnectionInfoICS
: getConnectionInfoGB;
return manager;
})();
@ -1591,8 +1632,9 @@ WifiWorker.prototype = {
var self = this;
function getConnectionInformation() {
WifiManager.getRssiApprox(function(rssi) {
WifiManager.getConnectionInfo(function(info) {
// See comments in calculateSignal for information about this.
let { rssi, linkspeed } = info;
if (rssi > 0)
rssi -= 256;
if (rssi <= MIN_RSSI)
@ -1600,24 +1642,23 @@ WifiWorker.prototype = {
else if (rssi >= MAX_RSSI)
rssi = MAX_RSSI;
WifiManager.getLinkSpeed(function(linkspeed) {
let info = { signalStrength: rssi,
relSignalStrength: calculateSignal(rssi),
linkSpeed: linkspeed };
let last = self._lastConnectionInfo;
let info = { signalStrength: rssi,
relSignalStrength: calculateSignal(rssi),
linkSpeed: linkspeed };
let last = self._lastConnectionInfo;
// Only fire the event if the link speed changed or the signal
// strength changed by more than 10%.
function tensPlace(percent) ((percent / 10) | 0)
// Only fire the event if the link speed changed or the signal
// strength changed by more than 10%.
function tensPlace(percent) ((percent / 10) | 0)
if (last && last.linkSpeed === info.linkSpeed &&
tensPlace(last.relSignalStrength) === tensPlace(info.relSignalStrength)) {
return;
}
if (last && last.linkSpeed === info.linkSpeed &&
tensPlace(last.relSignalStrength) === tensPlace(info.relSignalStrength)) {
return;
}
self._lastConnectionInfo = info;
self._fireEvent("connectionInfoUpdate", info);
});
self._lastConnectionInfo = info;
debug("Firing connectionInfoUpdate: " + uneval(info));
self._fireEvent("connectionInfoUpdate", info);
});
}

View File

@ -6308,12 +6308,19 @@ JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback,
void *userRef, const unsigned errorNumber, ...)
{
va_list ap;
AssertHeapIsIdle(cx);
va_start(ap, errorNumber);
JS_ReportErrorNumberVA(cx, errorCallback, userRef, errorNumber, ap);
va_end(ap);
}
JS_PUBLIC_API(void)
JS_ReportErrorNumberVA(JSContext *cx, JSErrorCallback errorCallback,
void *userRef, const unsigned errorNumber,
va_list ap)
{
AssertHeapIsIdle(cx);
js_ReportErrorNumberVA(cx, JSREPORT_ERROR, errorCallback, userRef,
errorNumber, JS_TRUE, ap);
va_end(ap);
}
JS_PUBLIC_API(void)

View File

@ -5650,6 +5650,12 @@ extern JS_PUBLIC_API(void)
JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback,
void *userRef, const unsigned errorNumber, ...);
#ifdef va_start
extern JS_PUBLIC_API(void)
JS_ReportErrorNumberVA(JSContext *cx, JSErrorCallback errorCallback,
void *userRef, const unsigned errorNumber, va_list ap);
#endif
/*
* Use an errorNumber to retrieve the format string, args are jschar *
*/
@ -5700,6 +5706,7 @@ struct JSErrorReport {
unsigned errorNumber; /* the error number, e.g. see js.msg */
const jschar *ucmessage; /* the (default) error message */
const jschar **messageArgs; /* arguments for the error message */
int16_t exnType; /* One of the JSExnType constants */
};
/*

View File

@ -594,6 +594,8 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
else
efs = callback(userRef, NULL, errorNumber);
if (efs) {
reportp->exnType = efs->exnType;
size_t totalArgsLength = 0;
size_t argLengths[10]; /* only {0} thru {9} supported */
argCount = efs->argCount;

View File

@ -217,6 +217,7 @@ CopyErrorReport(JSContext *cx, JSErrorReport *report)
/* Copy non-pointer members. */
copy->lineno = report->lineno;
copy->errorNumber = report->errorNumber;
copy->exnType = report->exnType;
/* Note that this is before it gets flagged with JSREPORT_EXCEPTION */
copy->flags = report->flags;
@ -865,19 +866,18 @@ js_GetLocalizedErrorMessage(JSContext* cx, void *userRef, const char *locale,
namespace js {
JS_FRIEND_API(const jschar*)
GetErrorTypeNameFromNumber(JSContext* cx, const unsigned errorNumber)
GetErrorTypeName(JSContext* cx, int16_t exnType)
{
const JSErrorFormatString *efs = js_GetErrorMessage(NULL, NULL, errorNumber);
/*
* JSEXN_INTERNALERR returns null to prevent that "InternalError: "
* is prepended before "uncaught exception: "
*/
if (!efs || efs->exnType <= JSEXN_NONE || efs->exnType >= JSEXN_LIMIT ||
efs->exnType == JSEXN_INTERNALERR)
if (exnType <= JSEXN_NONE || exnType >= JSEXN_LIMIT ||
exnType == JSEXN_INTERNALERR)
{
return NULL;
}
JSProtoKey key = GetExceptionProtoKey(efs->exnType);
JSProtoKey key = GetExceptionProtoKey(exnType);
return cx->runtime->atomState.classAtoms[key]->chars();
}
@ -1109,6 +1109,7 @@ js_ReportUncaughtException(JSContext *cx)
PodZero(&report);
report.filename = filename.ptr();
report.lineno = (unsigned) lineno;
report.exnType = int16_t(JSEXN_NONE);
if (str) {
if (JSFixedString *fixed = str->ensureFixed(cx))
report.ucmessage = fixed->chars();

View File

@ -809,11 +809,11 @@ CastToJSFreeOp(FreeOp *fop)
/* Implemented in jsexn.cpp. */
/*
* Get an error type name from a number.
* If no exception is associated, return NULL.
* Get an error type name from a JSExnType constant.
* Returns NULL for invalid arguments and JSEXN_INTERNALERR
*/
extern JS_FRIEND_API(const jschar*)
GetErrorTypeNameFromNumber(JSContext* cx, const unsigned errorNumber);
GetErrorTypeName(JSContext* cx, int16_t exnType);
/* Implemented in jswrapper.cpp. */
typedef enum NukeReferencesToWindow {

View File

@ -15,15 +15,9 @@ PARALLEL_DIRS += \
chrome \
$(NULL)
# We can't use CPP_UNIT_TESTS for TestPoisonArea because libxpcom
# (which it does not need) isn't available at this point in the build.
BARE_UNIT_TESTS = \
TestPoisonArea.cpp \
$(NULL)
CPPSRCS += $(BARE_UNIT_TESTS)
SIMPLE_PROGRAMS += $(BARE_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
TOOL_DIRS := \
cpp-tests \
$(NULL)
MOCHITEST_FILES = \
border_radius_hit_testing_iframe.html \
@ -358,11 +352,3 @@ MOCHITEST_BROWSER_FILES = \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_LAYOUT
check::
@$(EXIT_ON_ERROR) \
for f in $(subst .cpp,$(BIN_SUFFIX),$(BARE_UNIT_TESTS)); do \
$(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
done

View File

@ -0,0 +1,16 @@
# 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/.
DEPTH := ../../../..
topsrcdir := @top_srcdir@
srcdir := @srcdir@
VPATH := @srcdir@
include $(DEPTH)/config/autoconf.mk
CPP_UNIT_TESTS := \
TestPoisonArea.cpp \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -1,3 +1,7 @@
# 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/.
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@

View File

@ -1,18 +1,23 @@
# 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/.
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = toolkit/components/osfile/tests/mochi
MODULE = osfile
MOCHITEST_CHROME_FILES = \
test_osfile_back.xul \
worker_test_osfile_unix.js \
worker_test_osfile_win.js \
test_osfile_front.xul \
worker_test_osfile_front.js \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
MODULE = osfile
MOCHITEST_CHROME_FILES := \
test_osfile_back.xul \
worker_test_osfile_unix.js \
worker_test_osfile_win.js \
test_osfile_front.xul \
worker_test_osfile_front.js \
$(NULL)
include $(topsrcdir)/config/rules.mk