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

This commit is contained in:
Matt Brubeck 2011-11-21 08:41:42 -08:00
commit 439f001c33
64 changed files with 751 additions and 247 deletions

View File

@ -144,6 +144,8 @@ netscape_security_isPrivilegeEnabled(JSContext *cx, uintN argc, jsval *vp)
if (NS_FAILED(rv))
result = JS_FALSE;
}
} else {
return JS_FALSE;
}
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(result));
return JS_TRUE;

View File

@ -144,6 +144,7 @@ class nsAutoScriptBlockerSuppressNodeRemoved;
struct nsIntMargin;
class nsPIDOMWindow;
class nsIDocumentLoaderFactory;
class nsIDOMHTMLInputElement;
namespace mozilla {
@ -1109,7 +1110,7 @@ public:
* @param aPrincipal Prinicpal of the document. Must not be null.
* @param aScriptObject The object from which the context for event handling
* can be got.
* @param aSVGDocument Force SVG Document creation.
* @param aFlavor Select the kind of document to create.
* @param aResult [out] The document that was created.
*/
static nsresult CreateDocument(const nsAString& aNamespaceURI,
@ -1119,7 +1120,7 @@ public:
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
nsIScriptGlobalObject* aScriptObject,
bool aSVGDocument,
DocumentFlavor aFlavor,
nsIDOMDocument** aResult);
/**
@ -1848,6 +1849,17 @@ public:
static nsresult Atob(const nsAString& aAsciiString,
nsAString& aBinaryData);
/**
* Returns whether the input element passed in parameter has the autocomplete
* functionnality enabled. It is taking into account the form owner.
* NOTE: the caller has to make sure autocomplete makes sense for the
* element's type.
*
* @param aInput the input element to check. NOTE: aInput can't be null.
* @return whether the input element has autocomplete enabled.
*/
static bool IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput);
private:
static bool InitializeEventTable();

View File

@ -130,6 +130,13 @@ class Element;
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
// Enum for requesting a particular type of document when creating a doc
enum DocumentFlavor {
DocumentFlavorLegacyGuess, // compat with old code until made HTML5-compliant
DocumentFlavorHTML, // HTMLDocument with HTMLness bit set to true
DocumentFlavorSVG // SVGDocument
};
// Document states
// RTL locale: specific to the XUL localedir attribute
@ -1891,7 +1898,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
nsIPrincipal* aPrincipal,
bool aLoadedAsData,
nsIScriptGlobalObject* aEventObject,
bool aSVGDocument);
DocumentFlavor aFlavor);
// This is used only for xbl documents created from the startup cache.
// Non-cached documents are created in the same manner as xml documents.

View File

