Merge last green changeset of mozilla-inbound to mozilla-central

This commit is contained in:
Ed Morley 2011-12-09 11:12:51 +00:00
commit 2b74cc516b
237 changed files with 11499 additions and 1709 deletions

View File

@ -1066,7 +1066,6 @@ NS_IMETHODIMP nsAccessible::TakeSelection()
return NS_ERROR_FAILURE;
}
/* void takeFocus (); */
NS_IMETHODIMP
nsAccessible::TakeFocus()
{
@ -1078,30 +1077,16 @@ nsAccessible::TakeFocus()
nsIContent* focusContent = mContent;
// If the current element can't take real DOM focus and if it has an ID and
// an ancestor with an aria-activedescendant attribute present, then set DOM
// focus to that ancestor and set aria-activedescendant on the ancestor to
// the ID of the desired element.
// If the accessible focus is managed by container widget then focus the
// widget and set the accessible as its current item.
if (!frame->IsFocusable()) {
nsAutoString id;
if (nsCoreUtils::GetID(mContent, id)) {
nsIContent* ancestorContent = mContent;
while ((ancestorContent = ancestorContent->GetParent()) &&
!ancestorContent->HasAttr(kNameSpaceID_None,
nsGkAtoms::aria_activedescendant));
if (ancestorContent) {
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
if (presShell) {
nsIFrame *frame = ancestorContent->GetPrimaryFrame();
if (frame && frame->IsFocusable()) {
focusContent = ancestorContent;
focusContent->SetAttr(kNameSpaceID_None,
nsGkAtoms::aria_activedescendant,
id, true);
}
}
nsAccessible* widget = ContainerWidget();
if (widget && widget->AreItemsOperable()) {
nsIContent* widgetElm = widget->GetContent();
nsIFrame* widgetFrame = widgetElm->GetPrimaryFrame();
if (widgetFrame && widgetFrame->IsFocusable()) {
focusContent = widgetElm;
widget->SetCurrentItem(this);
}
}
}
@ -2937,6 +2922,18 @@ nsAccessible::CurrentItem()
return nsnull;
}
void
nsAccessible::SetCurrentItem(nsAccessible* aItem)
{
nsIAtom* id = aItem->GetContent()->GetID();
if (id) {
nsAutoString idStr;
id->ToString(idStr);
mContent->SetAttr(kNameSpaceID_None,
nsGkAtoms::aria_activedescendant, idStr, true);
}
}
nsAccessible*
nsAccessible::ContainerWidget() const
{

View File

@ -588,6 +588,11 @@ public:
*/
virtual nsAccessible* CurrentItem();
/**
* Set the current item of the widget.
*/
virtual void SetCurrentItem(nsAccessible* aItem);
/**
* Return container widget this accessible belongs to.
*/

View File

@ -151,6 +151,14 @@ nsHTMLSelectListAccessible::CurrentItem()
return nsnull;
}
void
nsHTMLSelectListAccessible::SetCurrentItem(nsAccessible* aItem)
{
aItem->GetContent()->SetAttr(kNameSpaceID_None,
nsGkAtoms::selected, NS_LITERAL_STRING("true"),
true);
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectListAccessible: nsAccessible protected
@ -686,6 +694,13 @@ nsHTMLComboboxAccessible::CurrentItem()
return AreItemsOperable() ? mListAccessible->CurrentItem() : nsnull;
}
void
nsHTMLComboboxAccessible::SetCurrentItem(nsAccessible* aItem)
{
if (AreItemsOperable())
mListAccessible->SetCurrentItem(aItem);
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLComboboxAccessible: protected

View File

@ -85,6 +85,7 @@ public:
virtual bool IsActiveWidget() const;
virtual bool AreItemsOperable() const;
virtual nsAccessible* CurrentItem();
virtual void SetCurrentItem(nsAccessible* aItem);
protected:
@ -209,6 +210,7 @@ public:
virtual bool IsActiveWidget() const;
virtual bool AreItemsOperable() const;
virtual nsAccessible* CurrentItem();
virtual void SetCurrentItem(nsAccessible* aItem);
protected:
// nsAccessible

View File

@ -46,16 +46,32 @@
@interface mozAccessible : NSObject <mozAccessible>
{
nsAccessibleWrap *mGeckoAccessible; // weak reference; it owns us.
NSMutableArray *mChildren; // strong ref to array of children
/**
* Weak reference; it owns us.
*/
nsAccessibleWrap* mGeckoAccessible;
// we can be marked as 'expired' if Shutdown() is called on our geckoAccessible.
// since we might still be retained by some third-party, we need to do cleanup
// in |expire|, and prevent any potential harm that could come from someone using us
// after this point.
/**
* Strong ref to array of children
*/
NSMutableArray* mChildren;
/**
* Weak reference to the parent
*/
mozAccessible* mParent;
/**
* We can be marked as 'expired' if Shutdown() is called on our geckoAccessible.
* since we might still be retained by some third-party, we need to do cleanup
* in |expire|, and prevent any potential harm that could come from someone using us
* after this point.
*/
BOOL mIsExpired;
// the nsIAccessible role of our gecko accessible.
/**
* The nsIAccessible role of our gecko accessible.
*/
PRUint32 mRole;
}
@ -114,6 +130,9 @@
// invalidates and removes all our children from our cached array.
- (void)invalidateChildren;
// invalidates the cached parent, used by invalidateChildren.
- (void)invalidateParent;
// makes ourselves "expired". after this point, we might be around if someone
// has retained us (e.g., a third-party), but we really contain no information.
- (void)expire;
@ -124,7 +143,7 @@
- (void)printHierarchyWithLevel:(unsigned)numSpaces;
- (void)sanityCheckChildren;
- (void)sanityCheckChildren:(NSArray *)theChildren;
- (void)sanityCheckChildren:(NSArray*)theChildren;
#endif
// ---- NSAccessibility methods ---- //

View File

@ -47,8 +47,10 @@
#include "nsObjCExceptions.h"
#include "nsIAccessible.h"
#include "nsIAccessibleRelation.h"
#include "nsIAccessibleText.h"
#include "nsIAccessibleEditableText.h"
#include "Relation.h"
#include "nsRootAccessible.h"
@ -246,16 +248,20 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
return [self window];
if ([attribute isEqualToString: (NSString*) kTopLevelUIElementAttribute])
return [self window];
if ([attribute isEqualToString:NSAccessibilityTitleAttribute] ||
[attribute isEqualToString:NSAccessibilityTitleUIElementAttribute])
if ([attribute isEqualToString:NSAccessibilityTitleAttribute])
return [self title];
if ([attribute isEqualToString:NSAccessibilityTitleUIElementAttribute]) {
Relation rel = mGeckoAccessible->RelationByType(nsIAccessibleRelation::RELATION_LABELLED_BY);
nsAccessible* tempAcc = rel.Next();
return tempAcc ? GetNativeFromGeckoAccessible(tempAcc) : nil;
}
if ([attribute isEqualToString:NSAccessibilityHelpAttribute])
return [self help];
#ifdef DEBUG
NSLog (@"!!! %@ can't respond to attribute %@", self, attribute);
#endif
return nil; // be nice and return empty string instead?
return nil;
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
@ -349,11 +355,15 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if (mParent)
return mParent;
nsCOMPtr<nsIAccessible> accessibleParent(mGeckoAccessible->GetUnignoredParent());
if (accessibleParent) {
id nativeParent = GetNativeFromGeckoAccessible(accessibleParent);
if (nativeParent)
return GetClosestInterestingAccessible(nativeParent);
if (nativeParent) {
return mParent = GetClosestInterestingAccessible(nativeParent);
}
}
// GetUnignoredParent() returns null when there is no unignored accessible all the way up to
@ -365,7 +375,8 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
id nativeParent = GetNativeFromGeckoAccessible(static_cast<nsIAccessible*>(root));
NSAssert1 (nativeParent, @"!!! we can't find a parent for %@", self);
return GetClosestInterestingAccessible(nativeParent);
mParent = GetClosestInterestingAccessible(nativeParent);
return mParent;
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
@ -604,6 +615,8 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
[mChildren makeObjectsPerformSelector:@selector(invalidateParent)];
// make room for new children
[mChildren release];
mChildren = nil;
@ -611,6 +624,11 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
NS_OBJC_END_TRY_ABORT_BLOCK;
}
- (void)invalidateParent
{
mParent = nil;
}
- (void)expire
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;

View File

@ -55,6 +55,44 @@ static id <mozAccessible, mozView> getNativeViewFromRootAccessible (nsAccessible
@implementation mozRootAccessible
- (NSArray*)accessibilityAttributeNames
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
// if we're expired, we don't support any attributes.
if (mIsExpired)
return [NSArray array];
// standard attributes that are shared and supported by root accessible (AXMain) elements.
static NSMutableArray* attributes = nil;
if (!attributes) {
attributes = [[super accessibilityAttributeNames] mutableCopy];
[attributes addObject:NSAccessibilityMainAttribute];
[attributes addObject:NSAccessibilityMinimizedAttribute];
}
return attributes;
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (id)accessibilityAttributeValue:(NSString *)attribute
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if ([attribute isEqualToString:NSAccessibilityMainAttribute]) {
return [NSNumber numberWithBool:[[self window] isMainWindow]];
}
if ([attribute isEqualToString:NSAccessibilityMinimizedAttribute]) {
return [NSNumber numberWithBool:[[self window] isMiniaturized]];
}
return [super accessibilityAttributeValue:attribute];
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
// return the AXParent that our parallell NSView tells us about.
- (id)parent
{

View File

@ -302,6 +302,22 @@ nsXULSelectableAccessible::CurrentItem()
return nsnull;
}
void
nsXULSelectableAccessible::SetCurrentItem(nsAccessible* aItem)
{
if (!mSelectControl)
return;
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
do_QueryInterface(aItem->GetContent());
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
do_QueryInterface(mSelectControl);
if (multiSelectControl)
multiSelectControl->SetCurrentItem(itemElm);
else
mSelectControl->SetSelectedItem(itemElm);
}
////////////////////////////////////////////////////////////////////////////////
// nsXULMenuitemAccessible
////////////////////////////////////////////////////////////////////////////////
@ -893,3 +909,9 @@ nsXULMenubarAccessible::CurrentItem()
}
return nsnull;
}
void
nsXULMenubarAccessible::SetCurrentItem(nsAccessible* aItem)
{
NS_ERROR("nsXULMenubarAccessible::SetCurrentItem not implemented");
}

View File

@ -67,6 +67,7 @@ public:
// Widgets
virtual nsAccessible* CurrentItem();
virtual void SetCurrentItem(nsAccessible* aItem);
protected:
// nsIDOMXULMultiSelectControlElement inherits from this, so we'll always have
@ -170,6 +171,7 @@ public:
virtual bool IsActiveWidget() const;
virtual bool AreItemsOperable() const;
virtual nsAccessible* CurrentItem();
virtual void SetCurrentItem(nsAccessible* aItem);
};
#endif

View File

@ -279,6 +279,12 @@ nsXULTreeAccessible::CurrentItem()
return nsnull;
}
void
nsXULTreeAccessible::SetCurrentItem(nsAccessible* aItem)
{
NS_ERROR("nsXULTreeAccessible::SetCurrentItem not implemented");
}
already_AddRefed<nsIArray>
nsXULTreeAccessible::SelectedItems()
{

View File

@ -106,6 +106,7 @@ public:
virtual bool IsActiveWidget() const;
virtual bool AreItemsOperable() const;
virtual nsAccessible* CurrentItem();
virtual void SetCurrentItem(nsAccessible* aItem);
virtual nsAccessible* ContainerWidget() const;

View File

@ -48,6 +48,7 @@ include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
test_focusedChild.html \
test_takeFocus.html \
test_takeFocus.xul \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -18,9 +18,7 @@
<script type="application/javascript">
////////////////////////////////////////////////////////////////////////////
// Test
var gQueue = null;
// Invokers
function takeFocusInvoker(aID)
{
@ -39,6 +37,12 @@
}
}
////////////////////////////////////////////////////////////////////////////
// Test
//gA11yEventDumpToConsole = true; // debug stuff
var gQueue = null;
function doTest()
{
gQueue = new eventQueue();
@ -49,6 +53,7 @@
gQueue.push(new takeFocusInvoker("item2"));
gQueue.push(new takeFocusInvoker("plugin"));
gQueue.push(new takeFocusInvoker(document));
gQueue.push(new takeFocusInvoker("lb_item2"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
@ -75,6 +80,11 @@
title="No focus event fired on document when focus is set to the document while focused in a plugin">
Mozilla Bug 646361
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=706067"
title="Make takeFocus work on widget items">
Mozilla Bug 706067
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -92,5 +102,10 @@
</div>
<embed id="plugin" type="application/x-test" width="200" height="200" wmode="window"></embed>
<select id="listbox" size="5">
<option id="lb_item1">item1</option>
<option id="lb_item2">item2</option>
</select>
</body>
</html>

View File

@ -0,0 +1,125 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/browser.css"
type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Accessible focus testing">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript"
src="../common.js" />
<script type="application/javascript"
src="../states.js" />
<script type="application/javascript"
src="../events.js" />
<script type="application/javascript"
src="../treeview.js" />
<script type="application/javascript">
<![CDATA[
////////////////////////////////////////////////////////////////////////////
// Invokers
function setTreeView(aTreeID, aView)
{
this.DOMNode = getNode(aTreeID);
this.eventSeq = [
new invokerChecker(EVENT_REORDER, this.DOMNode)
];
this.invoke = function setTreeView_invoke()
{
this.DOMNode.treeBoxObject.view = aView;
}
this.getID = function setTreeView_getID()
{ return "set tree view for " + prettyName(aTreeID); }
};
function takeFocusInvoker(aID, aArgConverterFunc)
{
this.targetFunc = aArgConverterFunc ? aArgConverterFunc : getAccessible;
this.eventSeq = [ new focusChecker(this.targetFunc, aID) ];
this.invoke = function takeFocusInvoker_invoke()
{
this.targetFunc.call(null, aID).takeFocus();
}
this.getID = function takeFocusInvoker_getID()
{
return "takeFocus for " + prettyName(aID);
}
}
function getLastChild(aID)
{
return getAccessible(aID).lastChild;
}
////////////////////////////////////////////////////////////////////////////
// Tests
//gA11yEventDumpID = "eventdump"; // debug stuff
//gA11yEventDumpToConsole = true; // debug stuff
var gQueue = null;
function doTests()
{
// Test focus events.
gQueue = new eventQueue();
gQueue.push(new setTreeView("tree", new nsTableTreeView(5)));
gQueue.push(new takeFocusInvoker("tree", getLastChild));
gQueue.push(new takeFocusInvoker("listitem2"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
]]>
</script>
<hbox flex="1" style="overflow: auto;">
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=706067"
title="Make takeFocus work on widget items">
Mozilla Bug 706067
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
</body>
<vbox flex="1">
<tree id="tree" flex="1">
<treecols>
<treecol id="col1" flex="1" primary="true" label="column"/>
<treecol id="col2" flex="1" label="column 2"/>
</treecols>
<treechildren id="treechildren"/>
</tree>
<listbox id="listbox">
<listitem id="listitem1">item1</listitem>
<listitem id="listitem2">item2</listitem>
</listbox>
<vbox id="eventdump"/>
</vbox>
</hbox>
</window>

View File

@ -97,6 +97,22 @@
// disabled, too. See bug 429285.
testAriaDisabledTree("group");
// aria-multiline
testStates("aria_multiline_textbox", 0, EXT_STATE_MULTI_LINE);
// aria-multiselectable
testStates("aria_multiselectable_listbox",
STATE_MULTISELECTABLE | STATE_EXTSELECTABLE);
// aria-pressed
testStates("aria_pressed_button", STATE_PRESSED | STATE_CHECKABLE);
// aria-readonly
testStates("aria_readonly_textbox", STATE_READONLY);
// aria-selectable
testStates("aria_selectable_listitem", STATE_SELECTABLE | STATE_SELECTED);
// active state caused by aria-activedescendant
testStates("as_item1", 0, EXT_STATE_ACTIVE);
testStates("as_item2", 0, 0, 0, EXT_STATE_ACTIVE);
@ -193,6 +209,11 @@
title="Expose active state on current item of selectable widgets">
Mozilla Bug 689847
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=457226"
title="Mochitests for ARIA states">
Mozilla Bug 457226
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -225,6 +246,13 @@
<div id="aria_mixed_checkbox" role="checkbox" aria-checked="mixed">
I might agree
</div>
<div id="aria_multiline_textbox" role="textbox" aria-multiline="true"></div>
<div id="aria_multiselectable_listbox" role="listbox" aria-multiselectable="true"></div>
<div id="aria_pressed_button" role="button" aria-pressed="true">Button</div>
<div id="aria_readonly_textbox" role="textbox" aria-readonly="true">This text should be readonly</div>
<div role="listbox">
<div id="aria_selectable_listitem" role="option" aria-selected="true">Item1</div>
</div>
<!-- Test that aria-disabled state gets propagated to all descendants -->
<div id="group" role="group" aria-disabled="true">

5211
b2g/chrome/content/httpd.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -39,22 +39,55 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
const CC = Components.Constructor;
Cu.import('resource://gre/modules/Services.jsm');
const LocalFile = CC('@mozilla.org/file/local;1',
'nsILocalFile',
'initWithPath');
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
XPCOMUtils.defineLazyGetter(Services, 'env', function() {
return Cc['@mozilla.org/process/environment;1']
.getService(Ci.nsIEnvironment);
});
XPCOMUtils.defineLazyGetter(Services, 'ss', function() {
return Cc['@mozilla.org/content/style-sheet-service;1']
.getService(Ci.nsIStyleSheetService);
});
XPCOMUtils.defineLazyGetter(Services, 'fm', function() {
return Cc['@mozilla.org/focus-manager;1']
.getService(Ci.nsIFocusManager);
});
// In order to use http:// scheme instead of file:// scheme
// (that is much more restricted) the following code kick-off
// a local http server listening on http://127.0.0.1:8888 and
// http://localhost:8888.
function startupHttpd(baseDir, port) {
const httpdURL = 'chrome://browser/content/httpd.js';
let httpd = {};
Services.scriptloader.loadSubScript(httpdURL, httpd);
let server = new httpd.nsHttpServer();
server.registerDirectory('/', new LocalFile(baseDir));
server.start(port);
}
// XXX until we have a security model, just let the pre-installed
// app used indexedDB.
function allowIndexedDB(url) {
let uri = Services.io.newURI(url, null, null);
Services.perms.add(uri, 'indexedDB', Ci.nsIPermissionManager.ALLOW_ACTION);
}
var shell = {
get home() {
delete this.home;
return this.home = document.getElementById('homescreen');
},
get homeSrc() {
get homeURL() {
try {
let homeSrc = Cc['@mozilla.org/process/environment;1']
.getService(Ci.nsIEnvironment)
.get('B2G_HOMESCREEN');
let homeSrc = Services.env.get('B2G_HOMESCREEN');
if (homeSrc)
return homeSrc;
} catch (e) {}
@ -73,16 +106,41 @@ var shell = {
},
start: function shell_init() {
let homeURL = this.homeURL;
if (!homeURL) {
let msg = 'Fatal error during startup: [No homescreen found]';
return alert(msg);
}
window.controllers.appendController(this);
window.addEventListener('keypress', this);
this.home.addEventListener('load', this, true);
let ioService = Cc['@mozilla.org/network/io-service;1']
.getService(Ci.nsIIOService2);
ioService.offline = false;
try {
Services.io.offline = false;
let fileScheme = 'file://';
if (homeURL.substring(0, fileScheme.length) == fileScheme) {
homeURL = homeURL.replace(fileScheme, '');
let baseDir = homeURL.split('/');
baseDir.pop();
baseDir = baseDir.join('/');
const SERVER_PORT = 8888;
startupHttpd(baseDir, SERVER_PORT);
let baseHost = 'http://localhost';
homeURL = homeURL.replace(baseDir, baseHost + ':' + SERVER_PORT);
}
allowIndexedDB(homeURL);
} catch (e) {
let msg = 'Fatal error during startup: [' + e + '[' + homeURL + ']';
return alert(msg);
}
let browser = this.home;
browser.homePage = this.homeSrc;
browser.homePage = homeURL;
browser.goHome();
},
@ -183,9 +241,7 @@ var shell = {
let shouldOpen = parseInt(data);
if (shouldOpen && !isKeyboardOpened) {
activeElement = Cc['@mozilla.org/focus-manager;1']
.getService(Ci.nsIFocusManager)
.focusedElement;
activeElement = Services.fm.focusedElement;
if (!activeElement)
return;
@ -198,7 +254,7 @@ var shell = {
}
};
Services.obs.addObserver(constructor, "ime-enabled-state-changed", false);
Services.obs.addObserver(constructor, 'ime-enabled-state-changed', false);
['ContentStart', 'keypress', 'mousedown'].forEach(function vkm_events(type) {
window.addEventListener(type, constructor, true);
});

View File

@ -151,18 +151,17 @@
// Mouse events has been cancelled so dispatch a sequence
// of events to where touchend has been fired
if (preventMouseEvents) {
let target = evt.target;
ignoreEvents = true;
try {
this.fireMouseEvent('mousemove', evt);
this.fireMouseEvent('mousedown', evt);
this.fireMouseEvent('mouseup', evt);
} catch (e) {
alert(e);
}
evt.preventDefault();
evt.stopPropagation();
ignoreEvents = false;
let target = evt.target;
ignoreEvents = true;
window.setTimeout(function dispatchMouseEvents(self) {
self.fireMouseEvent('mousemove', evt);
self.fireMouseEvent('mousedown', evt);
self.fireMouseEvent('mouseup', evt);
ignoreEvents = false;
}, 0, this);
}
debug('click: fire');

View File

@ -8,6 +8,7 @@ chrome.jar:
content/shell.js (content/shell.js)
content/touch.js (content/touch.js)
content/commandUtil.js (content/commandUtil.js)
content/httpd.js (content/httpd.js)
% override chrome://global/content/netError.xhtml chrome://browser/content/netError.xhtml
content/netError.xhtml (content/netError.xhtml)

View File

@ -391,6 +391,12 @@
@BINPATH@/components/messageWakeupService.manifest
@BINPATH@/components/nsFilePicker.js
@BINPATH@/components/nsFilePicker.manifest
#ifdef MOZ_B2G_RIL
@BINPATH@/components/nsTelephonyWorker.manifest
@BINPATH@/components/nsTelephonyWorker.js
@BINPATH@/components/Telephony.manifest
@BINPATH@/components/Telephony.js
#endif
#ifdef XP_MACOSX
@BINPATH@/components/libalerts_s.dylib
#endif

View File

@ -243,11 +243,6 @@ panel[noactions] > richlistbox > richlistitem[type~="action"] > .ac-url-box > .a
-moz-binding: url("chrome://browser/content/urlbarBindings.xml#urlbar-rich-result-popup");
}
#urlbar-throbber:not([busy="true"]),
#urlbar-throbber[busy="true"] + #page-proxy-favicon {
display: none;
}
#urlbar-container[combined] > #urlbar > #urlbar-icons > #go-button,
#urlbar[pageproxystate="invalid"] > #urlbar-icons > .urlbar-icon:not(#go-button),
#urlbar[pageproxystate="valid"] > #urlbar-icons > #go-button,

View File

@ -2601,28 +2601,6 @@ function UpdateUrlbarSearchSplitterState()
splitter.parentNode.removeChild(splitter);
}
var LocationBarHelpers = {
_timeoutID: null,
_searchBegin: function LocBar_searchBegin() {
function delayedBegin(self) {
self._timeoutID = null;
document.getElementById("urlbar-throbber").setAttribute("busy", "true");
}
this._timeoutID = setTimeout(delayedBegin, 500, this);
},
_searchComplete: function LocBar_searchComplete() {
// Did we finish the search before delayedBegin was invoked?
if (this._timeoutID) {
clearTimeout(this._timeoutID);
this._timeoutID = null;
}
document.getElementById("urlbar-throbber").removeAttribute("busy");
}
};
function UpdatePageProxyState()
{
if (gURLBar && gURLBar.value != gLastValidURLStr)

View File

@ -516,8 +516,6 @@
ontextentered="this.handleCommand(param);"
ontextreverted="return this.handleRevert();"
pageproxystate="invalid"
onsearchbegin="LocationBarHelpers._searchBegin();"
onsearchcomplete="LocationBarHelpers._searchComplete();"
onfocus="document.getElementById('identity-box').style.MozUserFocus= 'normal'"
onblur="setTimeout(function() document.getElementById('identity-box').style.MozUserFocus = '', 0);">
<box id="notification-popup-box" hidden="true" align="center">
@ -538,7 +536,6 @@
<hbox id="identity-box-inner" align="center">
<stack id="page-proxy-stack"
onclick="PageProxyClickHandler(event);">
<image id="urlbar-throbber" busy="false"/>
<image id="page-proxy-favicon" validate="never"
pageproxystate="invalid"
onerror="this.removeAttribute('src');"/>

View File

@ -1,3 +1,5 @@
. $topsrcdir/build/macosx/common
ac_add_options --enable-debug
ac_add_options --enable-trace-malloc
ac_add_options --enable-accessibility

View File

@ -1024,8 +1024,7 @@ toolbar[iconsize="small"] #feed-button {
}
/* Favicon */
#page-proxy-favicon,
#urlbar-throbber {
#page-proxy-favicon {
width: 16px;
height: 16px;
}
@ -1044,10 +1043,6 @@ toolbar[iconsize="small"] #feed-button {
opacity: 0.3;
}
#urlbar-throbber {
list-style-image: url("chrome://browser/skin/places/searching_16.png");
}
/* Identity indicator */
#identity-box {
background-image: -moz-linear-gradient(hsl(0,0%,98%), hsl(0,0%,92%));

View File

@ -57,7 +57,6 @@ browser.jar:
skin/classic/browser/places/organizer.css (places/organizer.css)
* skin/classic/browser/places/organizer.xml (places/organizer.xml)
skin/classic/browser/places/query.png (places/query.png)
skin/classic/browser/places/searching_16.png (places/searching_16.png)
skin/classic/browser/places/starPage.png (places/starPage.png)
skin/classic/browser/places/tag.png (places/tag.png)
skin/classic/browser/places/toolbarDropMarker.png (places/toolbarDropMarker.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -1106,8 +1106,7 @@ toolbar[mode="icons"] #zoom-in-button {
height: 22px;
}
#page-proxy-favicon,
#urlbar-throbber {
#page-proxy-favicon {
width: 16px;
height: 16px;
margin: 0px;
@ -1127,10 +1126,6 @@ toolbar[mode="icons"] #zoom-in-button {
opacity: 0.5;
}
#urlbar-throbber {
list-style-image: url("chrome://browser/skin/places/searching_16.png");
}
#wrapper-urlbar-container[place="palette"] {
max-width: 20em;
}

View File

@ -76,7 +76,6 @@ browser.jar:
skin/classic/browser/places/plus.png (places/plus.png)
skin/classic/browser/places/plus-active.png (places/plus-active.png)
skin/classic/browser/places/starPage.png (places/starPage.png)
skin/classic/browser/places/searching_16.png (places/searching_16.png)
skin/classic/browser/places/starred48.png (places/starred48.png)
skin/classic/browser/places/unstarred48.png (places/unstarred48.png)
skin/classic/browser/places/unfiledBookmarks.png (places/unfiledBookmarks.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -1489,8 +1489,7 @@ html|*.urlbar-input:-moz-lwtheme:-moz-placeholder,
/* page proxy icon */
#page-proxy-favicon,
#urlbar-throbber {
#page-proxy-favicon {
width: 16px;
height: 16px;
}
@ -1509,10 +1508,6 @@ html|*.urlbar-input:-moz-lwtheme:-moz-placeholder,
opacity: 0.5;
}
#urlbar-throbber {
list-style-image: url("chrome://browser/skin/places/searching_16.png");
}
/* autocomplete */
#treecolAutoCompleteImage {