@ -178,6 +178,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "nsICategoryManager.h"
#include "nsIViewManager.h"
#include "nsEventStateManager.h"
#include "nsIDOMHTMLInputElement.h"
#ifdef IBMBIDI
#include "nsIBidiKeyboard.h"
@ -649,6 +650,27 @@ nsContentUtils::Atob(const nsAString& aAsciiBase64String,
return rv;
}
bool
nsContentUtils::IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput)
{
NS_PRECONDITION(aInput, "aInput should not be null!");
nsAutoString autocomplete;
aInput->GetAutocomplete(autocomplete);
if (autocomplete.IsEmpty()) {
nsCOMPtr<nsIDOMHTMLFormElement> form;
aInput->GetForm(getter_AddRefs(form));
if (!form) {
return true;
}
form->GetAutocomplete(autocomplete);
}
return autocomplete.EqualsLiteral("on");
}
/**
* Access a cached parser service. Don't addref. We need only one
* reference to it and this class has that one.
@ -3706,12 +3728,12 @@ nsContentUtils::CreateDocument(const nsAString& aNamespaceURI,
nsIURI* aDocumentURI, nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
nsIScriptGlobalObject* aEventObject,
bool aSVGDocument,
DocumentFlavor aFlavor,
nsIDOMDocument** aResult)
{
nsresult rv = NS_NewDOMDocument(aResult, aNamespaceURI, aQualifiedName,
aDoctype, aDocumentURI, aBaseURI, aPrincipal,
true, aEventObject, aSVGDocument);
true, aEventObject, aFlavor);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document = do_QueryInterface(*aResult);

View File

@ -188,7 +188,9 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(), nsnull,
mDocumentURI, mBaseURI,
mOriginalPrincipal,
scriptHandlingObject, svg,
scriptHandlingObject,
svg ? DocumentFlavorSVG :
DocumentFlavorLegacyGuess,
getter_AddRefs(domDocument));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -1447,7 +1447,9 @@ nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
return nsContentUtils::CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
scriptHandlingObject, false, aReturn);
scriptHandlingObject,
DocumentFlavorLegacyGuess,
aReturn);
}
NS_IMETHODIMP
@ -1479,7 +1481,8 @@ nsDOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(),
doctype, mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
scriptHandlingObject, false,
scriptHandlingObject,
DocumentFlavorLegacyGuess,
getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);

View File

@ -259,7 +259,6 @@ GK_ATOM(crop, "crop")
GK_ATOM(crossorigin, "crossorigin")
GK_ATOM(curpos, "curpos")
GK_ATOM(current, "current")
GK_ATOM(currentloop, "currentloop")
GK_ATOM(cycler, "cycler")
GK_ATOM(data, "data")
GK_ATOM(datalist, "datalist")
@ -533,8 +532,6 @@ GK_ATOM(localName, "local-name")
GK_ATOM(longdesc, "longdesc")
#ifdef MOZ_MEDIA
GK_ATOM(loop, "loop")
GK_ATOM(loopend, "loopend")
GK_ATOM(loopstart, "loopstart")
#endif
GK_ATOM(low, "low")
GK_ATOM(lowerFirst, "lower-first")
@ -781,14 +778,10 @@ GK_ATOM(percent, "percent")
GK_ATOM(persist, "persist")
GK_ATOM(phase, "phase")
GK_ATOM(ping, "ping")
#ifdef MOZ_MEDIA
GK_ATOM(pixelratio, "pixelratio")
#endif
GK_ATOM(placeholder, "placeholder")
GK_ATOM(plaintext, "plaintext")
#ifdef MOZ_MEDIA
GK_ATOM(playbackrate, "playbackrate")
GK_ATOM(playcount, "playcount")
#endif
GK_ATOM(pointSize, "point-size")
GK_ATOM(poly, "poly")

View File

@ -244,8 +244,6 @@ nsIAtom** const kAttributesHTML[] = {
&nsGkAtoms::longdesc,
#ifdef MOZ_MEDIA
&nsGkAtoms::loop,
&nsGkAtoms::loopend,
&nsGkAtoms::loopstart,
#endif
&nsGkAtoms::low,
&nsGkAtoms::max,
@ -263,13 +261,9 @@ nsIAtom** const kAttributesHTML[] = {
&nsGkAtoms::open,
&nsGkAtoms::optimum,
&nsGkAtoms::pattern,
#ifdef MOZ_MEDIA
&nsGkAtoms::pixelratio,
#endif
&nsGkAtoms::placeholder,
#ifdef MOZ_MEDIA
&nsGkAtoms::playbackrate,
&nsGkAtoms::playcount,
#endif
&nsGkAtoms::pointSize,
#ifdef MOZ_MEDIA

View File

@ -70,7 +70,6 @@
#include "nsCExternalHandlerService.h"
#include "nsIVariant.h"
#include "xpcprivate.h"
#include "nsIParser.h"
#include "XPCQuickStubs.h"
#include "nsStringStream.h"
#include "nsIStreamConverterService.h"
@ -156,6 +155,8 @@ using namespace mozilla;
#define NS_PROGRESS_EVENT_INTERVAL 50
NS_IMPL_ISUPPORTS1(nsXHRParseEndListener, nsIDOMEventListener)
class nsResumeTimeoutsEvent : public nsRunnable
{
public:
@ -431,7 +432,11 @@ nsXMLHttpRequest::nsXMLHttpRequest()
mUploadProgress(0), mUploadProgressMax(0),
mErrorLoad(false), mTimerIsActive(false),
mProgressEventWasDelayed(false),
mLoadLengthComputable(false), mLoadTotal(0),
mLoadLengthComputable(false),
mIsHtml(false),
mWarnAboutMultipartHtml(false),
mWarnAboutSyncHtml(false),
mLoadTotal(0),
mFirstStartRequestSeen(false),
mInLoadProgressEvent(false),
mResultJSON(JSVAL_VOID),
@ -721,7 +726,34 @@ nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
*aResponseXML = mResponseXML;
NS_ADDREF(*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());
}
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());
}
return NS_OK;
}
@ -852,7 +884,7 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
// We only decode text lazily if we're also parsing to a doc.
// Also, if we've decoded all current data already, then no need to decode
// more.
if (!mResponseXML ||
if (IsWaitingForHTMLCharset() || !mResponseXML ||
mResponseBodyDecodedPos == mResponseBody.Length()) {
aResponseText = mResponseText;
return NS_OK;
@ -1441,6 +1473,16 @@ nsXMLHttpRequest::IsSystemXHR()
return !!nsContentUtils::IsSystemPrincipal(mPrincipal);
}
bool
nsXMLHttpRequest::IsWaitingForHTMLCharset()
{
if (!mIsHtml) {
return false;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mResponseXML);
return doc->GetDocumentCharacterSetSource() < kCharsetFromDocTypeDefault;
}
nsresult
nsXMLHttpRequest::CheckChannelForCrossSiteRequest(nsIChannel* aChannel)
{
@ -1875,6 +1917,9 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
parseBody = !method.EqualsLiteral("HEAD");
}
mIsHtml = false;
mWarnAboutMultipartHtml = false;
mWarnAboutSyncHtml = false;
if (parseBody && NS_SUCCEEDED(status)) {
// We can gain a huge performance win by not even trying to
// parse non-XML data. This also protects us from the situation
@ -1883,7 +1928,30 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
nsCAutoString type;
channel->GetContentType(type);
if (type.Find("xml") == kNotFound) {
if (type.EqualsLiteral("text/html")) {
if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
// We don't make cool new features available in the bad synchronous
// mode. The synchronous mode is for legacy only.
mWarnAboutSyncHtml = true;
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
} else if (mState & XML_HTTP_REQUEST_MULTIPART) {
// HTML parsing is supported only for non-multipart responses. The
// multipart implementation assumes that it's OK to start the next part
// immediately after the last part. That doesn't work with the HTML
// parser, because when OnStopRequest for one part has fired, the
// parser thread still hasn't posted back the runnables that make the
// parsing appear finished.
//
// On the other hand, multipart support seems to be a legacy feature,
// so it isn't clear that use cases justify adding support for deferring
// the multipart stream events between parts to accommodate the
// asynchronous nature of the HTML parser.
mWarnAboutMultipartHtml = true;
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
} else {
mIsHtml = true;
}
} else if (type.Find("xml") == kNotFound) {
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
}
} else {
@ -1908,7 +1976,9 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
const nsAString& emptyStr = EmptyString();
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(mOwner);
rv = nsContentUtils::CreateDocument(emptyStr, emptyStr, nsnull, docURI,
baseURI, mPrincipal, global, false,
baseURI, mPrincipal, global,
mIsHtml ? DocumentFlavorHTML :
DocumentFlavorLegacyGuess,
getter_AddRefs(mResponseXML));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> responseDoc = do_QueryInterface(mResponseXML);
@ -1993,12 +2063,8 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
return NS_OK;
}
nsCOMPtr<nsIParser> parser;
// Is this good enough here?
if (mState & XML_HTTP_REQUEST_PARSEBODY && mXMLParserStreamListener) {
parser = do_QueryInterface(mXMLParserStreamListener);
NS_ABORT_IF_FALSE(parser, "stream listener was expected to be a parser");
mXMLParserStreamListener->OnStopRequest(request, ctxt, status);
}
@ -2007,8 +2073,11 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
mContext = nsnull;
// If we're received data since the last progress event, make sure to fire
// an event for it.
// an event for it, except in the HTML case, defer the last progress event
// until the parser is done.
if (!mIsHtml) {
MaybeDispatchProgressEvents(true);
}
nsCOMPtr<nsIChannel> channel(do_QueryInterface(request));
NS_ENSURE_TRUE(channel, NS_ERROR_UNEXPECTED);
@ -2053,9 +2122,6 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
mResponseXML = nsnull;
}
NS_ASSERTION(!parser || parser->IsParserEnabled(),
"Parser blocked somehow?");
// If we're uninitialized at this point, we encountered an error
// earlier and listeners have already been notified. Also we do
// not want to do this if we already completed.
@ -2064,18 +2130,42 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
return NS_OK;
}
if (!mResponseXML) {
ChangeStateToDone();
return NS_OK;
}
if (mIsHtml) {
NS_ASSERTION(!(mState & XML_HTTP_REQUEST_SYNCLOOPING),
"We weren't supposed to support HTML parsing with XHR!");
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(mResponseXML);
nsEventListenerManager* manager = eventTarget->GetListenerManager(true);
manager->AddEventListenerByType(new nsXHRParseEndListener(this),
NS_LITERAL_STRING("DOMContentLoaded"),
NS_EVENT_FLAG_BUBBLE |
NS_EVENT_FLAG_SYSTEM_EVENT);
return NS_OK;
}
// We might have been sent non-XML data. If that was the case,
// we should null out the document member. The idea in this
// check here is that if there is no document element it is not
// an XML document. We might need a fancier check...
if (mResponseXML) {
nsCOMPtr<nsIDOMElement> root;
mResponseXML->GetDocumentElement(getter_AddRefs(root));
if (!root) {
mResponseXML = nsnull;
}
}
ChangeStateToDone();
return NS_OK;
}
void
nsXMLHttpRequest::ChangeStateToDone()
{
if (mIsHtml) {
// In the HTML case, this has to be deferred, because the parser doesn't
// do it's job synchronously.
MaybeDispatchProgressEvents(true);
}
ChangeState(XML_HTTP_REQUEST_DONE, true);
NS_NAMED_LITERAL_STRING(errorStr, ERROR_STR);
@ -2101,8 +2191,6 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
// We're a multipart request, so we're not done. Reset to opened.
ChangeState(XML_HTTP_REQUEST_OPENED);
}
return NS_OK;
}
NS_IMETHODIMP
@ -3050,11 +3138,13 @@ nsXMLHttpRequest::MaybeDispatchProgressEvents(bool aFinalProgress)
mLoadTotal = mLoadTransferred;
mLoadLengthComputable = true;
}
if (aFinalProgress || !IsWaitingForHTMLCharset()) {
mInLoadProgressEvent = true;
DispatchProgressEvent(this, NS_LITERAL_STRING(PROGRESS_STR),
true, mLoadLengthComputable, mLoadTransferred,
mLoadTotal, mLoadTransferred, mLoadTotal);
mInLoadProgressEvent = false;
}
if (mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT ||
mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER) {
mResponseBody.Truncate();

View File

@ -123,6 +123,7 @@ class nsXMLHttpRequest : public nsXHREventTarget,
public nsIJSNativeInitializer,
public nsITimerCallback
{
friend class nsXHRParseEndListener;
public:
nsXMLHttpRequest();
virtual ~nsXMLHttpRequest();
@ -235,6 +236,10 @@ protected:
bool IsSystemXHR();
bool IsWaitingForHTMLCharset();
void ChangeStateToDone();
/**
* Check if aChannel is ok for a cross-site request by making sure no
* inappropriate headers are set, and no username/password is set.
@ -347,6 +352,9 @@ protected:
bool mTimerIsActive;
bool mProgressEventWasDelayed;
bool mLoadLengthComputable;
bool mIsHtml;
bool mWarnAboutMultipartHtml;
bool mWarnAboutSyncHtml;
PRUint64 mLoadTotal; // 0 if not known.
PRUint64 mLoadTransferred;
nsCOMPtr<nsITimer> mProgressNotifier;
@ -432,4 +440,24 @@ protected:
PRUint64 mMaxProgress;
};
class nsXHRParseEndListener : public nsIDOMEventListener
{
public:
NS_DECL_ISUPPORTS
NS_IMETHOD HandleEvent(nsIDOMEvent *event)
{
nsCOMPtr<nsIXMLHttpRequest> xhr = do_QueryReferent(mXHR);
if (xhr) {
static_cast<nsXMLHttpRequest*>(xhr.get())->ChangeStateToDone();
}
mXHR = nsnull;
return NS_OK;
}
nsXHRParseEndListener(nsIXMLHttpRequest* aXHR)
: mXHR(do_GetWeakReference(aXHR)) {}
virtual ~nsXHRParseEndListener() {}
private:
nsWeakPtr mXHR;
};
#endif

View File

@ -505,6 +505,12 @@ _TEST_FILES2 = \
somedatas.resource \
somedatas.resource^headers^ \
delayedServerEvents.sjs \
test_html_in_xhr.html \
file_html_in_xhr.html \
file_html_in_xhr2.html \
file_html_in_xhr3.html \
file_html_in_xhr.sjs \
file_html_in_xhr_slow.sjs \
test_bug664916.html \
test_bug666604.html \
test_bug675121.html \

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html><!-- Þ -->
<meta charset="Windows-1251">
<script>
document.documentElement.setAttribute("data-fail", "FAIL");
</script>
<script src="file_html_in_xhr.sjs"></script>
<script src="file_html_in_xhr.sjs" defer></script>
<script src="file_html_in_xhr.sjs" async></script>
<link type="stylesheet" href="file_html_in_xhr.sjs">
<body onload='document.documentElement.setAttribute("data-fail", "FAIL");'>
<img src="file_html_in_xhr.sjs">
<iframe src="file_html_in_xhr.sjs"></iframe>
<video poster="file_html_in_xhr.sjs" src="file_html_in_xhr.sjs"></video>
<object data="file_html_in_xhr.sjs"></object>
<noscript><div></div></noscript>

View File

@ -0,0 +1,15 @@
function handleRequest(request, response)
{
response.setHeader("Content-Type", "text/javascript", false);
if (request.queryString.indexOf("report") != -1) {
if (getState("loaded") == "loaded") {
response.write("ok(false, 'This script was not supposed to get fetched.'); continueAfterReport();");
} else {
response.write("ok(true, 'This script was not supposed to get fetched.'); continueAfterReport();");
}
} else {
setState("loaded", "loaded");
response.write('document.documentElement.setAttribute("data-fail", "FAIL");');
}
}

View File

@ -0,0 +1 @@
<meta charset="windows-1251">Þ

View File

@ -0,0 +1 @@
SUCCESS

View File

@ -0,0 +1,24 @@
var timer;
function handleRequest(request, response)
{
var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
converter.charset = "windows-1251";
var stream = converter.convertToInputStream("\u042E");
var out = response.bodyOutputStream;
response.setHeader("Cache-Control", "no-cache", false);
response.setHeader("Content-Type", "text/html", false);
out.writeFrom(stream, 1);
var firstPart = "<meta charset='windows";
out.write(firstPart, firstPart.length);
out.flush();
response.processAsync();
timer = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer);
timer.initWithCallback(function() {
response.write("-1251'>");
response.finish();
}, 500, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}

View File

@ -0,0 +1,113 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=651072
-->
<head>
<title>Test for Bug 651072</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload=runTest();>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=651072">Mozilla Bug 651072</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 651072 **/
SimpleTest.waitForExplicitFinish();
var xhr = new XMLHttpRequest();
function runTest() {
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
ok(this.responseXML, "Should have gotten responseXML");
is(this.responseXML.characterSet, "windows-1251", "Wrong character encoding");
is(this.responseXML.documentElement.firstChild.data, " \u042E ", "Decoded using the wrong encoding.");
is(this.responseText.indexOf("\u042E"), 27, "Bad responseText");
is(this.responseXML.getElementsByTagName("div").length, 1, "There should be one div.");
ok(!this.responseXML.documentElement.hasAttribute("data-fail"), "Should not have a data-fail attribute.");
var scripts = this.responseXML.getElementsByTagName("script");
is(scripts.length, 4, "Unexpected number of scripts.");
while (scripts.length) {
// These should not run when moved to another doc
document.body.appendChild(scripts[0]);
}
var s = document.createElement("script");
s.src = "file_html_in_xhr.sjs?report=1";
document.body.appendChild(s);
}
}
xhr.open("GET", "file_html_in_xhr.html", true);
xhr.send();
}
function continueAfterReport() {
ok(!document.documentElement.hasAttribute("data-fail"), "Should not have a data-fail attribute on mochitest doc.");
xhr = new XMLHttpRequest();
xhr.onprogress = function() {
ok(this.responseText, "Got falsy responseText");
if (this.responseText) {
ok(this.responseText.length, "Got zero-length responseText");
if (this.responseText.length) {
is(this.responseText.charCodeAt(0), 0x042E, "Wrong character encoding for slow text");
}
}
}
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
testNonParsingText();
}
}
xhr.open("GET", "file_html_in_xhr_slow.sjs");
xhr.send();
}
function testNonParsingText() {
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
is(this.responseText.indexOf("\u042E"), -1, "Honored meta in text mode.");
is(this.responseText.indexOf("\uFFFD"), 29, "Honored meta in text mode 2.");
testChunkedText();
}
}
xhr.open("GET", "file_html_in_xhr2.html");
xhr.responseType = "text";
xhr.send();
}
function testChunkedText() {
xhr = new XMLHttpRequest();
xhr.onprogress = function() {
is(this.responseText.indexOf("\u042E"), -1, "Honored meta in chunked text mode.");
}
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
testSyncXHR();
}
}
xhr.open("GET", "file_html_in_xhr2.html");
xhr.responseType = "moz-chunked-text";
xhr.send();
}
function testSyncXHR() {
xhr = new XMLHttpRequest();
xhr.open("GET", "file_html_in_xhr3.html", false);
xhr.send();
is(xhr.responseText, "SUCCESS\n", "responseText should be ready by now");
is(xhr.responseXML, null, "responseXML should be null in the sync case");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

View File

@ -396,6 +396,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
NS_IMPL_URI_ATTR(nsHTMLMediaElement, Src, src)
NS_IMPL_BOOL_ATTR(nsHTMLMediaElement, Controls, controls)
NS_IMPL_BOOL_ATTR(nsHTMLMediaElement, Autoplay, autoplay)
NS_IMPL_BOOL_ATTR(nsHTMLMediaElement, Loop, loop)
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLMediaElement, Preload, preload, NULL)
/* readonly attribute nsIDOMHTMLMediaElement mozAutoplayEnabled; */
@ -1422,12 +1423,6 @@ bool nsHTMLMediaElement::ParseAttribute(PRInt32 aNamespaceID,
};
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::loopstart ||
aAttribute == nsGkAtoms::loopend ||
aAttribute == nsGkAtoms::start ||
aAttribute == nsGkAtoms::end) {
return aResult.ParseDoubleValue(aValue);
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return true;
}
@ -2082,6 +2077,11 @@ void nsHTMLMediaElement::PlaybackEnded()
DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
}
if (HasAttr(kNameSpaceID_None, nsGkAtoms::loop)) {
SetCurrentTime(0);
return;
}
FireTimeUpdate(false);
DispatchAsyncEvent(NS_LITERAL_STRING("ended"));
}

View File

@ -699,7 +699,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
// TODO: Proper about:blank treatment is bug 543435
if (loadAsHtml5 && !viewSource) {
if (loadAsHtml5 && aCommand && !nsCRT::strcmp(aCommand, "view")) {
// mDocumentURI hasn't been set, yet, so get the URI from the channel
nsCOMPtr<nsIURI> uri;
aChannel->GetOriginalURI(getter_AddRefs(uri));
@ -771,9 +771,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
// and parentContentViewer
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
// No support yet for docshell-less HTML
NS_ENSURE_TRUE(docShell || !IsHTML(), NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
@ -810,9 +807,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
}
nsCAutoString scheme;
uri->GetScheme(scheme);
nsCAutoString urlSpec;
uri->GetSpec(urlSpec);
#ifdef DEBUG_charset
@ -830,8 +824,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
nsCOMPtr<nsIWyciwygChannel> wyciwygChannel;
if (!IsHTML()) {
charsetSource = kCharsetFromDocTypeDefault;
if (!IsHTML() || !docShell) { // no docshell for text/html XHR
charsetSource = IsHTML() ? kCharsetFromWeakDocTypeDefault
: kCharsetFromDocTypeDefault;
charset.AssignLiteral("UTF-8");
TryChannelCharset(aChannel, charsetSource, charset);
parserCharsetSource = charsetSource;
@ -946,6 +941,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
"not nsICachingChannel");
rv = cachingChan->SetCacheTokenCachedCharset(charset);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "cannot SetMetaDataElement");
rv = NS_OK; // don't propagate error
}
// Set the parser as the stream listener for the document loader...

View File

@ -121,6 +121,7 @@ _TEST_FILES = \
test_load.html \
test_load_candidates.html \
test_load_source.html \
test_loop.html \
test_media_selection.html \
test_mozLoadFrom.html \
test_networkState.html \

View File

@ -0,0 +1,56 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test looping support</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
var manager = new MediaTestManager;
function startTest(test, token) {
manager.started(token);
var v = document.createElement('video');
v.token = token;
v.src = test.name;
v.name = test.name;
v.playCount = 0;
v.seekingCount = 0;
v.seekedCount = 0;
v.loop = true;
v.addEventListener("play", function (e) {
e.target.playCount += 1;
ok(e.target.playCount == 1, "Should get exactly one play event.");
}, false);
v.addEventListener("seeking", function (e) {
e.target.seekingCount += 1;
}, false);
v.addEventListener("seeked", function (e) {
e.target.seekedCount += 1;
if (e.target.seekedCount == 3) {
ok(e.target.seekingCount == 3, "Expect matched pairs of seeking/seeked events.");
e.target.loop = false;
}
}, false);
v.addEventListener("ended", function (e) {
ok(!e.target.loop, "Shouldn't get ended event while looping.");
e.target.parentNode.removeChild(v);
manager.finished(e.target.token);
}, false);
document.body.appendChild(v);
v.play();
}
manager.runTests(gSmallTests, startTest);
</script>
</pre>
</body>
</html>

View File

@ -69,7 +69,7 @@ nsXBLProtoImplField::nsXBLProtoImplField(const PRUnichar* aName, const PRUnichar
}
nsXBLProtoImplField::nsXBLProtoImplField(bool aIsReadOnly)
nsXBLProtoImplField::nsXBLProtoImplField(const bool aIsReadOnly)
: mNext(nsnull),
mFieldText(nsnull),
mFieldTextLength(0),

View File

@ -55,7 +55,7 @@ public:
const PRUnichar* aSetter,
const PRUnichar* aReadOnly);
nsXBLProtoImplProperty(const PRUnichar* aName, bool aIsReadOnly);
nsXBLProtoImplProperty(const PRUnichar* aName, const bool aIsReadOnly);
virtual ~nsXBLProtoImplProperty();