View File

@ -75,7 +75,6 @@ browser.jar:
skin/classic/browser/places/history.png (places/history.png)
skin/classic/browser/places/allBookmarks.png (places/allBookmarks.png)
skin/classic/browser/places/unsortedBookmarks.png (places/unsortedBookmarks.png)
skin/classic/browser/places/searching_16.png (places/searching_16.png)
skin/classic/browser/places/downloads.png (places/downloads.png)
skin/classic/browser/preferences/alwaysAsk.png (preferences/alwaysAsk.png)
skin/classic/browser/preferences/application.png (preferences/application.png)
@ -231,7 +230,6 @@ browser.jar:
skin/classic/aero/browser/places/history.png (places/history-aero.png)
skin/classic/aero/browser/places/allBookmarks.png (places/allBookmarks-aero.png)
skin/classic/aero/browser/places/unsortedBookmarks.png (places/unsortedBookmarks-aero.png)
skin/classic/aero/browser/places/searching_16.png (places/searching_16.png)
skin/classic/aero/browser/places/downloads.png (places/downloads.png)
skin/classic/aero/browser/preferences/alwaysAsk.png (preferences/alwaysAsk-aero.png)
skin/classic/aero/browser/preferences/application.png (preferences/application-aero.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

2
build/macosx/common Normal file
View File

@ -0,0 +1,2 @@
CC=/usr/bin/gcc-4.2
CXX=/usr/bin/g++-4.2

View File

@ -1,10 +1,4 @@
if test -z "$CC" ; then
CC=gcc-4.2
fi
if test -z "$CXX" ; then
CXX=g++-4.2
fi
. $topsrcdir/build/macosx/common
# Mac builds don't nomally have to be handled as cross
# compilation, but some of the libraries on the bots

View File

@ -45,6 +45,8 @@ ac_add_app_options x86_64 --target=x86_64-apple-darwin10
ac_add_app_options i386 --with-macos-sdk=/Developer/SDKs/MacOSX10.5.sdk
ac_add_app_options x86_64 --with-macos-sdk=/Developer/SDKs/MacOSX10.6.sdk
. $topsrcdir/build/macosx/common
# $MOZ_BUILD_APP is only defined when sourced by configure. That's not a
# problem, because the variables it affects only need to be set for
# configure.
@ -52,14 +54,6 @@ if test -n "$MOZ_BUILD_APP" ; then
if test "$MOZ_BUILD_APP" = "i386" -o "$MOZ_BUILD_APP" = "x86_64"; then
TARGET_CPU=$MOZ_BUILD_APP
if test -z "$CC" ; then
CC=gcc-4.2
fi
if test -z "$CXX" ; then
CXX=g++-4.2
fi
# $HOST_CXX is presently unused. $HOST_CC will only be used during a cross
# compile.
HOST_CC=$CC

View File

@ -115,7 +115,7 @@ endif
####################################
# Sanity checks
ifneq (,$(filter MINGW%,$(shell uname -s)))
ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
# check for CRLF line endings
ifneq (0,$(shell $(PERL) -e 'binmode(STDIN); while (<STDIN>) { if (/\r/) { print "1"; exit } } print "0"' < $(TOPSRCDIR)/client.mk))
$(error This source tree appears to have Windows-style line endings. To \
@ -133,8 +133,6 @@ MOZCONFIG_LOADER := build/autoconf/mozconfig2client-mk
MOZCONFIG_FINDER := build/autoconf/mozconfig-find
MOZCONFIG_MODULES := build/unix/uniq.pl
run_for_side_effects := \
$(shell $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) $(TOPSRCDIR)/.mozconfig.mk > $(TOPSRCDIR)/.mozconfig.out)
@ -142,6 +140,13 @@ include $(TOPSRCDIR)/.mozconfig.mk
ifndef MOZ_OBJDIR
MOZ_OBJDIR = obj-$(CONFIG_GUESS)
else
# On Windows Pymake builds check MOZ_OBJDIR doesn't start with "/"
ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(MOZ_OBJDIR))))
$(error For Windows Pymake builds, MOZ_OBJDIR must be a Windows [and not MSYS] style path.)
endif
endif
endif
ifdef MOZ_BUILD_PROJECTS
@ -294,6 +299,10 @@ CONFIG_STATUS_DEPS := \
$(wildcard $(addsuffix confvars.sh,$(wildcard $(TOPSRCDIR)/*/))) \
$(NULL)
CONFIGURE_ENV_ARGS += \
MAKE="$(MAKE)" \
$(NULL)
# configure uses the program name to determine @srcdir@. Calling it without
# $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
# path of $(TOPSRCDIR).

View File

@ -64,6 +64,8 @@ ifdef SDK_HEADERS
EXPORTS += $(SDK_HEADERS)
endif
REPORT_BUILD = @echo $(notdir $<)
ifeq ($(OS_ARCH),OS2)
EXEC =
else
@ -1148,25 +1150,32 @@ endif # MOZ_AUTO_DEPS
# Rules for building native targets must come first because of the host_ prefix
host_%.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
host_%.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
host_%.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
host_%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
host_%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
%:: %.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTOPTION)$@ $(_VPATH_SRCS)
%.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(_VPATH_SRCS)
@ -1177,6 +1186,7 @@ moc_%.cpp: %.h $(GLOBAL_DEPS)
$(MOC) $(DEFINES) $(ACDEFINES) $< $(OUTOPTION)$@
moc_%.cc: %.cc $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $(_VPATH_SRCS:.cc=.h) $(OUTOPTION)$@
ifdef ASFILES
@ -1197,10 +1207,12 @@ endif
# Please keep the next two rules in sync.
#
%.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
%.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
ifdef STRICT_CPLUSPLUS_SUFFIX
echo "#line 1 \"$*.cpp\"" | cat - $*.cpp > t_$*.cc
@ -1211,10 +1223,12 @@ else
endif #STRICT_CPLUSPLUS_SUFFIX
$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
$(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS)
$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $(_VPATH_SRCS)
@ -1464,6 +1478,7 @@ XPIDL_DEPS = \
$(NULL)
$(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_DEPS) $(XPIDL_GEN_DIR)/.done
$(REPORT_BUILD)
$(PYTHON_PATH) \
-I$(topsrcdir)/other-licenses/ply \
-I$(topsrcdir)/xpcom/idl-parser \
@ -1475,6 +1490,7 @@ ifndef NO_GEN_XPT
# generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
# into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
$(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_DEPS) $(XPIDL_GEN_DIR)/.done
$(REPORT_BUILD)
$(PYTHON_PATH) \
-I$(topsrcdir)/other-licenses/ply \
-I$(topsrcdir)/xpcom/idl-parser \
@ -1763,12 +1779,15 @@ define MAKE_DEPS_NOAUTO
endef
$(MDDEPDIR)/%.pp: %.c
$(REPORT_BUILD)
@$(MAKE_DEPS_NOAUTO)
$(MDDEPDIR)/%.pp: %.cpp
$(REPORT_BUILD)
@$(MAKE_DEPS_NOAUTO)
$(MDDEPDIR)/%.pp: %.s
$(REPORT_BUILD)
@$(MAKE_DEPS_NOAUTO)
ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))

View File

@ -2251,6 +2251,17 @@ if test "$_python_res" != 0; then
fi
AC_MSG_RESULT([yes])
dnl Check for using a custom <stdint.h> implementation
dnl ========================================================
AC_MSG_CHECKING(for custom <stdint.h> implementation)
if test "$MOZ_CUSTOM_STDINT_H"; then
AC_DEFINE_UNQUOTED(MOZ_CUSTOM_STDINT_H, "$MOZ_CUSTOM_STDINT_H")
AC_SUBST(MOZ_CUSTOM_STDINT_H)
AC_MSG_RESULT(using $MOZ_CUSTOM_STDINT_H)
else
AC_MSG_RESULT(none specified)
fi
dnl Get mozilla version from central milestone file
MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
@ -3017,47 +3028,8 @@ else
AC_MSG_RESULT(no)
fi
dnl Check for int16_t, int32_t, int64_t, int64, uint, uint_t, and uint16_t.
dnl Check for int64, uint, and uint_t.
dnl ========================================================
AC_MSG_CHECKING(for int16_t)
AC_CACHE_VAL(ac_cv_int16_t,
[AC_TRY_COMPILE([#include <stdio.h>
#include <sys/types.h>],
[int16_t foo = 0;],
[ac_cv_int16_t=true],
[ac_cv_int16_t=false])])
if test "$ac_cv_int16_t" = true ; then
AC_DEFINE(HAVE_INT16_T)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(for int32_t)
AC_CACHE_VAL(ac_cv_int32_t,
[AC_TRY_COMPILE([#include <stdio.h>
#include <sys/types.h>],
[int32_t foo = 0;],
[ac_cv_int32_t=true],
[ac_cv_int32_t=false])])
if test "$ac_cv_int32_t" = true ; then
AC_DEFINE(HAVE_INT32_T)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(for int64_t)
AC_CACHE_VAL(ac_cv_int64_t,
[AC_TRY_COMPILE([#include <stdio.h>
#include <sys/types.h>],
[int64_t foo = 0;],
[ac_cv_int64_t=true],
[ac_cv_int64_t=false])])
if test "$ac_cv_int64_t" = true ; then
AC_DEFINE(HAVE_INT64_T)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(for int64)
AC_CACHE_VAL(ac_cv_int64,
[AC_TRY_COMPILE([#include <stdio.h>
@ -3097,19 +3069,6 @@ if test "$ac_cv_uint_t" = true ; then
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(for uint16_t)
AC_CACHE_VAL(ac_cv_uint16_t,
[AC_TRY_COMPILE([#include <stdio.h>
#include <sys/types.h>],
[uint16_t foo = 0;],
[ac_cv_uint16_t=true],
[ac_cv_uint16_t=false])])
if test "$ac_cv_uint16_t" = true ; then
AC_DEFINE(HAVE_UINT16_T)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
dnl are defined when compiling C++ but not C. Since the result of this
@ -7751,7 +7710,7 @@ dnl ========================================================
AC_MSG_CHECKING([for gcc -pipe support])
if test -n "$GNU_CC" -a -n "$GNU_CXX" -a -n "$GNU_AS"; then
echo '#include <stdio.h>' > dummy-hello.c
echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c
echo 'int main() { printf("Hello World"); exit(0); }' >> dummy-hello.c
${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
cat dummy-hello.s 2> /dev/null | ${AS_BIN} -o dummy-hello.S - 2>&5
if test $? = 0; then

View File

@ -297,7 +297,6 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
// The redirecting channel isn't a writable property bag, we won't be able
// to enforce the load policy if it redirects again, so we stop it now.
nsXPIDLString message;
nsCAutoString newUriSpec;
newUri->GetSpec(newUriSpec);
const PRUnichar *formatParams[] = { NS_ConvertUTF8toUTF16(newUriSpec).get() };

View File

@ -350,6 +350,7 @@ GK_ATOM(empty, "empty")
GK_ATOM(encoding, "encoding")
GK_ATOM(enctype, "enctype")
GK_ATOM(end, "end")
GK_ATOM(endEvent, "endEvent")
GK_ATOM(end_after, "end_after")
GK_ATOM(end_before, "end_before")
GK_ATOM(equalsize, "equalsize")
@ -1370,6 +1371,7 @@ GK_ATOM(attributeName, "attributeName")
GK_ATOM(attributeType, "attributeType")
GK_ATOM(auto_reverse, "auto-reverse")
GK_ATOM(begin, "begin")
GK_ATOM(beginEvent, "beginEvent")
GK_ATOM(by, "by")
GK_ATOM(calcMode, "calcMode")
GK_ATOM(css, "CSS")

View File

@ -701,6 +701,25 @@ nsXMLHttpRequest::GetChannel(nsIChannel **aChannel)
return NS_OK;
}
static void LogMessage(const char* aWarning, nsPIDOMWindow* aWindow)
{
nsCOMPtr<nsIDocument> doc;
if (aWindow) {
doc = do_QueryInterface(aWindow->GetExtantDocument());
}
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
aWarning,
nsnull,
0,
nsnull, // Response URL not kept around
EmptyString(),
0,
0,
nsIScriptError::warningFlag,
"DOM",
doc);
}
/* readonly attribute nsIDOMDocument responseXML; */
NS_IMETHODIMP
nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
@ -717,31 +736,11 @@ nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
}
if (mWarnAboutMultipartHtml) {
mWarnAboutMultipartHtml = false;
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
"HTMLMultipartXHRWarning",
nsnull,
0,
nsnull, // Response URL not kept around
EmptyString(),
0,
0,
nsIScriptError::warningFlag,
"DOM",
mOwner->WindowID());
LogMessage("HTMLMultipartXHRWarning", mOwner);
}
if (mWarnAboutSyncHtml) {
mWarnAboutSyncHtml = false;
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
"HTMLSyncXHRWarning",
nsnull,
0,
nsnull, // Response URL not kept around
EmptyString(),
0,
0,
nsIScriptError::warningFlag,
"DOM",
mOwner->WindowID());
LogMessage("HTMLSyncXHRWarning", mOwner);
}
return NS_OK;
}
@ -784,6 +783,13 @@ nsXMLHttpRequest::DetectCharset()
mResponseCharset.AssignLiteral("UTF-8");
}
if (mResponseType == XML_HTTP_RESPONSE_TYPE_JSON &&
!mResponseCharset.EqualsLiteral("UTF-8")) {
// The XHR spec says only UTF-8 is supported for responseType == "json"
LogMessage("JSONCharsetWarning", mOwner);
mResponseCharset.AssignLiteral("UTF-8");
}
nsCOMPtr<nsICharsetConverterManager> ccm =
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
@ -921,7 +927,7 @@ nsXMLHttpRequest::CreateResponseParsedJSON(JSContext* aCx)
if (!aCx) {
return NS_ERROR_FAILURE;
}
// The Unicode converter has already zapped the BOM if there was one
if (!JS_ParseJSON(aCx,
(jschar*)mResponseText.get(),
mResponseText.Length(), &mResultJSON)) {
@ -974,7 +980,7 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponseType(nsAString& aResponseType)
aResponseType.AssignLiteral("text");
break;
case XML_HTTP_RESPONSE_TYPE_JSON:
aResponseType.AssignLiteral("moz-json");
aResponseType.AssignLiteral("json");
break;
case XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT:
aResponseType.AssignLiteral("moz-chunked-text");
@ -998,6 +1004,13 @@ NS_IMETHODIMP nsXMLHttpRequest::SetResponseType(const nsAString& aResponseType)
XML_HTTP_REQUEST_HEADERS_RECEIVED)))
return NS_ERROR_DOM_INVALID_STATE_ERR;
// sync request is not allowed setting responseType in window context
if (mOwner &&
!(mState & (XML_HTTP_REQUEST_UNSENT | XML_HTTP_REQUEST_ASYNC))) {
LogMessage("ResponseTypeSyncXHRWarning", mOwner);
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
}
// Set the responseType attribute's value to the given value.
if (aResponseType.IsEmpty()) {
mResponseType = XML_HTTP_RESPONSE_TYPE_DEFAULT;
@ -1009,7 +1022,7 @@ NS_IMETHODIMP nsXMLHttpRequest::SetResponseType(const nsAString& aResponseType)
mResponseType = XML_HTTP_RESPONSE_TYPE_DOCUMENT;
} else if (aResponseType.EqualsLiteral("text")) {
mResponseType = XML_HTTP_RESPONSE_TYPE_TEXT;
} else if (aResponseType.EqualsLiteral("moz-json")) {
} else if (aResponseType.EqualsLiteral("json")) {
mResponseType = XML_HTTP_RESPONSE_TYPE_JSON;
} else if (aResponseType.EqualsLiteral("moz-chunked-text")) {
if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
@ -1098,9 +1111,15 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponse(JSContext *aCx, jsval *aResult)
if (mState & XML_HTTP_REQUEST_DONE) {
if (mResultJSON == JSVAL_VOID) {
rv = CreateResponseParsedJSON(aCx);
NS_ENSURE_SUCCESS(rv, rv);
mResponseText.Truncate();
if (NS_FAILED(rv)) {
// Per spec, errors aren't propagated. null is returned instead.
rv = NS_OK;
// It would be nice to log the error to the console. That's hard to
// do without calling window.onerror as a side effect, though.
JS_ClearPendingException(aCx);
mResultJSON = JSVAL_NULL;
}
}
*aResult = mResultJSON;
} else {
@ -1519,6 +1538,20 @@ nsXMLHttpRequest::Open(const nsACString& method, const nsACString& url,
return NS_ERROR_INVALID_ARG;
}
// sync request is not allowed using withCredential or responseType
// in window context
if (!async && mOwner &&
(mState & XML_HTTP_REQUEST_AC_WITH_CREDENTIALS ||
mResponseType != XML_HTTP_RESPONSE_TYPE_DEFAULT)) {
if (mState & XML_HTTP_REQUEST_AC_WITH_CREDENTIALS) {
LogMessage("WithCredentialsSyncXHRWarning", mOwner);
}
if (mResponseType != XML_HTTP_RESPONSE_TYPE_DEFAULT) {
LogMessage("ResponseTypeSyncXHRWarning", mOwner);
}
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
}
nsresult rv;
nsCOMPtr<nsIURI> uri;
bool authp = false;
@ -2920,7 +2953,14 @@ nsXMLHttpRequest::SetWithCredentials(bool aWithCredentials)
if (XML_HTTP_REQUEST_SENT & mState) {
return NS_ERROR_FAILURE;
}
// sync request is not allowed setting withCredentials in window context
if (mOwner &&
!(mState & (XML_HTTP_REQUEST_UNSENT | XML_HTTP_REQUEST_ASYNC))) {
LogMessage("WithCredentialsSyncXHRWarning", mOwner);
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
}
if (aWithCredentials) {
mState |= XML_HTTP_REQUEST_AC_WITH_CREDENTIALS;
}

View File

@ -533,6 +533,10 @@ _TEST_FILES2 = \
test_bug702439.html \
test_bug702439.html^headers^ \
file_bug702439.html \
test_bug707142.html \
file_bug707142_baseline.json \
file_bug707142_bom.json \
file_bug707142_utf-16.json \
$(NULL)
_CHROME_FILES = \

View File

@ -0,0 +1 @@
{"foo": "bar"}

View File

@ -0,0 +1 @@
{"foo": "bar"}

Binary file not shown.

View File

@ -5,15 +5,20 @@
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<body onload="gen.next();">
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<script class="testbody" type="application/javascript;version=1.7">
SimpleTest.waitForExplicitFinish();
var gen = runTests();
function continueTest() { gen.next(); }
function runTests() {
var path = "/tests/content/base/test/";
var passFiles = [['file_XHR_pass1.xml', 'GET'],
@ -63,7 +68,6 @@ for (i = 0; i < failFiles.length; ++i) {
}
}
// test response (responseType='document')
function checkResponseTextAccessThrows(xhr) {
var didthrow = false;
try { xhr.responseText } catch (e) { didthrow = true; }
@ -74,26 +78,42 @@ function checkResponseXMLAccessThrows(xhr) {
try { xhr.responseXML } catch (e) { didthrow = true; }
ok(didthrow, "should have thrown when accessing responseXML");
}
function checkResponseAccessThrows(xhr) {
var didthrow = false;
try { xhr.response } catch (e) { didthrow = true; }
ok(didthrow, "should have thrown when accessing response");
}
function checkSetResponseTypeThrows(xhr, type) {
var didthrow = false;
try { xhr.responseType = type; } catch (e) { didthrow = true; }
ok(didthrow, "should have thrown when setting responseType");
}
function checkOpenThrows(xhr, method, url, async) {
var didthrow = false;
try { xhr.open(method, url, async); } catch (e) { didthrow = true; }
ok(didthrow, "should have thrown when open is called");
}
// test response (sync, responseType is not changeable)
xhr = new XMLHttpRequest();
xhr.open("GET", 'file_XHR_pass2.txt', false);
checkSetResponseTypeThrows(xhr, "");
checkSetResponseTypeThrows(xhr, "text");
checkSetResponseTypeThrows(xhr, "document");
xhr.open("GET", 'file_XHR_pass1.xml', false);
checkSetResponseTypeThrows(xhr, "arraybuffer");
checkSetResponseTypeThrows(xhr, "blob");
checkSetResponseTypeThrows(xhr, "json");
checkSetResponseTypeThrows(xhr, "moz-chunked-text");
checkSetResponseTypeThrows(xhr, "moz-chunked-arraybuffer");
xhr.responseType = 'document';
xhr.send(null);
checkSetResponseTypeThrows(xhr, "document");
is(xhr.status, 200, "wrong status");
is(xhr.response, "hello pass\n", "wrong response");
// test response (responseType='document')
xhr = new XMLHttpRequest();
xhr.open("GET", 'file_XHR_pass1.xml');
xhr.responseType = 'document';
xhr.onloadend = continueTest;
xhr.send(null);
yield;
checkSetResponseTypeThrows(xhr, "document");
is(xhr.status, 200, "wrong status");
checkResponseTextAccessThrows(xhr);
is((new XMLSerializer()).serializeToString(xhr.response.documentElement),
"<res>hello</res>",
@ -101,9 +121,11 @@ is((new XMLSerializer()).serializeToString(xhr.response.documentElement),
// test response (responseType='text')
xhr = new XMLHttpRequest();
xhr.open("GET", 'file_XHR_pass2.txt', false);
xhr.open("GET", 'file_XHR_pass2.txt');
xhr.responseType = 'text';
xhr.onloadend = continueTest;
xhr.send(null);
yield;
is(xhr.status, 200, "wrong status");
checkResponseXMLAccessThrows(xhr);
is(xhr.response, "hello pass\n", "wrong response");
@ -118,9 +140,11 @@ function arraybuffer_equals_to(ab, s) {
// with a simple text file
xhr = new XMLHttpRequest();
xhr.open("GET", 'file_XHR_pass2.txt', false);
xhr.open("GET", 'file_XHR_pass2.txt');
xhr.responseType = 'arraybuffer';
xhr.onloadend = continueTest;
xhr.send(null);
yield;
is(xhr.status, 200, "wrong status");
checkResponseTextAccessThrows(xhr);
checkResponseXMLAccessThrows(xhr);
@ -129,9 +153,11 @@ ok(ab != null, "should have a non-null arraybuffer");
arraybuffer_equals_to(ab, "hello pass\n");
// test reusing the same XHR (Bug 680816)
xhr.open("GET", 'file_XHR_binary1.bin', false);
xhr.open("GET", 'file_XHR_binary1.bin');
xhr.responseType = 'arraybuffer';
xhr.onloadend = continueTest;
xhr.send(null);
yield;
is(xhr.status, 200, "wrong status");
ab2 = xhr.response;
ok(ab2 != null, "should have a non-null arraybuffer");
@ -141,9 +167,11 @@ arraybuffer_equals_to(ab2, "\xaa\xee\0\x03\xff\xff\xff\xff\xbb\xbb\xbb\xbb");
// with a binary file
xhr = new XMLHttpRequest();
xhr.open("GET", 'file_XHR_binary1.bin', false);
xhr.open("GET", 'file_XHR_binary1.bin');
xhr.responseType = 'arraybuffer';
xhr.send(null)
xhr.onloadend = continueTest;
xhr.send(null);
yield;
is(xhr.status, 200, "wrong status");
checkResponseTextAccessThrows(xhr);
checkResponseXMLAccessThrows(xhr);
@ -152,12 +180,14 @@ ok(ab != null, "should have a non-null arraybuffer");
arraybuffer_equals_to(ab, "\xaa\xee\0\x03\xff\xff\xff\xff\xbb\xbb\xbb\xbb");
is(xhr.response, xhr.response, "returns the same ArrayBuffer");
// test response (responseType='moz-json')
// test response (responseType='json')
var xhr = new XMLHttpRequest();
xhr.open("POST", 'responseIdentical.sjs', false);
xhr.responseType = 'moz-json';
xhr.open("POST", 'responseIdentical.sjs');
xhr.responseType = 'json';
jsonObjStr = JSON.stringify({title: "aBook", author: "john"});
xhr.onloadend = continueTest;
xhr.send(jsonObjStr);
yield;
is(xhr.status, 200, "wrong status");
checkResponseTextAccessThrows(xhr);
checkResponseXMLAccessThrows(xhr);
@ -166,14 +196,16 @@ is(xhr.response, xhr.response, "returning the same object on each access");
// with invalid json
var xhr = new XMLHttpRequest();
xhr.open("POST", 'responseIdentical.sjs', false);
xhr.responseType = 'moz-json';
xhr.open("POST", 'responseIdentical.sjs');
xhr.responseType = 'json';
xhr.onloadend = continueTest;
xhr.send("{");
yield;
is(xhr.status, 200, "wrong status");
checkResponseTextAccessThrows(xhr);
checkResponseXMLAccessThrows(xhr);
checkResponseAccessThrows(xhr);
checkResponseAccessThrows(xhr); // Check twice to ensure that we still throw
is(xhr.response, null, "Bad JSON should result in null response.");
is(xhr.response, null, "Bad JSON should result in null response even 2nd time.");
// test response (responseType='blob')
var onloadCount = 0;
@ -183,9 +215,11 @@ function checkOnloadCount() {
// with a simple text file
xhr = new XMLHttpRequest();
xhr.open("GET", 'file_XHR_pass2.txt', false);
xhr.open("GET", 'file_XHR_pass2.txt');
xhr.responseType = 'blob';
xhr.onloadend = continueTest;
xhr.send(null);
yield;
is(xhr.status, 200, "wrong status");
checkResponseTextAccessThrows(xhr);
checkResponseXMLAccessThrows(xhr);
@ -281,6 +315,8 @@ client.open("GET", "file_XHR_pass1.xml", true);
client.send();
client.abort();
yield;
} /* runTests */
</script>
</pre>
</body>

View File

@ -8,7 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=464848
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<body onload="gen.next();">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=464848">Mozilla Bug 464848</a>
<p id="display">
@ -19,6 +19,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=464848
</div>
<pre id="test">
<script class="testbody" type="application/javascript;version=1.8">
SimpleTest.waitForExplicitFinish();
var gen = runTests();
function continueTest() { gen.next(); }
function runTests() {
xhr = new XMLHttpRequest();
xhr.open("GET", "file_XHRSendData_doc.xml", false);
@ -176,12 +182,16 @@ for (var i = 0; i < testDOMFiles.length; i++) {
try {
for each(test in tests) {
xhr = new XMLHttpRequest;
xhr.open("POST", "file_XHRSendData.sjs", false);
xhr.open("POST", "file_XHRSendData.sjs", !!test.resType);
if (test.contentType)
xhr.setRequestHeader("Content-Type", test.contentType);
if (test.resType)
if (test.resType) {
xhr.responseType = test.resType;
xhr.onloadend = continueTest;
}
xhr.send(test.body);
if (test.resType)
yield;
if (test.resContentType) {
is(xhr.getResponseHeader("Result-Content-Type"), test.resContentType,
@ -234,6 +244,10 @@ function is_identical_arraybuffer(ab1, ab2) {
String.fromCharCode.apply(String, u8v2), "arraybuffer values not equal");
}
SimpleTest.finish();
yield;
} /* runTests */
</script>
</pre>
</body>

View File

@ -424,51 +424,55 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
var xhr = SpecialPowers.createSystemXHR();
xhr.withCredentials = true;
// also, test mixed mode UI
xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", false, "user 1", "password 1");
xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", true, "user 1", "password 1");
xhr.send();
ok(xhr.status == 200, "Failed to set credentials in test 5.c");
xhr.onloadend = function() {
ok(xhr.status == 200, "Failed to set credentials in test 5.c");
gEventSourceObj5_c = new EventSource("https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_evtsrc",
{ withCredentials: true } );
ok(gEventSourceObj5_c.withCredentials, "Wrong withCredentials in test 5.c");
gEventSourceObj5_c = new EventSource("https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_evtsrc",
{ withCredentials: true } );
ok(gEventSourceObj5_c.withCredentials, "Wrong withCredentials in test 5.c");
gEventSourceObj5_c.onmessage = function(e) {
ok(e.origin == "https://example.com", "Wrong Origin in test 5.c");
fn_onmessage(e);
gEventSourceObj5_c.onmessage = function(e) {
ok(e.origin == "https://example.com", "Wrong Origin in test 5.c");
fn_onmessage(e);
};
gEventSourceObj5_c.hits = [];
gEventSourceObj5_c.hits['fn_onmessage'] = 0;
setTimeout(function() {
ok(gEventSourceObj5_c.hits['fn_onmessage'] > 0, "Test 5.c failed");
gEventSourceObj5_c.close();
doTest5_d(test_id);
}, parseInt(3000*stress_factor));
};
gEventSourceObj5_c.hits = [];
gEventSourceObj5_c.hits['fn_onmessage'] = 0;
setTimeout(function() {
ok(gEventSourceObj5_c.hits['fn_onmessage'] > 0, "Test 5.c failed");
gEventSourceObj5_c.close();
doTest5_d(test_id);
}, parseInt(3000*stress_factor));
}
function doTest5_d(test_id)
{
var xhr = SpecialPowers.createSystemXHR();
xhr.withCredentials = true;
xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", false, "user 2", "password 2");
xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", true, "user 2", "password 2");
xhr.send();
ok(xhr.status == 200, "Failed to set credentials in test 5.d");
gEventSourceObj5_d = new EventSource("https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc");
ok(!gEventSourceObj5_d.withCredentials, "Wrong withCredentials in test 5.d");
gEventSourceObj5_d.onmessage = function(e) {
ok(e.origin == "https://example.com", "Wrong Origin in test 5.d");
fn_onmessage(e);
xhr.onloadend = function() {
ok(xhr.status == 200, "Failed to set credentials in test 5.d");
gEventSourceObj5_d = new EventSource("https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc");
ok(!gEventSourceObj5_d.withCredentials, "Wrong withCredentials in test 5.d");
gEventSourceObj5_d.onmessage = function(e) {
ok(e.origin == "https://example.com", "Wrong Origin in test 5.d");
fn_onmessage(e);
};
gEventSourceObj5_d.hits = [];
gEventSourceObj5_d.hits['fn_onmessage'] = 0;
setTimeout(function() {
ok(gEventSourceObj5_d.hits['fn_onmessage'] == 0, "Test 5.d failed");
gEventSourceObj5_d.close();
setTestHasFinished(test_id);
}, parseInt(3000*stress_factor));
};
gEventSourceObj5_d.hits = [];
gEventSourceObj5_d.hits['fn_onmessage'] = 0;
setTimeout(function() {
ok(gEventSourceObj5_d.hits['fn_onmessage'] == 0, "Test 5.d failed");
gEventSourceObj5_d.close();
setTestHasFinished(test_id);
}, parseInt(3000*stress_factor));
}
function doTest5_e(test_id)
@ -476,52 +480,56 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
// credentials using the auth cache and cookies
var xhr = SpecialPowers.createSystemXHR();
xhr.withCredentials = true;
xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", false, "user 1", "password 1");
xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", true, "user 1", "password 1");
xhr.send();
ok(xhr.status == 200, "Failed to set credentials in test 5.e");
xhr.onloadend = function() {
ok(xhr.status == 200, "Failed to set credentials in test 5.e");
gEventSourceObj5_e = new EventSource("http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_evtsrc",
{ get withCredentials() { return true; } } );
ok(gEventSourceObj5_e.withCredentials, "Wrong withCredentials in test 5.e");
gEventSourceObj5_e = new EventSource("http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_evtsrc",
{ get withCredentials() { return true; } } );
ok(gEventSourceObj5_e.withCredentials, "Wrong withCredentials in test 5.e");
gEventSourceObj5_e.onmessage = function(e) {
ok(e.origin == "http://example.org", "Wrong Origin in test 5.e");
fn_onmessage(e);
gEventSourceObj5_e.onmessage = function(e) {
ok(e.origin == "http://example.org", "Wrong Origin in test 5.e");
fn_onmessage(e);
};
gEventSourceObj5_e.hits = [];
gEventSourceObj5_e.hits['fn_onmessage'] = 0;
setTimeout(function() {
ok(gEventSourceObj5_e.hits['fn_onmessage'] > 0, "Test 5.e failed");
gEventSourceObj5_e.close();
doTest5_f(test_id);
}, parseInt(5000*stress_factor));
};
gEventSourceObj5_e.hits = [];
gEventSourceObj5_e.hits['fn_onmessage'] = 0;
setTimeout(function() {
ok(gEventSourceObj5_e.hits['fn_onmessage'] > 0, "Test 5.e failed");
gEventSourceObj5_e.close();
doTest5_f(test_id);
}, parseInt(5000*stress_factor));
}
function doTest5_f(test_id)
{
var xhr = SpecialPowers.createSystemXHR();
xhr.withCredentials = true;
xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", false, "user 2", "password 2");
xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", true, "user 2", "password 2");
xhr.send();
ok(xhr.status == 200, "Failed to set credentials in test 5.f");
xhr.onloadend = function() {
ok(xhr.status == 200, "Failed to set credentials in test 5.f");
gEventSourceObj5_f = new EventSource("http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc",
{ });
ok(!gEventSourceObj5_f.withCredentials, "Wrong withCredentials in test 5.f");
gEventSourceObj5_f = new EventSource("http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc",
{ });
ok(!gEventSourceObj5_f.withCredentials, "Wrong withCredentials in test 5.f");
gEventSourceObj5_f.onmessage = function(e) {
ok(e.origin == "http://example.org", "Wrong Origin in test 5.f");
fn_onmessage(e);
gEventSourceObj5_f.onmessage = function(e) {
ok(e.origin == "http://example.org", "Wrong Origin in test 5.f");
fn_onmessage(e);
};
gEventSourceObj5_f.hits = [];
gEventSourceObj5_f.hits['fn_onmessage'] = 0;
setTimeout(function() {
ok(gEventSourceObj5_f.hits['fn_onmessage'] == 0, "Test 5.f failed");
gEventSourceObj5_f.close();
setTestHasFinished(test_id);
}, parseInt(3000*stress_factor));
};
gEventSourceObj5_f.hits = [];
gEventSourceObj5_f.hits['fn_onmessage'] = 0;
setTimeout(function() {
ok(gEventSourceObj5_f.hits['fn_onmessage'] == 0, "Test 5.f failed");
gEventSourceObj5_f.close();
setTestHasFinished(test_id);
}, parseInt(3000*stress_factor));
}
function doTest6(test_id)

View File

@ -86,14 +86,14 @@ function onWindowLoad() {
ok(document.iframeWasLoaded, "Loading resource via src-attribute");
for each (test in alltests) {
function runTest(test) {
var xhr = new XMLHttpRequest();
var method = "GET";
if (test.method != null) { method = test.method; }
xhr.open(method, test.url, false);
xhr.open(method, test.url);
xhr.withCredentials = test.withCredentials;
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
@ -104,11 +104,20 @@ function onWindowLoad() {
xhr.send();
} catch(e) {
}
var success = eval(xhr.status + test.status_check);
ok(success, test.error);
xhr.onloadend = function() {
var success = eval(xhr.status + test.status_check);
ok(success, test.error);
if (alltests.length == 0) {
SimpleTest.finish();
} else {
runTest(alltests.shift());
}
};
}
SimpleTest.finish();
runTest(alltests.shift());
}
SimpleTest.waitForExplicitFinish();

View File

@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=707142
-->
<head>
<title>Test for Bug 707142</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=707142">Mozilla Bug 707142</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 707142 **/
SimpleTest.waitForExplicitFinish();
var xhr = new XMLHttpRequest();
xhr.onload = function() {
is(xhr.response["foo"], "bar", "Should have gotten bar on baseline");
xhr.onload = function() {
is(xhr.response["foo"], "bar", "Should have gotten bar with BOM");
xhr.onload = function() {
is(xhr.response, null, "Should have gotten null response with UTF-16 JSON");
SimpleTest.finish();
};
xhr.open("GET", "file_bug707142_utf-16.json");
xhr.responseType = "json";
xhr.send();
};
xhr.open("GET", "file_bug707142_bom.json");
xhr.responseType = "json";
xhr.send();
};
xhr.open("GET", "file_bug707142_baseline.json");
xhr.responseType = "json";
xhr.send();
</script>
</pre>
</body>
</html>

View File

@ -115,7 +115,7 @@ function runTests() {
{ type: "arraybuffer", text: false, nodata: true },
{ type: "blob", text: false, nodata: true },
{ type: "document", text: true, nodata: true },
{ type: "moz-json", text: true, nodata: true },
{ type: "json", text: true, nodata: true },
{ type: "", text: true },
{ type: "moz-chunked-text", text: true, chunked: true },
{ type: "moz-chunked-arraybuffer", text: false, chunked: true },

View File

@ -0,0 +1,21 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Test setting .responseType and .withCredentials is allowed
// in non-window non-Worker context
function run_test()
{
var xhr = Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'].
createInstance(Components.interfaces.nsIXMLHttpRequest);
xhr.open('GET', 'data:,', false);
var exceptionThrown = false;
try {
xhr.responseType = '';
xhr.withCredentials = false;
} catch (e) {
exceptionThrown = true;
}
do_check_eq(false, exceptionThrown);
}

View File

@ -7,4 +7,5 @@ tail =
[test_csputils.js]
[test_error_codes.js]
[test_thirdpartyutil.js]
[test_xhr_standalone.js]
[test_xmlserializer.js]

View File

@ -2771,7 +2771,7 @@ struct NS_STACK_CLASS nsCanvasBidiProcessor : public nsBidiPresUtils::BidiProces
virtual void DrawText(nscoord xOffset, nscoord width)
{
gfxPoint point = mPt;
point.x += xOffset * mAppUnitsPerDevPixel;
point.x += xOffset;
// offset is given in terms of left side of string
if (mTextRun->IsRightToLeft()) {

View File

@ -2975,7 +2975,7 @@ struct NS_STACK_CLASS nsCanvasBidiProcessorAzure : public nsBidiPresUtils::BidiP
virtual void DrawText(nscoord xOffset, nscoord width)
{
gfxPoint point = mPt;
point.x += xOffset * mAppUnitsPerDevPixel;
point.x += xOffset;
// offset is given in terms of left side of string
if (mTextRun->IsRightToLeft()) {

View File

@ -135,6 +135,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/LookAndFeel.h"
#include "sampler.h"
#ifdef XP_MACOSX
#import <ApplicationServices/ApplicationServices.h>
@ -3808,6 +3809,7 @@ nsEventStateManager::DispatchMouseEvent(nsGUIEvent* aEvent, PRUint32 aMessage,
nsIContent* aTargetContent,
nsIContent* aRelatedContent)
{
SAMPLE_LABEL("Input", "DispatchMouseEvent");
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent), aMessage, aEvent->widget,
nsMouseEvent::eReal);

View File

@ -50,9 +50,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMStringMap)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMStringMap)
// Call back to element to null out weak reference to this object.
tmp->mElement->ClearDataset();
tmp->mElement = nsnull;
// Check that mElement exists in case the unlink code is run more than once.
if (tmp->mElement) {
// Call back to element to null out weak reference to this object.
tmp->mElement->ClearDataset();
tmp->mElement = nsnull;
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMStringMap)

View File

@ -39,13 +39,18 @@
#if !defined(nsWebMReader_h_)
#define nsWebMReader_h_
#include "mozilla/StdInt.h"
#include "nsDeque.h"
#include "nsBuiltinDecoderReader.h"
#include "nsWebMBufferedParser.h"
#include "nsAutoRef.h"
#include "nestegg/nestegg.h"
#define VPX_DONT_DEFINE_STDINT_TYPES
#include "vpx/vpx_decoder.h"
#include "vpx/vp8dx.h"
#ifdef MOZ_TREMOR
#include "tremor/ivorbiscodec.h"
#else

View File

@ -322,6 +322,28 @@ nsSMILTimeValueSpec::GetTimedElement(Element* aElement)
return &animElement->TimedElement();
}
// Indicates whether we're allowed to register an event-listener
// when scripting is disabled.
bool
nsSMILTimeValueSpec::IsWhitelistedEvent()
{
// The category of (SMIL-specific) "repeat(n)" events are allowed.
if (mParams.mType == nsSMILTimeValueSpecParams::REPEAT) {
return true;
}
// A specific list of other SMIL-related events are allowed, too.
if (mParams.mType == nsSMILTimeValueSpecParams::EVENT &&
(mParams.mEventSymbol == nsGkAtoms::repeat ||
mParams.mEventSymbol == nsGkAtoms::repeatEvent ||
mParams.mEventSymbol == nsGkAtoms::beginEvent ||
mParams.mEventSymbol == nsGkAtoms::endEvent)) {
return true;
}
return false;
}
void
nsSMILTimeValueSpec::RegisterEventListener(Element* aTarget)
{
@ -334,10 +356,11 @@ nsSMILTimeValueSpec::RegisterEventListener(Element* aTarget)
if (!aTarget)
return;
// Don't listen for accessKey events if script is disabled. (see bug 704482)
if (mParams.mType == nsSMILTimeValueSpecParams::ACCESSKEY &&
!aTarget->GetOwnerDocument()->IsScriptEnabled())
// When script is disabled, only allow registration for whitelisted events.
if (!aTarget->GetOwnerDocument()->IsScriptEnabled() &&
!IsWhitelistedEvent()) {
return;
}
if (!mEventListener) {
mEventListener = new EventListener(this);

View File

@ -93,6 +93,7 @@ protected:
void UpdateReferencedElement(Element* aFrom, Element* aTo);
void UnregisterFromReferencedElement(Element* aElement);
nsSMILTimedElement* GetTimedElement(Element* aElement);
bool IsWhitelistedEvent();
void RegisterEventListener(Element* aElement);
void UnregisterEventListener(Element* aElement);
nsEventListenerManager* GetEventListenerManager(Element* aElement);

View File

@ -83,6 +83,7 @@
#include "nsIIOService.h"
#include "mozilla/dom/Element.h"
#include "sampler.h"
using namespace mozilla::dom;
using namespace mozilla::layers;
@ -729,6 +730,7 @@ nsDOMWindowUtils::Focus(nsIDOMElement* aElement)
NS_IMETHODIMP
nsDOMWindowUtils::GarbageCollect(nsICycleCollectorListener *aListener)
{
SAMPLE_LABEL("GC", "GarbageCollect");
// Always permit this in debug builds.
#ifndef DEBUG
if (!IsUniversalXPConnectCapable()) {

View File

@ -108,6 +108,8 @@
#include "mozilla/FunctionTimer.h"
#include "mozilla/Preferences.h"
#include "sampler.h"
using namespace mozilla;
const size_t gStackSize = 8192;
@ -1185,6 +1187,7 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript,
NS_TIME_FUNCTION_MIN_FMT(1.0, "%s (line %d) (url: %s, line: %d)", MOZ_FUNCTION_NAME,
__LINE__, aURL, aLineNo);
SAMPLE_LABEL("JS", "EvaluateStringWithValue");
NS_ABORT_IF_FALSE(aScopeObject,
"Shouldn't call EvaluateStringWithValue with null scope object.");
@ -1387,6 +1390,7 @@ nsJSContext::EvaluateString(const nsAString& aScript,
NS_TIME_FUNCTION_MIN_FMT(1.0, "%s (line %d) (url: %s, line: %d)", MOZ_FUNCTION_NAME,
__LINE__, aURL, aLineNo);
SAMPLE_LABEL("JS", "EvaluateString");
NS_ENSURE_TRUE(mIsInitialized, NS_ERROR_NOT_INITIALIZED);
if (!mScriptsEnabled) {
@ -1857,6 +1861,7 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, JSObject* aScope,
NS_TIME_FUNCTION_FMT(1.0, "%s (line %d) (function: %s)", MOZ_FUNCTION_NAME, __LINE__, name);
}
#endif
SAMPLE_LABEL("JS", "CallEventHandler");
JSAutoRequest ar(mContext);
JSObject* target = nsnull;
@ -3166,6 +3171,7 @@ void
nsJSContext::GarbageCollectNow(bool shrinkingGC)
{
NS_TIME_FUNCTION_MIN(1.0);
SAMPLE_LABEL("GC", "GarbageCollectNow");
KillGCTimer();
@ -3191,6 +3197,7 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener)
return;
}
SAMPLE_LABEL("GC", "CycleCollectNow");
NS_TIME_FUNCTION_MIN(1.0);
KillCCTimer();

View File

@ -130,3 +130,6 @@ AddedWindowedPluginWhileFullScreen=Exited full-screen because windowed plugin wa
HTMLMultipartXHRWarning=HTML parsing in XMLHttpRequest is not supported for multipart responses.
HTMLSyncXHRWarning=HTML parsing in XMLHttpRequest is not supported in the synchronous mode.
InvalidRedirectChannelWarning=Unable to redirect to %S because the channel doesn't implement nsIWritablePropertyBag2.
ResponseTypeSyncXHRWarning=Use of XMLHttpRequest's responseType attribute is no longer supported in the synchronous mode in window context.
WithCredentialsSyncXHRWarning=Use of XMLHttpRequest's withCredentials attribute is no longer supported in the synchronous mode in window context.
JSONCharsetWarning=An attempt was made to declare a non-UTF-8 encoding for JSON retrieved using XMLHttpRequest. Only UTF-8 is supported for decoding JSON.

View File

@ -233,7 +233,9 @@ PRLogModuleInfo* nsPluginLogging::gPluginLog = nsnull;
// #defines for plugin cache and prefs
#define NS_PREF_MAX_NUM_CACHED_INSTANCES "browser.plugins.max_num_cached_plugins"
#define DEFAULT_NUMBER_OF_STOPPED_INSTANCES 10
// Raise this from '10' to '50' to work around a bug in Apple's current Java
// plugins on OS X Lion and SnowLeopard. See bug 705931.
#define DEFAULT_NUMBER_OF_STOPPED_INSTANCES 50
#ifdef CALL_SAFETY_ON
// By default we run OOPP, so we don't want to cover up crashes.

View File

@ -38,22 +38,7 @@
#ifndef MOZILLA_GFX_TYPES_H_
#define MOZILLA_GFX_TYPES_H_
#if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || defined (_sgi) || defined (__sun) || defined (sun) || defined (__digital__)
# include <inttypes.h>
#elif defined (_MSC_VER)
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#elif defined (_AIX)
# include <sys/inttypes.h>
#else
# include <stdint.h>
#endif
#include "mozilla/StdInt.h"
#include <stddef.h>

View File

@ -185,13 +185,16 @@ endif # GNU_CC
# special rule for pixman-mmx to get the right cflags
pixman-mmx.$(OBJ_SUFFIX): pixman-mmx.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(MMX_CFLAGS) $(_VPATH_SRCS)
pixman-sse2.$(OBJ_SUFFIX): pixman-sse2.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(SSE2_CFLAGS) $(_VPATH_SRCS)
pixman-arm-neon.$(OBJ_SUFFIX): pixman-arm-neon.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(ARM_NEON_CFLAGS) $(_VPATH_SRCS)

View File

@ -65,6 +65,8 @@
#endif
#include "GLContext.h"
#define PIXMAN_DONT_DEFINE_STDINT
#include "pixman.h"
namespace mozilla {

View File

@ -103,9 +103,11 @@ endif # GNU_CC
# special rules for transform-sse*.c to get the right cflags. (taken from pixman/src/Makefile.in)
transform-sse1.$(OBJ_SUFFIX): transform-sse1.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(SSE1_FLAGS) $(_VPATH_SRCS)
transform-sse2.$(OBJ_SUFFIX): transform-sse2.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(SSE2_FLAGS) $(_VPATH_SRCS)

View File

@ -40,18 +40,7 @@
/* API for the WOFF encoder and decoder */
#ifdef _MSC_VER /* MS VC lacks inttypes.h
but we can make do with a few definitons here */
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
#else
#include <inttypes.h>
#endif
#include "mozilla/StdInt.h"
#include <stdio.h> /* only for FILE, needed for woffPrintStatus */

View File

@ -1,7 +1,9 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
var currentTest;
var gIsRefImageLoaded = false;
const gShouldOutputDebugInfo = false;
function pollForSuccess ()
function pollForSuccess()
{
if (!currentTest.isTestFinished) {
if (!currentTest.reusingReferenceImage || (currentTest.reusingReferenceImage
@ -23,9 +25,8 @@ function reuseImageCallback()
gIsRefImageLoaded = true;
}
function failTest ()
{ imageLoadCallback();
function failTest()
{
if (currentTest.isTestFinished || currentTest.closeFunc) {
return;
}
@ -120,6 +121,9 @@ AnimationTest.prototype.preloadImage = function()
AnimationTest.prototype.outputDebugInfo = function(message, id, dataUri)
{
if (!gShouldOutputDebugInfo) {
return;
}
var debugElement = document.getElementById(this.debugElementId);
var newDataUriElement = document.createElement("a");
newDataUriElement.setAttribute("id", id);
@ -203,7 +207,7 @@ AnimationTest.prototype.continueTest = function()
this.takeReferenceSnapshot();
this.setupPolledImage();
setTimeout(pollForSuccess, 10);
SimpleTest.executeSoon(pollForSuccess);
};
AnimationTest.prototype.setupPolledImage = function ()
@ -212,7 +216,8 @@ AnimationTest.prototype.setupPolledImage = function ()
if (!this.reusingImageAsReference) {
this.enableDisplay(document.getElementById(this.imageElementId));
var currentSnapshot = snapshotWindow(window, false);
var result = compareSnapshots(currentSnapshot, this.referenceSnapshot, true);
var result = compareSnapshots(currentSnapshot,
this.referenceSnapshot, true);
this.currentSnapshotDataURI = currentSnapshot.toDataURL();
@ -276,14 +281,14 @@ AnimationTest.prototype.takeReferenceSnapshot = function ()
}
if (this.reusingImageAsReference) {
// Show reference div, & take a snapshot
var referenceDiv = document.getElementById(this.imageElementId);
this.enableDisplay(referenceDiv);
// Show reference elem (which is actually our image), & take a snapshot
var referenceElem = document.getElementById(this.imageElementId);
this.enableDisplay(referenceElem);
this.referenceSnapshot = snapshotWindow(window, false);
var snapResult = compareSnapshots(this.cleanSnapshot, this.referenceSnapshot,
false);
var snapResult = compareSnapshots(this.cleanSnapshot,
this.referenceSnapshot, false);
if (!snapResult[0]) {
if (this.blankWaitTime > 2000) {
// if it took longer than two seconds to load the image, we probably
@ -292,9 +297,9 @@ AnimationTest.prototype.takeReferenceSnapshot = function ()
ok(snapResult[0],
"Reference snapshot shouldn't match clean (non-image) snapshot");
} else {
this.blankWaitTime += 20;
this.blankWaitTime += currentTest.pollFreq;
// let's wait a bit and see if it clears up
setTimeout(referencePoller, 20);
setTimeout(referencePoller, currentTest.pollFreq);
return;
}
}
@ -314,7 +319,8 @@ AnimationTest.prototype.takeReferenceSnapshot = function ()
this.enableDisplay(referenceDiv);
this.referenceSnapshot = snapshotWindow(window, false);
var snapResult = compareSnapshots(this.cleanSnapshot, this.referenceSnapshot, false);
var snapResult = compareSnapshots(this.cleanSnapshot,
this.referenceSnapshot, false);
if (!snapResult[0]) {
if (this.blankWaitTime > 2000) {
// if it took longer than two seconds to load the image, we probably

View File

@ -284,8 +284,10 @@ EXPORTS_NAMESPACES += mozilla
EXPORTS_mozilla = \
Attributes.h \
GuardObjects.h \
MSStdInt.h \
RangedPtr.h \
RefPtr.h \
StdInt.h \
Types.h \
Util.h \
$(NULL)
@ -801,6 +803,7 @@ ifdef SOLARIS_SUNPRO_CXX
ifeq ($(TARGET_CPU),sparc)
# Sun Studio SPARC doesn't work well with gcc inline asm, use lock_SunOS_sparc*.il
jslock.o: jslock.cpp Makefile.in lock_sparcv8plus.il lock_sparcv9.il
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
ifeq (sparcv9,$(findstring sparcv9,$(OS_TEST)))
$(CXX) -o $@ -c $(COMPILE_CFLAGS) $(srcdir)/lock_sparcv9.il $<
@ -814,9 +817,11 @@ endif # SOLARIS_SUNPRO_CXX
# This suppresses optimization for this single compilation unit.
ifeq ($(OS_ARCH),AIX)
jsatom.o: jsatom.cpp Makefile.in
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
$(CXX) -o $@ -c $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(COMPILE_CFLAGS)) $<
jsdtoa.o: jsdtoa.cpp Makefile.in
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
$(CXX) -o $@ -c $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(COMPILE_CFLAGS)) $<
endif

View File

@ -64,6 +64,8 @@ ifdef SDK_HEADERS
EXPORTS += $(SDK_HEADERS)
endif
REPORT_BUILD = @echo $(notdir $<)
ifeq ($(OS_ARCH),OS2)
EXEC =
else
@ -1148,25 +1150,32 @@ endif # MOZ_AUTO_DEPS
# Rules for building native targets must come first because of the host_ prefix
host_%.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
host_%.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
host_%.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
host_%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
host_%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
%:: %.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTOPTION)$@ $(_VPATH_SRCS)
%.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(_VPATH_SRCS)
@ -1177,6 +1186,7 @@ moc_%.cpp: %.h $(GLOBAL_DEPS)
$(MOC) $(DEFINES) $(ACDEFINES) $< $(OUTOPTION)$@
moc_%.cc: %.cc $(GLOBAL_DEPS)
$(REPORT_BUILD)
$(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $(_VPATH_SRCS:.cc=.h) $(OUTOPTION)$@
ifdef ASFILES
@ -1197,10 +1207,12 @@ endif
# Please keep the next two rules in sync.
#
%.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
%.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
ifdef STRICT_CPLUSPLUS_SUFFIX
echo "#line 1 \"$*.cpp\"" | cat - $*.cpp > t_$*.cc
@ -1211,10 +1223,12 @@ else
endif #STRICT_CPLUSPLUS_SUFFIX
$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
$(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS)
$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
$(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $(_VPATH_SRCS)
@ -1464,6 +1478,7 @@ XPIDL_DEPS = \
$(NULL)
$(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_DEPS) $(XPIDL_GEN_DIR)/.done
$(REPORT_BUILD)
$(PYTHON_PATH) \
-I$(topsrcdir)/other-licenses/ply \
-I$(topsrcdir)/xpcom/idl-parser \
@ -1475,6 +1490,7 @@ ifndef NO_GEN_XPT
# generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
# into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
$(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_DEPS) $(XPIDL_GEN_DIR)/.done
$(REPORT_BUILD)
$(PYTHON_PATH) \
-I$(topsrcdir)/other-licenses/ply \
-I$(topsrcdir)/xpcom/idl-parser \
@ -1763,12 +1779,15 @@ define MAKE_DEPS_NOAUTO
endef
$(MDDEPDIR)/%.pp: %.c
$(REPORT_BUILD)
@$(MAKE_DEPS_NOAUTO)
$(MDDEPDIR)/%.pp: %.cpp
$(REPORT_BUILD)
@$(MAKE_DEPS_NOAUTO)
$(MDDEPDIR)/%.pp: %.s
$(REPORT_BUILD)
@$(MAKE_DEPS_NOAUTO)
ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))

View File

@ -1240,6 +1240,11 @@ if test "$GMAKE" = ":"; then
fi
AC_SUBST(GMAKE)
# MAKE will be set by client.mk, but still need this for standalone js builds
if test -z "$MAKE"; then
MAKE=$GMAKE
fi
if test "$COMPILE_ENVIRONMENT"; then
AC_PATH_XTRA
@ -2107,6 +2112,17 @@ if test "$_python_res" != 0; then
fi
AC_MSG_RESULT([yes])
dnl Check for using a custom <stdint.h> implementation
dnl ========================================================
AC_MSG_CHECKING(for custom <stdint.h> implementation)
if test "$MOZ_CUSTOM_STDINT_H"; then
AC_DEFINE_UNQUOTED(MOZ_CUSTOM_STDINT_H, "$MOZ_CUSTOM_STDINT_H")
AC_SUBST(MOZ_CUSTOM_STDINT_H)
AC_MSG_RESULT(using $MOZ_CUSTOM_STDINT_H)
else
AC_MSG_RESULT(none specified)
fi
MOZ_DOING_LTO(lto_is_enabled)
dnl ========================================================
@ -2920,28 +2936,6 @@ else
AC_MSG_RESULT(no)
fi
dnl Find exact-width integer types, or figure them out
dnl ourselves.
dnl ========================================================
dnl Once this is working, we can delete the code for int16_t,
dnl etc. below.
MOZ_CHECK_HEADER(stdint.h)
if test "$ac_cv_header_stdint_h" = yes; then
AC_DEFINE(JS_HAVE_STDINT_H)
else
dnl We'll figure them out for ourselves. List more likely types
dnl earlier. If we ever really encounter a size for which none of
dnl the listed types are appropriate, we'll get a configure-time
dnl error; just add the right answer.
MOZ_N_BYTE_TYPE(JS_INT8_TYPE, 1, [char])
MOZ_N_BYTE_TYPE(JS_INT16_TYPE, 2, [short int long])
MOZ_N_BYTE_TYPE(JS_INT32_TYPE, 4, [int long 'long long' short])
MOZ_N_BYTE_TYPE(JS_INT64_TYPE, 8, [int long 'long long'])
MOZ_N_BYTE_TYPE(JS_INTPTR_TYPE, sizeof (void *),
[int long 'long long' short])
fi
MOZ_SIZE_OF_TYPE(JS_BYTES_PER_WORD, void*, 4 8)
if test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "4"; then
AC_DEFINE(JS_BITS_PER_WORD_LOG2, 5)
@ -2964,60 +2958,8 @@ if test "$ac_cv_header_sys_isa_defs_h" = yes; then
AC_DEFINE(JS_HAVE_SYS_ISA_DEFS_H)
fi
dnl Check for int16_t, int32_t, int64_t, int64, uint, uint_t, and uint16_t.
dnl Check for uint and uint_t.
dnl ========================================================
AC_MSG_CHECKING(for int16_t)
AC_CACHE_VAL(ac_cv_int16_t,
[AC_TRY_COMPILE([#include <stdio.h>
#include <sys/types.h>],
[int16_t foo = 0;],
[ac_cv_int16_t=true],
[ac_cv_int16_t=false])])
if test "$ac_cv_int16_t" = true ; then
AC_DEFINE(HAVE_INT16_T)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(for int32_t)
AC_CACHE_VAL(ac_cv_int32_t,
[AC_TRY_COMPILE([#include <stdio.h>
#include <sys/types.h>],
[int32_t foo = 0;],
[ac_cv_int32_t=true],
[ac_cv_int32_t=false])])
if test "$ac_cv_int32_t" = true ; then
AC_DEFINE(HAVE_INT32_T)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(for int64_t)
AC_CACHE_VAL(ac_cv_int64_t,
[AC_TRY_COMPILE([#include <stdio.h>
#include <sys/types.h>],
[int64_t foo = 0;],
[ac_cv_int64_t=true],
[ac_cv_int64_t=false])])
if test "$ac_cv_int64_t" = true ; then
AC_DEFINE(HAVE_INT64_T)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(for int64)
AC_CACHE_VAL(ac_cv_int64,
[AC_TRY_COMPILE([#include <stdio.h>
#include <sys/types.h>],
[int64 foo = 0;],
[ac_cv_int64=true],
[ac_cv_int64=false])])
if test "$ac_cv_int64" = true ; then
AC_DEFINE(HAVE_INT64)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(for uint)
AC_CACHE_VAL(ac_cv_uint,
[AC_TRY_COMPILE([#include <stdio.h>
@ -3044,19 +2986,6 @@ if test "$ac_cv_uint_t" = true ; then
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(for uint16_t)
AC_CACHE_VAL(ac_cv_uint16_t,
[AC_TRY_COMPILE([#include <stdio.h>
#include <sys/types.h>],
[uint16_t foo = 0;],
[ac_cv_uint16_t=true],
[ac_cv_uint16_t=false])])
if test "$ac_cv_uint16_t" = true ; then
AC_DEFINE(HAVE_UINT16_T)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
dnl are defined when compiling C++ but not C. Since the result of this
@ -4723,7 +4652,7 @@ dnl ========================================================
AC_MSG_CHECKING([for gcc -pipe support])
if test -n "$GNU_CC" -a -n "$GNU_CXX" -a -n "$GNU_AS"; then
echo '#include <stdio.h>' > dummy-hello.c
echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c
echo 'int main() { printf("Hello World"); exit(0); }' >> dummy-hello.c
${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
cat dummy-hello.s 2> /dev/null | ${AS_BIN} -o dummy-hello.S - 2>&5
if test $? = 0; then
@ -5405,18 +5334,34 @@ mv confdefs.h.save confdefs.h
MAKEFILES="
Makefile
shell/Makefile
jsapi-tests/Makefile
tests/Makefile
config/Makefile
config/autoconf.mk
config/expandlibs_config.py
config/mkdepend/Makefile
"
if test -n "$JS_NATIVE_EDITLINE"; then
MAKEFILES="$MAKEFILES
editline/Makefile
"
if test "$JS_NATIVE_EDITLINE"; then
MAKEFILES="$MAKEFILES
editline/Makefile
"
fi
if test ! "$COMPILER_DEPEND" -a ! "$MOZ_NATIVE_MAKEDEPEND"; then
MAKEFILES="$MAKEFILES
config/mkdepend/Makefile
"
fi
if test "$ENABLE_TESTS"; then
MAKEFILES="$MAKEFILES
jsapi-tests/Makefile
tests/Makefile
"
fi
if test "$DEHYDRA_PATH"; then
MAKEFILES="$MAKEFILES
analysis-tests/Makefile
"
fi
dnl
@ -5448,8 +5393,8 @@ fi
# Produce the js-config script at configure time; see the comments for
# 'js-config' in Makefile.in.
AC_MSG_RESULT(invoking make to create js-config script)
$GMAKE js-config
AC_MSG_RESULT(invoking $MAKE to create js-config script)
$MAKE js-config
# Build jsctypes if it's enabled.
if test "$JS_HAS_CTYPES" -a -z "$MOZ_NATIVE_FFI"; then

View File

@ -1,4 +1,4 @@
// |jit-test| debug
// |jit-test| slow; debug
/* Make a lot of functions of the form:
function x1(){x1();}

View File

@ -1,4 +1,4 @@
// |jit-test| mjitalways
// |jit-test| slow; mjitalways
var nlocals = 50;
var localstr = "";

View File

@ -0,0 +1,23 @@
// A live Environment can observe the new variables introduced by ES5 non-strict direct eval.
var g = newGlobal('new-compartment');
g.eval("var x = 'global'; function f(s) { h(); eval(s); h(); }");
g.eval("function h() { debugger; }");
var dbg = Debugger(g);
var env = undefined;
var hits = 0;
dbg.onDebuggerStatement = function (hframe) {
if (env === undefined) {
// First debugger statement.
env = hframe.older.environment;
assertEq(env.find("x") !== env, true);
assertEq(env.names().indexOf("x"), -1);
} else {
// Second debugger statement, post-eval.
assertEq(env.find("x"), env);
assertEq(env.names().indexOf("x") >= 0, true);
}
hits++;
};
g.f("var x = 'local';");
assertEq(hits, 2);

View File

@ -0,0 +1,20 @@
// The last Environment on the environment chain always has .type == "object" and .object === the global object.
var g = newGlobal('new-compartment');
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
g.eval("function h() { debugger; }");
var hits = 0;
dbg.onDebuggerStatement = function (hframe) {
var env = hframe.older.environment;
while (env.parent)
env = env.parent;
assertEq(env.type, "object");
assertEq(env.object, gw);
hits++;
};
g.eval("h();");
g.eval("(function () { h(); return []; })();");
g.eval("with (Math) { h(-2 * PI); }");
assertEq(hits, 3);

View File

@ -0,0 +1,19 @@
// find sees that vars are hoisted out of with statements.
var g = newGlobal('new-compartment');
var dbg = Debugger(g);
var hits = 0;
dbg.onDebuggerStatement = function (frame) {
assertEq(frame.environment.find("x").type, "object");
hits++;
};
assertEq(g.eval("(function () {\n" +
" function g() { x = 1; }\n" +
" with ({x: 2}) {\n" +
" var x;\n" +
" debugger;\n" +
" return x;\n" +
" }\n" +
"})();"), 2);
assertEq(hits, 1);

View File

@ -0,0 +1,18 @@
// env.find() finds nonenumerable names in the global environment.
var g = newGlobal('new-compartment');
var dbg = Debugger(g);
var hits = 0;
g.h = function () {
var env = dbg.getNewestFrame().environment;
var last = env;
while (last.parent)
last = last.parent;
assertEq(env.find("Array"), last);
hits++;
};
g.eval("h();");
g.eval("(function () { let (x = 1, y = 2) h(); })();");
assertEq(hits, 2);

View File

@ -0,0 +1,20 @@
// env.find() finds noneumerable properties in with statements.
var g = newGlobal('new-compartment');
var dbg = Debugger(g);
var hits = 0;
g.h = function () {
var frame = dbg.getNewestFrame();
var target = frame.eval("obj").return;
var env = frame.environment.find("PI");
assertEq(env.object, target);
hits++;
};
g.obj = g.Math;
g.eval("with (obj) h();");
g.eval("with (Math) { let x = 12; h(); }");
g.eval("obj = {};\n" +
"Object.defineProperty(obj, 'PI', {enumerable: false, value: 'Marlowe'});\n" +
"with (obj) h();\n");
assertEq(hits, 3);

View File

@ -0,0 +1,21 @@
// env.find throws a TypeError if the argument is not an identifier.
load(libdir + "asserts.js");
var g = newGlobal('new-compartment');
var dbg = Debugger(g);
var hits = 0;
g.h = function () {
var env = dbg.getNewestFrame().environment;
assertThrowsInstanceOf(function () { env.find(); }, TypeError);
assertThrowsInstanceOf(function () { env.find(""); }, TypeError);
assertThrowsInstanceOf(function () { env.find(" "); }, TypeError);
assertThrowsInstanceOf(function () { env.find(0); }, TypeError);
assertThrowsInstanceOf(function () { env.find("0"); }, TypeError);
assertThrowsInstanceOf(function () { env.find("0xc"); }, TypeError);
assertThrowsInstanceOf(function () { env.find("Anna Karenina"); }, TypeError);
hits++;
};
g.eval("h();");
g.eval("with ([1]) h();");
assertEq(hits, 2);

View File

@ -0,0 +1,49 @@
// Environment.prototype.find finds bindings that are function arguments, 'let'
// bindings, or FunctionExpression names.
var g = newGlobal('new-compartment');
g.eval("function h() { debugger; }");
var dbg = new Debugger(g);
function test1(code) {
var hits = 0;
dbg.onDebuggerStatement = function (frame) {
var env = frame.older.environment.find('X');
assertEq(env.names().indexOf('X') !== -1, true);
assertEq(env.type, 'declarative');
assertEq(env.parent !== null, true);
hits++;
};
g.eval(code);
assertEq(hits, 1);
}
var manyNames = '';
for (var i = 0; i < 4096; i++)
manyNames += 'x' + i + ', ';
manyNames += 'X';
function test2(code) {
print(code + " : one");
test1(code.replace('@@', 'X'));
print(code + " : many");
test1(code.replace('@@', manyNames));
}
test2('function f(@@) { h(); } f(1);');
test2('function f(@@) { h(); } f();');
test2('function f(@@) { return function g() { h(X); }; } f(1)();');
test2('function f(@@) { return function g() { h(X); }; } f()();');
test2(' { let @@ = 0; h(); }');
test2('function f(a, b, c) { let @@ = 0; h(); } f(1, 2, 3);');
test2(' { let @@ = 0; { let y = 0; h(); } }');
test2('function f() { let @@ = 0; { let y = 0; h(); } } f();');
test2(' { for (let @@ = 0; X < 1; X++) h(); }');
test2('function f() { for (let @@ = 0; X < 1; X++) h(); } f();');
test2(' { (let (@@ = 0) let (y = 2, z = 3) h()); }');
test2('function f() { return (let (@@ = 0) let (y = 2, z = 3) h()); } f();');
test1('(function X() { h(); })();');
test1('(function X(a, b, c) { h(); })(1, 2, 3);');

View File

@ -0,0 +1,19 @@
// An Environment keeps its referent alive.
var g = newGlobal('new-compartment');
g.eval("function f(x) { return 2 * x; }");
var dbg = Debugger(g);
var env;
dbg.onEnterFrame = function (frame) { env = frame.environment; };
assertEq(g.f(22), 44);
dbg.onEnterFrame = undefined;
assertEq(env.find("x"), env);
assertEq(env.names().join(","), "x");
gc();
g.gc(g);
gc(env);
assertEq(env.find("x"), env);
assertEq(env.names().join(","), "x");

View File

@ -0,0 +1,28 @@
// A closure's .environment keeps the lexical environment alive even if the closure is destroyed.
var N = 4;
var g = newGlobal('new-compartment');
g.eval("function add(a) { return function (b) { return eval('a + b'); }; }");
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
var aw = gw.getOwnPropertyDescriptor("add").value;
// Create N closures and collect environments.
var arr = [];
for (var i = 0; i < N; i++)
arr[i] = aw.call(null, i).return.environment;
// Test that they work now.
function check() {
for (var i = 0; i < N; i++) {
assertEq(arr[i].find("b"), null);
assertEq(arr[i].find("a"), arr[i]);
}
}
check();
// Test that they work after gc.
gc();
gc({});
g.gc(g);
check();

View File

@ -0,0 +1,40 @@
// The value of frame.environment is the same Environment object at different
// times within a single visit to a scope.
var g = newGlobal('new-compartment');
var dbg = Debugger(g);
g.eval("function h() { debugger; }");
var hits, env;
dbg.onDebuggerStatement = function (hframe) {
var frame = hframe.older;
var e = frame.environment;
// frame.environment is at least cached from one moment to the next.
assertEq(e, frame.environment);
// frame.environment is cached from statement to statement within a call frame.
if (env === undefined)
env = e;
else
assertEq(e, env);
hits++;
};
hits = 0;
env = undefined;
g.eval("function f() { (function () { var i = 0; h(); var j = 2; h(); })(); }");
g.f();
assertEq(hits, 2);
hits = 0;
env = undefined;
g.eval("function f2() { { let i = 0; h(); let j = 2; h(); } }");
g.f2();
assertEq(hits, 2);
hits = 0;
env = undefined;
g.eval("function f3() { { let i; for (i = 0; i < 2; i++) h(); } }");
g.f3();
assertEq(hits, 2);

View File

@ -0,0 +1,29 @@
// frame.environment is different for different activations of a scope.
var g = newGlobal('new-compartment');
var dbg = Debugger(g);
g.eval("function h() { debugger; }");
var arr;
dbg.onDebuggerStatement = function (hframe) {
var e = hframe.older.environment;
assertEq(arr.indexOf(e), -1);
arr.push(e);
};
function test(code, expectedHits) {
arr = [];
g.eval(code);
assertEq(arr.length, expectedHits);
}
// two separate calls to a function
test("(function () { var f = function (a) { h(); return a; }; f(1); f(2); })();", 2);
// recursive calls to a function
test("(function f(n) { h(); return n < 2 ? 1 : n * f(n - 1); })(3);", 3);
// separate visits to a block in the same call frame
test("(function () { for (var i = 0; i < 3; i++) { let j = i * 4; h(); }})();", 3);
// two strict direct eval calls in the same function scope
test("(function () { 'use strict'; for (var i = 0; i < 3; i++) eval('h();'); })();", 3);

View File

@ -0,0 +1,109 @@
// Two Environments nested in the same runtime scope share the correct tail of their parent chains.
// The compiler must be allowed to elide empty scopes and so forth, so this
// test does not check the number of unshared Environments. Instead, each test
// case identifies the expected innermost shared scope by the name of a
// variable in it.
var g = newGlobal('new-compartment');
g.eval("function h() { debugger; }");
var dbg = Debugger(g);
var hits, name, shared, unshared;
dbg.onDebuggerStatement = function (hframe) {
var frame = hframe.older;
// Find name in frame.environment.
var env, child = null;
for (env = frame.environment; env !== null; env = env.parent) {
if (env.names().indexOf(name) != -1)
break;
child = env;
}
assertEq(env !== null, true, "expected '" + name + "' to be in scope");
assertEq(env, frame.environment.find(name),
"env.find should find the same frame as the written out search");
if (hits === 0) {
// First hit.
shared = env;
unshared = child;
} else {
// Subsequent hit.
assertEq(env, shared, "the environment containing '" + name + "' should be shared");
assertEq(child === null || unshared === null || unshared !== child, true,
"environments nested within the one containing '" + name + "' should not be shared");
}
hits++;
};
function test(sharedName, expectedHits, code) {
hits = 0;
name = sharedName;
shared = unshared = undefined;
g.eval(code);
assertEq(hits, expectedHits);
}
// Basic test cases.
//
// (The stray "a = b" assignments in these tests are to inhibit the flat closure
// optimization, which Environments expose. There's nothing really wrong with
// the optimization or with the debugger exposing it, but that's not what we
// want to test here.)
test("q", 2, "var q = function (a) { h(); }; q(1); q(2);");
test("a", 2, "q = function (a) { (function (b) { h(); a = b; })(2); h(); }; q(1);");
test("a", 2, "q = function (a) { h(); return function (b) { h(); a = b; }; }; q(1)(2);");
test("n", 3, "q = function (n) { for (var i = 0; i < n; i++) { let (j = i) { h(); } } }; q(3);");
// Don't crash in E4X filter scopes.
test("x", 2, "q = function () { var x = <><y/><z/></>.(function (e) { h(); }(this)); }; q();");
// A function with long dynamic and static chains.
var N = 80;
var code = "function f" + N + "(a" + N + ") {\neval('a0 + a1'); h();\n}\n";
for (var i = N; --i >= 0;) {
var call = "f" + (i + 1) + "(a" + i + " - 1);\n";
code = ("function f" + i + "(a" + i + ") {\n" +
code +
call +
"if (a" + i + " === 0) " + call +
"}\n");
}
g.eval(code);
test("a0", 2, "f0(0);");
test("a17", 2, "f0(17);");
test("a" + (N-2), 2, "f0(" + (N-2) + ");");
test("a" + (N-1), 2, "f0(" + (N-1) + ");");
// A function with a short dynamic chain and a long static chain.
N = 60;
function DeepStaticShallowDynamic(i, n) {
var code = "function f" + i + "(a" + i + ") {\n";
if (i >= n)
code += "eval('a1 + a2'); h();\n";
else
code += "return " + DeepStaticShallowDynamic(i+1, n) + ";\n";
code += "}";
return code;
}
g.eval(DeepStaticShallowDynamic(1, N));
function range(start, stop) {
for (var i = start; i < stop; i++)
yield i;
}
function DSSDsplit(s) {
return ("var mid = f1" + ["(" + i + ")" for (i in range(0, s))].join("") + ";\n" +
"mid" + ["(" + i + ")" for (i in range(s, N))].join("") + ";\n" +
"mid" + ["(" + i + ")" for (i in range(s, N))].join("") + ";\n");
}
test("a1", 2, DSSDsplit(1));
test("a17", 2, DSSDsplit(17));
test("a" + (N-2), 2, DSSDsplit(N-2));
test("a" + (N-1), 2, DSSDsplit(N-1));

View File

@ -0,0 +1,19 @@
// Observably different visits to the same with-statement produce distinct Environments.
var g = newGlobal('new-compartment');
g.eval("function f(a, obj) { with (obj) return function () { return a; }; }");
var dbg = Debugger(g);
var hits = 0;
dbg.onDebuggerStatement = function (frame) {
// Even though the two visits to the with-statement have the same target
// object, Math, the environments are observably different.
var f1 = frame.eval("f(1, Math);").return;
var f2 = frame.eval("f(2, Math);").return;
assertEq(f1.environment !== f2.environment, true);
assertEq(f1.object, f2.object);
assertEq(f1.call().return, 1);
assertEq(f2.call().return, 2);
hits++;
};
g.eval("debugger;");
assertEq(hits, 1);

View File

@ -0,0 +1,17 @@
// env.names() lists nonenumerable names in with-statement environments.
var g = newGlobal('new-compartment');
var dbg = Debugger(g);
var hits = 0;
g.h = function () {
var env = dbg.getNewestFrame().environment;
var names = env.names();
assertEq(names.indexOf("a") !== -1, true);
assertEq(names.indexOf("b") !== -1, true);
assertEq(names.indexOf("isPrototypeOf") !== -1, true);
hits++;
};
g.eval("var obj = {a: 1};\n" +
"Object.defineProperty(obj, 'b', {value: 2});\n" +
"with (obj) h();");
assertEq(hits, 1);

View File

@ -0,0 +1,15 @@
// env.names() on object environments ignores property names that are not identifiers.
var g = newGlobal('new-compartment');
var dbg = Debugger(g);
var names;
g.h = function () {
names = dbg.getNewestFrame().environment.names();
};
g.eval("var obj = {a: 1};\n" +
"with ({a: 1, '0xcafe': 2, ' ': 3, '': 4, '0': 5}) h();");
assertEq(names.indexOf("a") !== -1, true);
assertEq(names.indexOf("0xcafe"), -1);
assertEq(names.indexOf(" "), -1);
assertEq(names.indexOf(""), -1);
assertEq(names.indexOf("0"), -1);

View File

@ -0,0 +1,18 @@
// The objects on the environment chain are all Debugger.Environment objects.
// The environment chain ends in null.
var g = newGlobal('new-compartment')
g.eval("function f(a) { return function (b) { return function (c) { h(); return a + b + c; }; }; }");
var dbg = Debugger(g);
var hits = 0;
g.h = function () {
var n = 0;
for (var env = dbg.getNewestFrame().environment; env !== null; env = env.parent) {
n++;
assertEq(env instanceof Debugger.Environment, true);
}
assertEq(n >= 4, true);
hits++;
};
assertEq(g.f(5)(7)(9), 21);
assertEq(hits, 1);

View File

@ -0,0 +1,38 @@
// env.type is 'object' in global environments and with-blocks, and 'declarative' otherwise.
var g = newGlobal('new-compartment');
var dbg = Debugger(g);
function test(code, expected) {
var actual = '';
g.h = function () { actual += dbg.getNewestFrame().environment.type; }
g.eval(code);
assertEq(actual, expected);
}
test("h();", 'object');
test("(function (s) { eval(s); })('var v = h();')", 'declarative');
test("(function (s) { h(); })();", 'declarative');
test("{let x = 1, y = 2; h();}", 'declarative');
test("with({x: 1, y: 2}) h();", 'object');
test("(function (s) { with ({x: 1, y: 2}) h(); })();", 'object');
test("let (x = 1) { h(); }", 'declarative');
test("(let (x = 1) h());", 'declarative');
test("for (let x = 0; x < 1; x++) h();", 'declarative');
test("for (let x in h()) ;", 'object');
test("for (let x in {a:1}) h();", 'declarative');
test("try { throw new Error; } catch (x) { h(x) }", 'declarative');
test("'use strict'; eval('var z = 1; h();');", 'declarative');
test("for (var x in [h(m) for (m in [1])]) ;", 'declarative');
test("for (var x in (h(m) for (m in [1]))) ;", 'declarative');
// Since a generator-expression is effectively a function, the innermost scope
// is a function scope, and thus declarative. Thanks to an odd design decision,
// m is already in scope at the point of the call to h(). The answer here is
// not all that important, but we shouldn't crash.
test("for (var x in (0 for (m in h()))) ;", 'declarative');
dbg.onDebuggerStatement = function (frame) {
assertEq(frame.eval("h(), 2 + 2;").return, 4);
}
test("debugger;", 'object');
test("(function f() { debugger; })();", 'declarative');

View File

@ -0,0 +1,13 @@
// frame.environment is a Debugger.Environment object
var g = newGlobal('new-compartment')
var dbg = Debugger(g);
g.h = function () {
assertEq(dbg.getNewestFrame().environment instanceof Debugger.Environment, true);
};
g.eval("h()");
g.evaluate("h()");
g.eval("eval('h()')");
g.eval("function f() { h(); }");
g.f();

View File

@ -0,0 +1,12 @@
// dbg.getNewestFrame().environment works.
var g = newGlobal('new-compartment');
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
g.h = function () {
var env = dbg.getNewestFrame().environment;
assertEq(env instanceof Debugger.Environment, true);
assertEq(env.object, gw);
assertEq(env.parent, null);
};
g.eval("h()");

View File

@ -0,0 +1,11 @@
// If !frame.live, frame.environment throws.
load(libdir + "asserts.js");
var g = newGlobal('new-compartment');
var dbg = Debugger(g);
var frame;
g.h = function () { frame = dbg.getNewestFrame(); };
g.eval("h();");
assertEq(frame.live, false);
assertThrowsInstanceOf(function () { frame.environment; }, Error);

View File

@ -0,0 +1,12 @@
// frame.environment can be called from the onEnterFrame hook.
var g = newGlobal('new-compartment');
g.eval("function f(x) { return 2 * x; }");
var dbg = Debugger(g);
var hits = 0;
dbg.onEnterFrame = function (frame) {
assertEq(frame.environment.names().join(","), "x");
hits++;
};
assertEq(g.f(22), 44);
assertEq(hits, 1);

View File

@ -1,4 +1,5 @@
// Direct eval code under evalWithbindings sees both the bindings and the enclosing scope.
// Direct eval code under evalWithBindings sees both the bindings and the enclosing scope.
var g = newGlobal('new-compartment');
var dbg = new Debugger(g);
var hits = 0;

View File

@ -0,0 +1,17 @@
// obj.environment is undefined when the referent is not a JS function.
var g = newGlobal('new-compartment')
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
assertEq(gw.environment, undefined);
g.eval("var r = /x/;");
var rw = gw.getOwnPropertyDescriptor("r").value;
assertEq(rw.class, "RegExp");
assertEq(rw.environment, undefined);
// Native function.
var fw = gw.getOwnPropertyDescriptor("parseInt").value;
assertEq(fw.class, "Function");
assertEq(fw.environment, undefined);

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