View File

@ -105,7 +105,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
nsIPrincipal* aPrincipal,
bool aLoadedAsData,
nsIScriptGlobalObject* aEventObject,
bool aSVGDocument)
DocumentFlavor aFlavor)
{
// Note: can't require that aDocumentURI/aBaseURI/aPrincipal be non-null,
// since at least one caller (XMLHttpRequest) doesn't have decent args to
@ -118,8 +118,11 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
nsCOMPtr<nsIDocument> d;
bool isHTML = false;
bool isXHTML = false;
if (aSVGDocument) {
if (aFlavor == DocumentFlavorSVG) {
rv = NS_NewSVGDocument(getter_AddRefs(d));
} else if (aFlavor == DocumentFlavorHTML) {
rv = NS_NewHTMLDocument(getter_AddRefs(d));
isHTML = true;
} else if (aDoctype) {
nsAutoString publicId, name;
aDoctype->GetPublicId(publicId);
@ -229,7 +232,7 @@ NS_NewXBLDocument(nsIDOMDocument** aInstancePtrResult,
NS_LITERAL_STRING("http://www.mozilla.org/xbl"),
NS_LITERAL_STRING("bindings"), nsnull,
aDocumentURI, aBaseURI, aPrincipal, false,
nsnull, false);
nsnull, DocumentFlavorLegacyGuess);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> idoc = do_QueryInterface(*aInstancePtrResult);

View File

@ -113,7 +113,7 @@ NS_INTERFACE_MAP_BEGIN(Navigator)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigator)
NS_INTERFACE_MAP_ENTRY(nsIDOMClientInformation)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorGeolocation)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorBattery)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozNavigatorBattery)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorDesktopNotification)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Navigator)
NS_INTERFACE_MAP_END
@ -746,11 +746,25 @@ NS_IMETHODIMP Navigator::GetMozNotification(nsIDOMDesktopNotificationCenter** aR
//*****************************************************************************
NS_IMETHODIMP
Navigator::GetMozBattery(nsIDOMBatteryManager** aBattery)
Navigator::GetMozBattery(nsIDOMMozBatteryManager** aBattery)
{
if (!mBatteryManager) {
*aBattery = nsnull;
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(window, NS_OK);
nsCOMPtr<nsIDocument> document = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(document, NS_OK);
nsIScriptGlobalObject* sgo = document->GetScopeObject();
NS_ENSURE_TRUE(sgo, NS_OK);
nsIScriptContext* scx = sgo->GetContext();
NS_ENSURE_TRUE(scx, NS_OK);
mBatteryManager = new battery::BatteryManager();
mBatteryManager->Init();
mBatteryManager->Init(window->GetCurrentInnerWindow(), scx);
}
NS_ADDREF(*aBattery = mBatteryManager);

View File

@ -71,7 +71,7 @@ class Navigator : public nsIDOMNavigator,
public nsIDOMClientInformation,
public nsIDOMNavigatorGeolocation,
public nsIDOMNavigatorDesktopNotification,
public nsIDOMNavigatorBattery
public nsIDOMMozNavigatorBattery
{
public:
Navigator(nsIDocShell *aDocShell);
@ -82,7 +82,7 @@ public:
NS_DECL_NSIDOMCLIENTINFORMATION
NS_DECL_NSIDOMNAVIGATORGEOLOCATION
NS_DECL_NSIDOMNAVIGATORDESKTOPNOTIFICATION
NS_DECL_NSIDOMNAVIGATORBATTERY
NS_DECL_NSIDOMMOZNAVIGATORBATTERY
static void Init();

View File

@ -1385,7 +1385,7 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(BatteryManager, nsDOMGenericSH,
NS_DEFINE_CLASSINFO_DATA(MozBatteryManager, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
@ -2287,7 +2287,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMNavigatorDesktopNotification,
Navigator::HasDesktopNotificationSupport())
DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation)
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMNavigatorBattery,
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMMozNavigatorBattery,
battery::BatteryManager::HasSupport())
DOM_CLASSINFO_MAP_END
@ -3866,8 +3866,8 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionError)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(BatteryManager, nsIDOMBatteryManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBatteryManager)
DOM_CLASSINFO_MAP_BEGIN(MozBatteryManager, nsIDOMMozBatteryManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBatteryManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END

View File

@ -426,7 +426,7 @@ DOMCI_CLASS(GeoPositionCoords)
DOMCI_CLASS(GeoPositionAddress)
DOMCI_CLASS(GeoPositionError)
DOMCI_CLASS(BatteryManager)
DOMCI_CLASS(MozBatteryManager)
// @font-face in CSS
DOMCI_CLASS(CSSFontFaceRule)

View File

@ -52,7 +52,7 @@
#define DISCHARGINGTIMECHANGE_EVENT_NAME NS_LITERAL_STRING("dischargingtimechange")
#define CHARGINGTIMECHANGE_EVENT_NAME NS_LITERAL_STRING("chargingtimechange")
DOMCI_DATA(BatteryManager, mozilla::dom::battery::BatteryManager)
DOMCI_DATA(MozBatteryManager, mozilla::dom::battery::BatteryManager)
namespace mozilla {
namespace dom {
@ -61,26 +61,28 @@ namespace battery {
NS_IMPL_CYCLE_COLLECTION_CLASS(BatteryManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BatteryManager,
nsDOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLevelChangeListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnChargingChangeListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnDischargingTimeChangeListener)
nsDOMEventTargetWrapperCache)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(levelchange)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(chargingchange)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(chargingtimechange)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(dischargingtimechange)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BatteryManager,
nsDOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLevelChangeListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnChargingChangeListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnDischargingTimeChangeListener)
nsDOMEventTargetWrapperCache)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(levelchange)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(chargingchange)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(chargingtimechange)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(dischargingtimechange)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BatteryManager)
NS_INTERFACE_MAP_ENTRY(nsIDOMBatteryManager)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BatteryManager)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozBatteryManager)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozBatteryManager)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache)
NS_IMPL_ADDREF_INHERITED(BatteryManager, nsDOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(BatteryManager, nsDOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(BatteryManager, nsDOMEventTargetWrapperCache)
NS_IMPL_RELEASE_INHERITED(BatteryManager, nsDOMEventTargetWrapperCache)
BatteryManager::BatteryManager()
: mLevel(kDefaultLevel)
@ -97,8 +99,12 @@ BatteryManager::~BatteryManager()
}
void
BatteryManager::Init()
BatteryManager::Init(nsPIDOMWindow *aWindow, nsIScriptContext* aScriptContext)
{
// Those vars come from nsDOMEventTargetHelper.
mOwner = aWindow;
mScriptContext = aScriptContext;
hal::RegisterBatteryObserver(this);
hal::BatteryInformation* batteryInfo = new hal::BatteryInformation();
@ -157,61 +163,10 @@ BatteryManager::GetChargingTime(double* aChargingTime)
return NS_OK;
}
NS_IMETHODIMP
BatteryManager::GetOnlevelchange(nsIDOMEventListener** aOnlevelchange)
{
return GetInnerEventListener(mOnLevelChangeListener, aOnlevelchange);
}
NS_IMETHODIMP
BatteryManager::SetOnlevelchange(nsIDOMEventListener* aOnlevelchange)
{
return RemoveAddEventListener(LEVELCHANGE_EVENT_NAME, mOnLevelChangeListener,
aOnlevelchange);
}
NS_IMETHODIMP
BatteryManager::GetOnchargingchange(nsIDOMEventListener** aOnchargingchange)
{
return GetInnerEventListener(mOnChargingChangeListener, aOnchargingchange);
}
NS_IMETHODIMP
BatteryManager::SetOnchargingchange(nsIDOMEventListener* aOnchargingchange)
{
return RemoveAddEventListener(CHARGINGCHANGE_EVENT_NAME,
mOnChargingChangeListener, aOnchargingchange);
}
NS_IMETHODIMP
BatteryManager::GetOndischargingtimechange(nsIDOMEventListener** aOndischargingtimechange)
{
return GetInnerEventListener(mOnDischargingTimeChangeListener,
aOndischargingtimechange);
}
NS_IMETHODIMP
BatteryManager::SetOndischargingtimechange(nsIDOMEventListener* aOndischargingtimechange)
{
return RemoveAddEventListener(DISCHARGINGTIMECHANGE_EVENT_NAME,
mOnDischargingTimeChangeListener,
aOndischargingtimechange);
}
NS_IMETHODIMP
BatteryManager::GetOnchargingtimechange(nsIDOMEventListener** aOnchargingtimechange)
{
return GetInnerEventListener(mOnChargingTimeChangeListener,
aOnchargingtimechange);
}
NS_IMETHODIMP
BatteryManager::SetOnchargingtimechange(nsIDOMEventListener* aOnchargingtimechange)
{
return RemoveAddEventListener(CHARGINGTIMECHANGE_EVENT_NAME,
mOnChargingTimeChangeListener,
aOnchargingtimechange);
}
NS_IMPL_EVENT_HANDLER(BatteryManager, levelchange)
NS_IMPL_EVENT_HANDLER(BatteryManager, chargingchange)
NS_IMPL_EVENT_HANDLER(BatteryManager, chargingtimechange)
NS_IMPL_EVENT_HANDLER(BatteryManager, dischargingtimechange)
nsresult
BatteryManager::DispatchTrustedEventToSelf(const nsAString& aEventName)

View File

@ -39,11 +39,14 @@
#define mozilla_dom_battery_BatteryManager_h
#include "nsIDOMBatteryManager.h"
#include "nsDOMEventTargetHelper.h"
#include "nsDOMEventTargetWrapperCache.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/Observer.h"
#include "Types.h"
class nsPIDOMWindow;
class nsIScriptContext;
namespace mozilla {
namespace hal {
@ -53,26 +56,26 @@ class BatteryInformation;
namespace dom {
namespace battery {
class BatteryManager : public nsIDOMBatteryManager
, public nsDOMEventTargetHelper
class BatteryManager : public nsDOMEventTargetWrapperCache
, public nsIDOMMozBatteryManager
, public BatteryObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMBATTERYMANAGER
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
NS_DECL_NSIDOMMOZBATTERYMANAGER
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetWrapperCache::)
BatteryManager();
virtual ~BatteryManager();
void Init();
void Init(nsPIDOMWindow *aWindow, nsIScriptContext* aScriptContext);
void Shutdown();
// For IObserver.
void Notify(const hal::BatteryInformation& aBatteryInfo);
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BatteryManager,
nsDOMEventTargetHelper)
nsDOMEventTargetWrapperCache)
/**
* Returns whether the battery api is supported (ie. not disabled by the user)
@ -101,10 +104,10 @@ private:
*/
double mRemainingTime;
nsRefPtr<nsDOMEventListenerWrapper> mOnLevelChangeListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnChargingChangeListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnDischargingTimeChangeListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnChargingTimeChangeListener;
NS_DECL_EVENT_HANDLER(levelchange);
NS_DECL_EVENT_HANDLER(chargingchange);
NS_DECL_EVENT_HANDLER(chargingtimechange);
NS_DECL_EVENT_HANDLER(dischargingtimechange);
};
} // namespace battery

View File

@ -38,8 +38,8 @@
interface nsIDOMEventListener;
[scriptable, function, uuid(6dcb803b-e968-4c02-88f5-049a3f2a2efb)]
interface nsIDOMBatteryManager : nsIDOMEventTarget
[scriptable, function, uuid(98b6237b-9654-43de-97e0-acf4b091b4e7)]
interface nsIDOMMozBatteryManager : nsIDOMEventTarget
{
readonly attribute double level;
readonly attribute boolean charging;

View File

@ -36,10 +36,10 @@
#include "nsISupports.idl"
interface nsIDOMBatteryManager;
interface nsIDOMMozBatteryManager;
[scriptable, uuid(a19eedd7-6c26-4676-bd34-7ca74ca5f565)]
interface nsIDOMNavigatorBattery : nsISupports
[scriptable, uuid(c295f049-be3d-4f83-9f7c-5c3e91d6ecb9)]
interface nsIDOMMozNavigatorBattery : nsISupports
{
readonly attribute nsIDOMBatteryManager mozBattery;
readonly attribute nsIDOMMozBatteryManager mozBattery;
};

View File

@ -14,6 +14,12 @@
/** Test for Battery API **/
// Testing prefixing.
ok(!("NavigatorBattery" in window), "NavigatorBattery shouldn't be visible");
ok(("MozNavigatorBattery" in window), "MozNavigatorBattery should be visible");
ok(!("BatteryManager" in window), "BatteryManager shouldn't be visible");
ok(("MozBatteryManager" in window), "MozBatteryManager should be visible");
ok('mozBattery' in navigator, "navigator.mozBattery should exist");
var battery = navigator.mozBattery;

View File

@ -57,7 +57,7 @@
#endif
%}
[scriptable, uuid(642a3b85-4edb-4c01-a162-06b5d88171e7)]
[scriptable, uuid(f6eddb8a-7480-4b15-af2c-cc6ce9a7c140)]
interface nsIDOMHTMLMediaElement : nsIDOMHTMLElement
{
// error state
@ -94,6 +94,7 @@ interface nsIDOMHTMLMediaElement : nsIDOMHTMLElement
readonly attribute boolean ended;
readonly attribute boolean mozAutoplayEnabled;
attribute boolean autoplay;
attribute boolean loop;
void play();
void pause();

View File

@ -115,3 +115,5 @@ nsIJSONEncodeDeprecatedWarning=nsIJSON.encode is deprecated. Please use JSON.st
nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDOMWindow instead.
InputEncodingWarning=Use of inputEncoding is deprecated.
GlobalStorageWarning=Use of globalStorage is deprecated. Please use localStorage instead.
HTMLMultipartXHRWarning=HTML parsing in XMLHttpRequest is not supported for multipart responses.
HTMLSyncXHRWarning=HTML parsing in XMLHttpRequest is not supported in the synchronous mode.

View File

@ -127,13 +127,15 @@ Nv3DVUtils::SetDeviceInfo(IUnknown *devUnknown)
bool rv = false;
rv = m3DVStreaming->Nv3DVSetDevice(devUnknown);
if (!rv) {
if (NS_FAILED(rv)) {
NS_WARNING("Nv3DVStreaming Nv3DVControl failed!");
return;
}
rv = m3DVStreaming->Nv3DVControl(NV_STEREO_MODE_RIGHT_LEFT, true, FIREFOX_3DV_APP_HANDLE);
NS_ASSERTION(rv, "Nv3DVStreaming Nv3DVControl failed!");
if (NS_FAILED(rv)) {
NS_WARNING("Nv3DVStreaming Nv3DVControl failed!");
}
}
/*

View File

@ -579,11 +579,10 @@ gfxUserFontSet::OnLoadComplete(gfxProxyFontEntry *aProxy,
}
// error occurred, load next src
LoadStatus status;
(void)LoadNext(aProxy);
status = LoadNext(aProxy);
// Even if loading failed, we need to bump the font-set generation
// We ignore the status returned by LoadNext();
// even if loading failed, we need to bump the font-set generation
// and return true in order to trigger reflow, so that fallback
// will be used where the text was "masked" by the pending download
IncrementGeneration();

View File

@ -42,6 +42,7 @@ DEPTH = ../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
relativesrcdir = js/jsd
include $(DEPTH)/config/autoconf.mk
@ -55,6 +56,7 @@ LIBXUL_LIBRARY = 1
MODULE_NAME = JavaScript_Debugger
EXPORT_LIBRARY = 1
XPCSHELL_TESTS = test
# REQUIRES = java js

View File

@ -0,0 +1,39 @@
// Bug 689101 - if the binary layout of jsval does not match between C and C++
// code, then calls to functions returning jsval may get compiled differently
// than the callee, resulting in parameters being shifted over by one.
//
// An example is where on Windows, calling jsdValue.getWrappedValue() will
// return a random floating point number instead of an object.
//
// This test must be run with debugging already enabled
function run_test() {
const Cc = Components.classes;
const Ci = Components.interfaces;
const DebuggerService = Cc["@mozilla.org/js/jsd/debugger-service;1"];
const jsdIDebuggerService = Ci.jsdIDebuggerService;
var jsd = DebuggerService.getService(jsdIDebuggerService);
do_check_true(jsd.isOn);
var n = 0;
function f() {
n++;
}
jsd.enumerateScripts({ enumerateScript: function(script) {
script.setBreakpoint(0);
} });
jsd.breakpointHook = function(frame, type, dummy) {
var scope = frame.scope;
var parent = scope.jsParent; // Probably does not need to be called
var wrapped = scope.getWrappedValue();
// Do not try to print 'wrapped'; it may be an internal Call object
// that will crash when you toString it. Different bug.
do_check_eq(typeof(wrapped), "object");
return Ci.jsdIExecutionHook.RETURN_CONTINUE;
};
f();
}

6
js/jsd/test/xpcshell.ini Normal file
View File

@ -0,0 +1,6 @@
[DEFAULT]
head =
tail =
[test_jsval_retval.js]
debug = 1

View File

@ -346,14 +346,14 @@ __BitScanReverse64(unsigned __int64 val)
# define js_FloorLog2wImpl(n) \
((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz32(n)))
# else
extern size_t js_FloorLog2wImpl(size_t n);
JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n);
# endif
#elif JS_BYTES_PER_WORD == 8
# ifdef JS_HAS_BUILTIN_BITSCAN64
# define js_FloorLog2wImpl(n) \
((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz64(n)))
# else
extern size_t js_FloorLog2wImpl(size_t n);
JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n);
# endif
#else
# error "NOT SUPPORTED"

View File

@ -1,14 +1,21 @@
// |jit-test| error: InternalError
// |jit-test| allow-oom;
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
const MAX = 10000;
var str = "";
for (var i = 0; i < MAX; ++i) {
try
{
const MAX = 10000;
var str = "";
for (var i = 0; i < MAX; ++i) {
/x/.test(str);
str += str + 'xxxxxxxxxxxxxx';
}
}
catch (e)
{
assertEq(""+e, "InternalError: allocation size overflow");
}
/* Don't crash */

View File

@ -552,12 +552,9 @@ DumpXPC(JSContext *cx, uintN argc, jsval *vp)
static JSBool
GC(JSContext *cx, uintN argc, jsval *vp)
{
JSRuntime *rt;
rt = cx->runtime;
JS_GC(cx);
#ifdef JS_GCMETER
js_DumpGCStats(rt, stdout);
js_DumpGCStats(cx->runtime, stdout);
#endif
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
@ -1236,6 +1233,9 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
case 'x':
JS_ToggleOptions(cx, JSOPTION_XML);
break;
case 'd':
xpc_ActivateDebugMode();
break;
case 'P':
if (JS_GET_CLASS(cx, JS_GetPrototype(cx, obj)) != &global_class) {
JSObject *gobj;

View File

@ -2719,7 +2719,6 @@ nsXPCComponents_Utils::LookupMethod()
return NS_ERROR_XPC_BAD_CONVERT_JS;
jsval funval;
JSFunction *oldfunction;
// get (and perhaps lazily create) the member's cloned function
if (!member->NewFunctionObject(inner_cc, iface,
@ -2727,8 +2726,8 @@ nsXPCComponents_Utils::LookupMethod()
&funval))
return NS_ERROR_XPC_BAD_CONVERT_JS;
oldfunction = JS_ValueToFunction(inner_cc, funval);
NS_ASSERTION(oldfunction, "Function is not a function");
NS_ASSERTION(JS_ValueToFunction(inner_cc, funval),
"Function is not a function");
// Stick the function in the return value. This roots it.
*retval = funval;

View File

@ -272,7 +272,7 @@ CompartmentCallback(JSContext *cx, JSCompartment *compartment, uintN op)
XPCCompartmentMap &map = self->GetCompartmentMap();
#ifdef DEBUG
{
JSCompartment *current = NULL; // init to shut GCC up
JSCompartment *current = NULL;
NS_ASSERTION(map.Get(key, &current), "no compartment?");
NS_ASSERTION(current == compartment, "compartment mismatch");
}

View File

@ -2278,7 +2278,7 @@ CallMethodHelper::~CallMethodHelper()
// Clean up the array contents if necessary.
if (dp->DoesValNeedCleanup()) {
// We need some basic information to properly destroy the array.
JSUint32 array_count;
JSUint32 array_count = 0;
nsXPTType datum_type;
if (!GetArraySizeFromParam(i, &array_count) ||
!NS_SUCCEEDED(mIFaceInfo->GetTypeForParam(mVTableIndex,
@ -2413,7 +2413,7 @@ CallMethodHelper::GatherAndConvertResults()
nsXPTCVariant* dp = GetDispatchParam(i);
jsval v = JSVAL_NULL;
AUTO_MARK_JSVAL(mCallContext, &v);
JSUint32 array_count;
JSUint32 array_count = 0;
nsXPTType datum_type;
bool isArray = type.IsArray();
bool isSizedString = isArray ?
@ -2738,7 +2738,7 @@ CallMethodHelper::ConvertDependentParams()
continue;
nsXPTType datum_type;
JSUint32 array_count;
JSUint32 array_count = 0;
bool isArray = type.IsArray();
bool isSizedString = isArray ?

View File

@ -267,7 +267,7 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
PRUint16 totalCount;
PRUint16 realTotalCount = 0;
XPCNativeMember* cur;
JSString* str;
JSString* str = NULL;
jsid name;
jsid interfaceName;

View File

@ -55,6 +55,7 @@ xpc_qsUnwrapThis<_interface>(JSContext *cx, \
nsISupports *native = castNativeFromWrapper(cx, obj, callee, _bit, \
pThisRef, pThisVal, lccx, \
&rv); \
*ppThis = NULL; /* avoids uninitialized warnings in callers */ \
if (failureFatal && !native) \
return xpc_qsThrow(cx, rv); \
*ppThis = static_cast<_interface*>(static_cast<_base*>(native)); \

View File

@ -2578,6 +2578,14 @@ fail:
gDesiredDebugMode = gDebugMode = JS_FALSE;
}
NS_EXPORT_(void)
xpc_ActivateDebugMode()
{
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
nsXPConnect::GetXPConnect()->SetDebugModeWhenPossible(true, true);
nsXPConnect::CheckForDebugMode(rt->GetJSRuntime());
}
/* JSContext Pop (); */
NS_IMETHODIMP
nsXPConnect::Pop(JSContext * *_retval)

View File

@ -595,6 +595,8 @@ public:
return gReportAllJSExceptions > 0;
}
static void CheckForDebugMode(JSRuntime *rt);
protected:
nsXPConnect();
@ -624,7 +626,6 @@ private:
static PRUint32 gReportAllJSExceptions;
static JSBool gDebugMode;
static JSBool gDesiredDebugMode;
static inline void CheckForDebugMode(JSRuntime *rt);
public:
static nsIScriptSecurityManager *gScriptSecurityManager;

View File

@ -182,6 +182,11 @@ xpc_UnmarkGrayObject(JSObject *obj)
xpc_UnmarkGrayObjectRecursive(obj);
}
// No JS can be on the stack when this is called. Probably only useful from
// xpcshell.
NS_EXPORT_(void)
xpc_ActivateDebugMode();
class nsIMemoryMultiReporterCallback;
namespace mozilla {

View File

@ -41,6 +41,12 @@
* `void*` and `void (*)()` may not be the same size on weird platforms, but
* the size of a function pointer shouldn't vary according to its parameters
* or return type.
*
* Apple's version of these structures, complete with member names and
* comments, is available online at
*
* http://www.opensource.apple.com/source/Libc/Libc-763.12/include/malloc/malloc.h
*
*/
/*

View File

@ -128,8 +128,10 @@ nsHtml5Parser::GetCommand(nsCString& aCommand)
NS_IMETHODIMP_(void)
nsHtml5Parser::SetCommand(const char* aCommand)
{
NS_ASSERTION(!strcmp(aCommand, "view") || !strcmp(aCommand, "view-source"),
"Parser command was not view");
NS_ASSERTION(!strcmp(aCommand, "view") ||
!strcmp(aCommand, "view-source") ||
!strcmp(aCommand, kLoadAsData),
"Unsupported parser command");
}
NS_IMETHODIMP_(void)
@ -712,6 +714,8 @@ nsHtml5Parser::MarkAsNotScriptCreated(const char* aCommand)
mode = VIEW_SOURCE_XML;
} else if (!nsCRT::strcmp(aCommand, "plain-text")) {
mode = PLAIN_TEXT;
} else if (!nsCRT::strcmp(aCommand, kLoadAsData)) {
mode = LOAD_AS_DATA;
}
#ifdef DEBUG
else {
@ -829,6 +833,9 @@ nsHtml5Parser::Initialize(nsIDocument* aDoc,
void
nsHtml5Parser::StartTokenizer(bool aScriptingEnabled) {
if (!aScriptingEnabled) {
mExecutor->PreventScriptExecution();
}
mTreeBuilder->setScriptingEnabled(aScriptingEnabled);
mTokenizer->start();
}

View File

@ -356,6 +356,10 @@ void
nsHtml5StreamParser::SniffBOMlessUTF16BasicLatin(const PRUint8* aFromSegment,
PRUint32 aCountToSniffingLimit)
{
// Avoid underspecified heuristic craziness for XHR
if (mMode == LOAD_AS_DATA) {
return;
}
// Make sure there's enough data. Require room for "<title></title>"
if (mSniffingLength + aCountToSniffingLimit < 30) {
return;
@ -609,6 +613,15 @@ nsHtml5StreamParser::FinalizeSniffing(const PRUint8* aFromSegment, // can be nul
mCharset.AssignLiteral("windows-1252");
mCharsetSource = kCharsetFromWeakDocTypeDefault;
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
} else if (mMode == LOAD_AS_DATA &&
mCharsetSource == kCharsetFromWeakDocTypeDefault) {
NS_ASSERTION(mReparseForbidden, "Reparse should be forbidden for XHR");
NS_ASSERTION(!mFeedChardet, "Should not feed chardet for XHR");
NS_ASSERTION(mCharset.EqualsLiteral("UTF-8"),
"XHR should default to UTF-8");
// Now mark charset source as non-weak to signal that we have a decision
mCharsetSource = kCharsetFromDocTypeDefault;
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
}
return SetupDecodingAndWriteSniffingBufferAndCurrentSegment(aFromSegment, aCount, aWriteCount);
}
@ -690,7 +703,9 @@ nsHtml5StreamParser::SniffStreamBytes(const PRUint8* aFromSegment,
}
// if we get here, there either was no BOM or the BOM sniffing isn't complete yet
if (!mMetaScanner && (mMode == NORMAL || mMode == VIEW_SOURCE_HTML)) {
if (!mMetaScanner && (mMode == NORMAL ||
mMode == VIEW_SOURCE_HTML ||
mMode == LOAD_AS_DATA)) {
mMetaScanner = new nsHtml5MetaScanner();
}
@ -698,7 +713,7 @@ nsHtml5StreamParser::SniffStreamBytes(const PRUint8* aFromSegment,
// this is the last buffer
PRUint32 countToSniffingLimit =
NS_HTML5_STREAM_PARSER_SNIFFING_BUFFER_SIZE - mSniffingLength;
if (mMode == NORMAL || mMode == VIEW_SOURCE_HTML) {
if (mMode == NORMAL || mMode == VIEW_SOURCE_HTML || mMode == LOAD_AS_DATA) {
nsHtml5ByteReadable readable(aFromSegment, aFromSegment +
countToSniffingLimit);
mMetaScanner->sniff(&readable, getter_AddRefs(mUnicodeDecoder), mCharset);
@ -719,7 +734,7 @@ nsHtml5StreamParser::SniffStreamBytes(const PRUint8* aFromSegment,
}
// not the last buffer
if (mMode == NORMAL || mMode == VIEW_SOURCE_HTML) {
if (mMode == NORMAL || mMode == VIEW_SOURCE_HTML || mMode == LOAD_AS_DATA) {
nsHtml5ByteReadable readable(aFromSegment, aFromSegment + aCount);
mMetaScanner->sniff(&readable, getter_AddRefs(mUnicodeDecoder), mCharset);
if (mUnicodeDecoder) {
@ -869,7 +884,8 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
}
// For View Source, the parser should run with scripts "enabled" if a normal
// load would have scripts enabled.
bool scriptingEnabled = mExecutor->IsScriptEnabled();
bool scriptingEnabled = mMode == LOAD_AS_DATA ?
false : mExecutor->IsScriptEnabled();
mOwner->StartTokenizer(scriptingEnabled);
mTreeBuilder->setScriptingEnabled(scriptingEnabled);
mTokenizer->start();

View File

@ -79,7 +79,12 @@ enum eParserMode {
/**
* View document as plain text
*/
PLAIN_TEXT
PLAIN_TEXT,
/**
* Load as data (XHR)
*/
LOAD_AS_DATA
};
enum eBomState {

View File

@ -735,10 +735,10 @@ nsHtml5TreeOpExecutor::RunScript(nsIContent* aScriptElement)
return;
}
if (mFragmentMode) {
if (mPreventScriptExecution) {
sele->PreventExecution();
}
if (mFragmentMode) {
return;
}

View File

@ -153,7 +153,7 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
*
*/
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) {
NS_ASSERTION(GetDocument()->GetScriptGlobalObject(),
NS_ASSERTION(!mDocShell || GetDocument()->GetScriptGlobalObject(),
"Script global object not ready");
mDocument->AddObserver(this);
WillBuildModelImpl();
@ -253,6 +253,10 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
mPreventScriptExecution = aPreventScriptExecution;
}
void PreventScriptExecution() {
mPreventScriptExecution = true;
}
bool IsFragmentMode() {
return mFragmentMode;
}

View File

@ -91,7 +91,7 @@ enum eParserDocType {
#define kCharsetUninitialized 0
#define kCharsetFromWeakDocTypeDefault 1
#define kCharsetFromUserDefault 2
#define kCharsetFromDocTypeDefault 3
#define kCharsetFromDocTypeDefault 3 // This and up confident for XHR
#define kCharsetFromCache 4
#define kCharsetFromParentFrame 5
#define kCharsetFromAutoDetection 6

View File

@ -499,11 +499,15 @@ class XPCShellTests(object):
# The test file will have to be loaded after the head files.
cmdT = self.buildCmdTestFile(name)
args = self.xpcsRunArgs
if 'debug' in test:
args.insert(0, '-d')
try:
self.log.info("TEST-INFO | %s | running test ..." % name)
startTime = time.time()
proc = self.launchProcess(cmdH + cmdT + self.xpcsRunArgs,
proc = self.launchProcess(cmdH + cmdT + args,
stdout=pStdout, stderr=pStderr, env=self.env, cwd=testdir)
# Allow user to kill hung subprocess with SIGINT w/o killing this script

View File

@ -48,6 +48,7 @@ skip-if = os == "android"
[include:netwerk/test/httpserver/test/xpcshell.ini]
[include:js/ductwork/debugger/tests/xpcshell.ini]
[include:js/jetpack/tests/unit/xpcshell.ini]
[include:js/jsd/test/xpcshell.ini]
[include:js/xpconnect/tests/unit/xpcshell.ini]
[include:modules/libjar/test/unit/xpcshell.ini]
[include:extensions/cookie/test/unit/xpcshell.ini]

View File

@ -71,6 +71,7 @@
#include "nsIDOMNSEditableElement.h"
#include "nsIDOMNSEvent.h"
#include "mozilla/dom/Element.h"
#include "nsContentUtils.h"
NS_IMPL_ISUPPORTS5(nsFormFillController,
nsIFormFillController,
@ -573,7 +574,8 @@ nsFormFillController::StartSearch(const nsAString &aSearchString, const nsAStrin
getter_AddRefs(result));
} else {
nsCOMPtr<nsIAutoCompleteResult> formHistoryResult;
if (!IsInputAutoCompleteOff()) {
if (mFocusedInput && nsContentUtils::IsAutocompleteEnabled(mFocusedInput)) {
nsCOMPtr <nsIFormAutoComplete> formAutoComplete =
do_GetService("@mozilla.org/satchel/form-autocomplete;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
@ -759,8 +761,11 @@ nsFormFillController::Focus(nsIDOMEvent* aEvent)
bool isReadOnly = false;
input->GetReadOnly(&isReadOnly);
nsAutoString autocomplete;
input->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
bool autocomplete = nsContentUtils::IsAutocompleteEnabled(input);
nsCOMPtr<nsIDOMHTMLElement> datalist;
input->GetList(getter_AddRefs(datalist));
bool hasList = datalist != nsnull;
PRInt32 dummy;
bool isPwmgrInput = false;
@ -768,39 +773,15 @@ nsFormFillController::Focus(nsIDOMEvent* aEvent)
isPwmgrInput = true;
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(input);
if (formControl && formControl->IsSingleLineTextControl(true) &&
!isReadOnly || isPwmgrInput) {
if (isPwmgrInput || (formControl &&
formControl->IsSingleLineTextControl(PR_TRUE) &&
(hasList || autocomplete) && !isReadOnly)) {
StartControllingInput(input);
}
return NS_OK;
}
bool
nsFormFillController::IsInputAutoCompleteOff()
{
bool autoCompleteOff = false;
if (mFocusedInput) {
nsAutoString autocomplete;
mFocusedInput->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
// Check the input for autocomplete="off", then the form
if (autocomplete.LowerCaseEqualsLiteral("off")) {
autoCompleteOff = true;
} else {
nsCOMPtr<nsIDOMHTMLFormElement> form;
mFocusedInput->GetForm(getter_AddRefs(form));
if (form)
form->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
autoCompleteOff = autocomplete.LowerCaseEqualsLiteral("off");
}
}
return autoCompleteOff;
}
nsresult
nsFormFillController::KeyPress(nsIDOMEvent* aEvent)
{

View File

@ -104,7 +104,6 @@ protected:
PRInt32& aEntry,
void* aUserData);
bool IsEventTrusted(nsIDOMEvent *aEvent);
bool IsInputAutoCompleteOff();
// members //////////////////////////////////////////
nsCOMPtr<nsIAutoCompleteController> mController;

View File

@ -126,7 +126,7 @@ var popupTests = [
is(Math.round(rect.left),
Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6),
testname + " top position of tooltip");
testname + " left position of tooltip");
is(Math.round(rect.top),
Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6),
testname + " top position of tooltip");
@ -176,7 +176,7 @@ var popupTests = [
is(Math.round(rect.left),
Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 4),
testname + " top position of tooltip");
testname + " left position of tooltip");
is(Math.round(rect.top),
Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 4),
testname + " top position of tooltip");
@ -221,7 +221,7 @@ var popupTests = [
is(Math.round(rect.left),
Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6),
testname + " top position of tooltip");
testname + " left position of tooltip");
is(Math.round(rect.top),
Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6),
testname + " top position of tooltip");

View File

@ -64,7 +64,7 @@ extern void jemalloc_stats(jemalloc_stats_t* stats)
# endif // XP_LINUX
#endif // MOZ_MEMORY
#if defined(XP_LINUX) || defined(XP_MACOSX)
#if defined(XP_LINUX) || defined(XP_MACOSX) || defined(SOLARIS)
#include <sys/time.h>
#include <sys/resource.h>
@ -122,6 +122,52 @@ static PRInt64 GetResident()
return GetProcSelfStatmField(1);
}
#elif defined(SOLARIS)
#include <procfs.h>
#include <fcntl.h>
#include <unistd.h>
static void XMappingIter(PRInt64& Vsize, PRInt64& Resident)
{
int mapfd = open("/proc/self/xmap", O_RDONLY);
struct stat st;
prxmap_t *prmapp;
if (mapfd >= 0) {
if (!fstat(mapfd, &st)) {
int nmap = st.st_size / sizeof(prxmap_t);
prmapp = (prxmap_t*)malloc((nmap + 1) * sizeof(prxmap_t));
int n = read(mapfd, prmapp, (nmap + 1) * sizeof(prxmap_t));
if (n > 0) {
Vsize = 0;
Resident = 0;
for (int i = 0; i < n / sizeof(prxmap_t); i++) {
Vsize += prmapp[i].pr_size;
Resident += prmapp[i].pr_rss * prmapp[i].pr_pagesize;
}
}
free(prmapp);
}
close(mapfd);
}
}
static PRInt64 GetVsize()
{
PRInt64 Vsize = -1;
PRInt64 Resident = -1;
XMappingIter(Vsize, Resident);
return Vsize;
}
static PRInt64 GetResident()
{
PRInt64 Vsize = -1;
PRInt64 Resident = -1;
XMappingIter(Vsize, Resident);
return Resident;
}
#elif defined(XP_MACOSX)
#include <mach/mach_init.h>
@ -224,7 +270,7 @@ static PRInt64 GetResident()
#endif
#if defined(XP_LINUX) || defined(XP_MACOSX) || defined(XP_WIN)
#if defined(XP_LINUX) || defined(XP_MACOSX) || defined(XP_WIN) || defined(SOLARIS)
NS_MEMORY_REPORTER_IMPLEMENT(Vsize,
"vsize",
KIND_OTHER,
@ -239,7 +285,7 @@ NS_MEMORY_REPORTER_IMPLEMENT(Vsize,
"measure of the memory resources used by the process.")
#endif
#if defined(XP_LINUX) || defined(XP_MACOSX)
#if defined(XP_LINUX) || defined(XP_MACOSX) || defined(SOLARIS)
NS_MEMORY_REPORTER_IMPLEMENT(PageFaultsSoft,
"page-faults-soft",
KIND_OTHER,
@ -457,11 +503,11 @@ nsMemoryReporterManager::Init()
REGISTER(HeapUnallocated);
REGISTER(Resident);
#if defined(XP_LINUX) || defined(XP_MACOSX) || defined(XP_WIN)
#if defined(XP_LINUX) || defined(XP_MACOSX) || defined(XP_WIN) || defined(SOLARIS)
REGISTER(Vsize);
#endif
#if defined(XP_LINUX) || defined(XP_MACOSX)
#if defined(XP_LINUX) || defined(XP_MACOSX) || defined(SOLARIS)
REGISTER(PageFaultsSoft);
REGISTER(PageFaultsHard);
#endif