Merge mozilla-central to mozilla-inbound

This commit is contained in:
Ed Morley 2012-05-05 12:57:25 +01:00
Родитель 1ed89209e6 105571263a
Коммит f9aab60a10
127 изменённых файлов: 2756 добавлений и 1761 удалений

Просмотреть файл

@ -344,7 +344,7 @@ let TestPilotSetup = {
appcontent.addEventListener("DOMContentLoaded", function(event) {
let newUrl = event.originalTarget.URL;
self._feedbackManager.fillInFeedbackPage(newUrl, window);
for (i = 0; i < self.taskList.length; i++) {
for (let i = 0; i < self.taskList.length; i++) {
self.taskList[i].onUrlLoad(newUrl, event);
}
}, true);

Просмотреть файл

@ -363,10 +363,7 @@ JSContext *
nsScriptSecurityManager::GetSafeJSContext()
{
// Get JSContext from stack.
JSContext *cx;
if (NS_FAILED(sJSContextStack->GetSafeJSContext(&cx)))
return nsnull;
return cx;
return sJSContextStack->GetSafeJSContext();
}
/* static */

Просмотреть файл

@ -1675,8 +1675,7 @@ nsContentUtils::TraceSafeJSContext(JSTracer* aTrc)
if (!sThreadJSContextStack) {
return;
}
JSContext* cx = nsnull;
sThreadJSContextStack->GetSafeJSContext(&cx);
JSContext* cx = sThreadJSContextStack->GetSafeJSContext();
if (!cx) {
return;
}

Просмотреть файл

@ -3863,7 +3863,7 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
if (!cx) {
nsContentUtils::ThreadJSContextStack()->Peek(&cx);
if (!cx) {
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
NS_ASSERTION(cx, "Uhoh, no context, this is bad!");
}
}
@ -6072,7 +6072,7 @@ GetContextAndScope(nsIDocument* aOldDocument, nsIDocument* aNewDocument,
stack->Peek(&cx);
if (!cx) {
stack->GetSafeJSContext(&cx);
cx = stack->GetSafeJSContext();
if (!cx) {
// No safe context reachable, bail.

Просмотреть файл

@ -379,7 +379,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
{
JSContext* ctx = mContext ? mContext : aContext;
if (!ctx) {
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&ctx);
ctx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
}
if (mListeners.Length()) {
nsCOMPtr<nsIAtom> name = do_GetAtom(aMessage);
@ -723,8 +723,7 @@ void
nsFrameScriptExecutor::Shutdown()
{
if (sCachedScripts) {
JSContext* cx = nsnull;
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
JSContext* cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
if (cx) {
#ifdef DEBUG_smaug
printf("Will clear cached frame manager scripts!\n");

Просмотреть файл

@ -71,6 +71,7 @@ GK_ATOM(mozeditorbogusnode, "_moz_editor_bogus_node")
GK_ATOM(mozgeneratedcontentbefore, "_moz_generated_content_before")
GK_ATOM(mozgeneratedcontentafter, "_moz_generated_content_after")
GK_ATOM(mozgeneratedcontentimage, "_moz_generated_content_image")
GK_ATOM(mozquote, "_moz_quote")
GK_ATOM(_moz_original_size, "_moz_original_size")
GK_ATOM(_moz_target, "_moz_target")
GK_ATOM(_moz_type, "_moz-type")

Просмотреть файл

@ -134,8 +134,7 @@ nsEventListenerInfo::ToSource(nsAString& aResult)
nsCOMPtr<nsIThreadJSContextStack> stack =
nsContentUtils::ThreadJSContextStack();
if (stack) {
JSContext* cx = nsnull;
stack->GetSafeJSContext(&cx);
JSContext* cx = stack->GetSafeJSContext();
if (cx && NS_SUCCEEDED(stack->Push(cx))) {
{
// Extra block to finish the auto request before calling pop
@ -177,8 +176,7 @@ nsEventListenerInfo::GetDebugObject(nsISupports** aRetVal)
nsCOMPtr<nsIThreadJSContextStack> stack =
nsContentUtils::ThreadJSContextStack();
if (stack) {
JSContext* cx = nsnull;
stack->GetSafeJSContext(&cx);
JSContext* cx = stack->GetSafeJSContext();
if (cx && NS_SUCCEEDED(stack->Push(cx))) {
{
// Extra block to finish the auto request before calling pop

Просмотреть файл

@ -134,10 +134,6 @@ nsHTMLFontElement::ParseAttribute(PRInt32 aNamespaceID,
}
return false;
}
if (aAttribute == nsGkAtoms::pointSize ||
aAttribute == nsGkAtoms::fontWeight) {
return aResult.ParseIntValue(aValue);
}
if (aAttribute == nsGkAtoms::color) {
return aResult.ParseColor(aValue);
}
@ -162,28 +158,14 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
}
}
// pointSize: int
// size: int
nsCSSValue* fontSize = aData->ValueForFontSize();
if (fontSize->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::pointSize);
if (value && value->Type() == nsAttrValue::eInteger)
fontSize->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Point);
else {
// size: int
value = aAttributes->GetAttr(nsGkAtoms::size);
if (value && value->Type() == nsAttrValue::eInteger) {
fontSize->SetIntValue(value->GetIntegerValue(), eCSSUnit_Enumerated);
}
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
if (value && value->Type() == nsAttrValue::eInteger) {
fontSize->SetIntValue(value->GetIntegerValue(), eCSSUnit_Enumerated);
}
}
// fontWeight: int
nsCSSValue* fontWeight = aData->ValueForFontWeight();
if (fontWeight->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::fontWeight);
if (value && value->Type() == nsAttrValue::eInteger) // +/-
fontWeight->SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
nsCSSValue* colorValue = aData->ValueForColor();
@ -222,9 +204,7 @@ nsHTMLFontElement::IsAttributeMapped(const nsIAtom* aAttribute) const
{
static const MappedAttributeEntry attributes[] = {
{ &nsGkAtoms::face },
{ &nsGkAtoms::pointSize },
{ &nsGkAtoms::size },
{ &nsGkAtoms::fontWeight },
{ &nsGkAtoms::color },
{ nsnull }
};

Просмотреть файл

@ -83,7 +83,10 @@ public:
// nsIScriptGlobalObject methods
virtual nsresult EnsureScriptEnvironment();
virtual nsresult SetScriptContext(nsIScriptContext *aContext);
void ClearScriptContext()
{
mScriptContext = NULL;
}
virtual nsIScriptContext *GetContext();
virtual JSObject *GetGlobalJSObject();
@ -106,7 +109,6 @@ public:
protected:
virtual ~nsXBLDocGlobalObject();
void SetContext(nsIScriptContext *aContext);
nsIScriptContext *GetScriptContext();
nsCOMPtr<nsIScriptContext> mScriptContext;
@ -264,33 +266,6 @@ XBL_ProtoErrorReporter(JSContext *cx,
// nsIScriptGlobalObject methods
//
void
nsXBLDocGlobalObject::SetContext(nsIScriptContext *aScriptContext)
{
if (!aScriptContext) {
mScriptContext = nsnull;
return;
}
aScriptContext->WillInitializeContext();
// NOTE: We init this context with a NULL global, so we automatically
// hook up to the existing nsIScriptGlobalObject global setup by
// nsGlobalWindow.
DebugOnly<nsresult> rv;
rv = aScriptContext->InitContext();
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Script Language's InitContext failed");
aScriptContext->SetGCOnDestruction(false);
aScriptContext->DidInitializeContext();
// and we set up our global manually
mScriptContext = aScriptContext;
}
nsresult
nsXBLDocGlobalObject::SetScriptContext(nsIScriptContext *aContext)
{
SetContext(aContext);
return NS_OK;
}
nsIScriptContext *
nsXBLDocGlobalObject::GetScriptContext()
{
@ -300,18 +275,28 @@ nsXBLDocGlobalObject::GetScriptContext()
nsresult
nsXBLDocGlobalObject::EnsureScriptEnvironment()
{
if (mScriptContext)
return NS_OK; // already initialized for this lang
nsCOMPtr<nsIDOMScriptObjectFactory> factory = do_GetService(kDOMScriptObjectFactoryCID);
NS_ENSURE_TRUE(factory, NS_OK);
nsresult rv;
if (mScriptContext) {
// Already initialized.
return NS_OK;
}
nsCOMPtr<nsIScriptRuntime> scriptRuntime;
rv = NS_GetJSRuntime(getter_AddRefs(scriptRuntime));
NS_ENSURE_SUCCESS(rv, rv);
NS_GetJSRuntime(getter_AddRefs(scriptRuntime));
NS_ENSURE_TRUE(scriptRuntime, NS_OK);
nsCOMPtr<nsIScriptContext> newCtx = scriptRuntime->CreateContext();
rv = SetScriptContext(newCtx);
MOZ_ASSERT(newCtx);
newCtx->WillInitializeContext();
// NOTE: We init this context with a NULL global, so we automatically
// hook up to the existing nsIScriptGlobalObject global setup by
// nsGlobalWindow.
nsresult rv = newCtx->InitContext();
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Script Language's InitContext failed");
newCtx->SetGCOnDestruction(false);
newCtx->DidInitializeContext();
mScriptContext = newCtx;
JSContext *cx = mScriptContext->GetNativeContext();
JSAutoRequest ar(cx);
@ -557,7 +542,7 @@ nsXBLDocumentInfo::~nsXBLDocumentInfo()
/* destructor code */
if (mGlobalObject) {
// remove circular reference
mGlobalObject->SetScriptContext(nsnull);
mGlobalObject->ClearScriptContext();
mGlobalObject->ClearGlobalObjectOwner(); // just in case
}
if (mBindingTable) {

Просмотреть файл

@ -110,8 +110,8 @@ public:
virtual nsresult InstallMember(nsIScriptContext* aContext,
nsIContent* aBoundElement,
void* aScriptObject,
void* aTargetClassObject,
JSObject* aScriptObject, // Unused
JSObject* aTargetClassObject,
const nsCString& aClassStr) = 0;
virtual nsresult CompileMember(nsIScriptContext* aContext,
const nsCString& aClassStr,

Просмотреть файл

@ -122,31 +122,28 @@ nsXBLProtoImplMethod::SetLineNumber(PRUint32 aLineNumber)
nsresult
nsXBLProtoImplMethod::InstallMember(nsIScriptContext* aContext,
nsIContent* aBoundElement,
void* aScriptObject,
void* aTargetClassObject,
JSObject* aScriptObject,
JSObject* aTargetClassObject,
const nsCString& aClassStr)
{
NS_PRECONDITION(IsCompiled(),
"Should not be installing an uncompiled method");
JSContext* cx = aContext->GetNativeContext();
nsIDocument *ownerDoc = aBoundElement->OwnerDoc();
nsIScriptGlobalObject *sgo;
nsIScriptGlobalObject* sgo = aBoundElement->OwnerDoc()->GetScopeObject();
if (!(sgo = ownerDoc->GetScopeObject())) {
if (!sgo) {
return NS_ERROR_UNEXPECTED;
}
JSObject * scriptObject = (JSObject *) aScriptObject;
NS_ASSERTION(scriptObject, "uh-oh, script Object should NOT be null or bad things will happen");
if (!scriptObject)
NS_ASSERTION(aScriptObject, "uh-oh, script Object should NOT be null or bad things will happen");
if (!aScriptObject)
return NS_ERROR_FAILURE;
JSObject * targetClassObject = (JSObject *) aTargetClassObject;
JSObject * globalObject = sgo->GetGlobalJSObject();
JSObject* globalObject = sgo->GetGlobalJSObject();
// now we want to reevaluate our property using aContext and the script object for this window...
if (mJSMethodObject && targetClassObject) {
if (mJSMethodObject && aTargetClassObject) {
nsDependentString name(mName);
JSAutoRequest ar(cx);
JSAutoEnterCompartment ac;
@ -160,8 +157,8 @@ nsXBLProtoImplMethod::InstallMember(nsIScriptContext* aContext,
return NS_ERROR_OUT_OF_MEMORY;
}
if (!::JS_DefineUCProperty(cx, targetClassObject,
reinterpret_cast<const jschar*>(mName),
if (!::JS_DefineUCProperty(cx, aTargetClassObject,
static_cast<const jschar*>(mName),
name.Length(), OBJECT_TO_JSVAL(method),
NULL, NULL, JSPROP_ENUMERATE)) {
return NS_ERROR_OUT_OF_MEMORY;

Просмотреть файл

@ -122,8 +122,8 @@ public:
virtual nsresult InstallMember(nsIScriptContext* aContext,
nsIContent* aBoundElement,
void* aScriptObject,
void* aTargetClassObject,
JSObject* aScriptObject,
JSObject* aTargetClassObject,
const nsCString& aClassStr);
virtual nsresult CompileMember(nsIScriptContext* aContext,
const nsCString& aClassStr,
@ -174,8 +174,8 @@ public:
// prototype implementation).
virtual nsresult InstallMember(nsIScriptContext* aContext,
nsIContent* aBoundElement,
void* aScriptObject,
void* aTargetClassObject,
JSObject* aScriptObject,
JSObject* aTargetClassObject,
const nsCString& aClassStr) {
return NS_OK;
}

Просмотреть файл

@ -166,31 +166,28 @@ const char* gPropertyArgs[] = { "val" };
nsresult
nsXBLProtoImplProperty::InstallMember(nsIScriptContext* aContext,
nsIContent* aBoundElement,
void* aScriptObject,
void* aTargetClassObject,
JSObject* aScriptObject,
JSObject* aTargetClassObject,
const nsCString& aClassStr)
{
NS_PRECONDITION(mIsCompiled,
"Should not be installing an uncompiled property");
JSContext* cx = aContext->GetNativeContext();
nsIDocument *ownerDoc = aBoundElement->OwnerDoc();
nsIScriptGlobalObject *sgo;
nsIScriptGlobalObject* sgo = aBoundElement->OwnerDoc()->GetScopeObject();
if (!(sgo = ownerDoc->GetScopeObject())) {
if (!sgo) {
return NS_ERROR_UNEXPECTED;
}
JSObject * scriptObject = (JSObject *) aScriptObject;
NS_ASSERTION(scriptObject, "uh-oh, script Object should NOT be null or bad things will happen");
if (!scriptObject)
NS_ASSERTION(aScriptObject, "uh-oh, script Object should NOT be null or bad things will happen");
if (!aScriptObject)
return NS_ERROR_FAILURE;
JSObject * targetClassObject = (JSObject *) aTargetClassObject;
JSObject * globalObject = sgo->GetGlobalJSObject();
// now we want to reevaluate our property using aContext and the script object for this window...
if ((mJSGetterObject || mJSSetterObject) && targetClassObject) {
if ((mJSGetterObject || mJSSetterObject) && aTargetClassObject) {
JSObject * getter = nsnull;
JSAutoRequest ar(cx);
JSAutoEnterCompartment ac;
@ -208,8 +205,8 @@ nsXBLProtoImplProperty::InstallMember(nsIScriptContext* aContext,
return NS_ERROR_OUT_OF_MEMORY;
nsDependentString name(mName);
if (!::JS_DefineUCProperty(cx, targetClassObject,
reinterpret_cast<const jschar*>(mName),
if (!::JS_DefineUCProperty(cx, aTargetClassObject,
static_cast<const jschar*>(mName),
name.Length(), JSVAL_VOID,
JS_DATA_TO_FUNC_PTR(JSPropertyOp, getter),
JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, setter),

Просмотреть файл

@ -67,8 +67,8 @@ public:
virtual nsresult InstallMember(nsIScriptContext* aContext,
nsIContent* aBoundElement,
void* aScriptObject,
void* aTargetClassObject,
JSObject* aScriptObject,
JSObject* aTargetClassObject,
const nsCString& aClassStr);
virtual nsresult CompileMember(nsIScriptContext* aContext,
const nsCString& aClassStr,

Просмотреть файл

@ -1,444 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TransforMiiX XSLT processor code.
*
* The Initial Developer of the Original Code is
* The MITRE Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
//
// Modification History:
// Who When What
// TK 03/29/99 Created
// LF 08/06/1999 Changed static const short NodeType to enum
// Added "friend NamedNodeMap"; to NodeListDefinition
//
#ifndef MITRE_DOM
#define MITRE_DOM
#ifdef __BORLANDC__
#include <stdlib.h>
#endif
#include "txList.h"
#include "nsIAtom.h"
#include "nsTHashtable.h"
#include "nsBaseHashtable.h"
#include "nsString.h"
#include "txCore.h"
#include "nsAutoPtr.h"
#define kTxNsNodeIndexOffset 0x00000000;
#define kTxAttrIndexOffset 0x40000000;
#define kTxChildIndexOffset 0x80000000;
class NamedNodeMap;
class Document;
class Element;
class Attr;
class ProcessingInstruction;
#define kNameSpaceID_Unknown -1
#define kNameSpaceID_None 0
// not really a namespace, but it needs to play the game
#define kNameSpaceID_XMLNS 1
#define kNameSpaceID_XML 2
// kNameSpaceID_XSLT is 6 for module, see nsINameSpaceManager.h
#define kNameSpaceID_XSLT 3
//
// Abstract Class defining the interface for a Node. See NodeDefinition below
// for the actual implementation of the WC3 node.
//
class Node : public txObject
{
public:
//Node type constants
//-- LF - changed to enum
enum NodeType {
ELEMENT_NODE = 1,
ATTRIBUTE_NODE,
TEXT_NODE,
CDATA_SECTION_NODE,
ENTITY_REFERENCE_NODE,
ENTITY_NODE,
PROCESSING_INSTRUCTION_NODE,
COMMENT_NODE,
DOCUMENT_NODE,
DOCUMENT_TYPE_NODE,
DOCUMENT_FRAGMENT_NODE,
NOTATION_NODE
};
//Read functions
virtual nsresult getNodeName(nsAString& aName) const = 0;
virtual nsresult getNodeValue(nsAString& aValue) = 0;
virtual unsigned short getNodeType() const = 0;
virtual Node* getParentNode() const = 0;
virtual Node* getFirstChild() const = 0;
virtual Node* getLastChild() const = 0;
virtual Node* getPreviousSibling() const = 0;
virtual Node* getNextSibling() const = 0;
virtual Document* getOwnerDocument() const = 0;
//Node manipulation functions
virtual Node* appendChild(Node* newChild) = 0;
virtual bool hasChildNodes() const = 0;
//From DOM3 26-Jan-2001 WD
virtual nsresult getBaseURI(nsAString& aURI) = 0;
//Introduced in DOM2
virtual nsresult getNamespaceURI(nsAString& aNSURI) = 0;
//txXPathNode functions
virtual bool getLocalName(nsIAtom** aLocalName) = 0;
virtual PRInt32 getNamespaceID() = 0;
virtual Node* getXPathParent() = 0;
virtual PRInt32 compareDocumentPosition(Node* aOther) = 0;
};
//
// Definition and Implementation of Node and NodeList functionality. This is
// the central class, from which all other DOM classes (objects) are derrived.
// Users of this DOM should work strictly with the Node interface and NodeList
// interface (see above for those definitions)
//
class NodeDefinition : public Node
{
public:
virtual ~NodeDefinition(); //Destructor, delete all children of node
//Read functions
virtual nsresult getNodeName(nsAString& aName) const;
nsresult getNodeValue(nsAString& aValue);
unsigned short getNodeType() const;
Node* getParentNode() const;
Node* getFirstChild() const;
Node* getLastChild() const;
Node* getPreviousSibling() const;
Node* getNextSibling() const;
Document* getOwnerDocument() const;
//Child node manipulation functions
virtual Node* appendChild(Node* newChild);
bool hasChildNodes() const;
//From DOM3 26-Jan-2001 WD
virtual nsresult getBaseURI(nsAString& aURI);
//Introduced in DOM2
nsresult getNamespaceURI(nsAString& aNSURI);
//txXPathNode functions
virtual bool getLocalName(nsIAtom** aLocalName);
virtual PRInt32 getNamespaceID();
virtual Node* getXPathParent();
virtual PRInt32 compareDocumentPosition(Node* aOther);
//Only to be used from XMLParser
void appendData(const PRUnichar* aData, int aLength)
{
nodeValue.Append(aData, aLength);
};
protected:
friend class Document;
friend class txXPathTreeWalker;
friend class txXPathNodeUtils;
NodeDefinition(NodeType type, nsIAtom *aLocalName,
const nsAString& value, Document* owner);
//Name, value, and attributes for this node. Available to derrived
//classes, since those derrived classes have a better idea how to use them,
//than the generic node does.
nsCOMPtr<nsIAtom> mLocalName;
nsString nodeValue;
NodeDefinition* implAppendChild(NodeDefinition* newChild);
NodeDefinition* implRemoveChild(NodeDefinition* oldChild);
private:
//Type of node this is
NodeType nodeType;
//Data members for linking this Node to its parent and siblings
NodeDefinition* parentNode;
NodeDefinition* previousSibling;
NodeDefinition* nextSibling;
//Pointer to the node's document
Document* ownerDocument;
PRUint32 length;
//Data members for maintaining a list of child nodes
NodeDefinition* firstChild;
NodeDefinition* lastChild;
// Struct to hold document order information
struct OrderInfo {
~OrderInfo();
PRUint32* mOrder;
PRInt32 mSize;
Node* mRoot;
};
// OrderInfo object for comparing document order
OrderInfo* mOrderInfo;
// Helperfunction for compareDocumentOrder
OrderInfo* getOrderInfo();
};
//
//Definition and Implementation of a Document.
//
typedef nsTHashtable<nsBaseHashtableET<nsStringHashKey, Element*> > txIDMap;
class Document : public NodeDefinition
{
public:
Document();
Element* getDocumentElement();
//Factory functions for various node types
Node* createComment(const nsAString& aData);
ProcessingInstruction* createProcessingInstruction(nsIAtom *aTarget,
const nsAString& aData);
Node* createTextNode(const nsAString& theData);
Element* createElementNS(nsIAtom *aPrefix, nsIAtom *aLocalName,
PRInt32 aNamespaceID);
Element* getElementById(const nsAString& aID);
// Node manipulation functions
Node* appendChild(Node* newChild);
//Override to return documentBaseURI
nsresult getBaseURI(nsAString& aURI);
private:
bool setElementID(const nsAString& aID, Element* aElement);
Element* documentElement;
// This class is friend to be able to set the documentBaseURI
// and IDs.
friend class txXMLParser;
txIDMap mIDMap;
nsString documentBaseURI;
};
//
//Definition and Implementation of an Element
//
class Element : public NodeDefinition
{
public:
NamedNodeMap* getAttributes();
nsresult appendAttributeNS(nsIAtom *aPrefix, nsIAtom *aLocalName,
PRInt32 aNamespaceID, const nsAString& aValue);
// Node manipulation functions
Node* appendChild(Node* newChild);
//txXPathNode functions override
nsresult getNodeName(nsAString& aName) const;
bool getLocalName(nsIAtom** aLocalName);
PRInt32 getNamespaceID();
bool getAttr(nsIAtom* aLocalName, PRInt32 aNSID, nsAString& aValue);
bool hasAttr(nsIAtom* aLocalName, PRInt32 aNSID);
// ID getter
bool getIDValue(nsAString& aValue);
Attr *getFirstAttribute()
{
return mFirstAttribute;
}
private:
friend class Document;
void setIDValue(const nsAString& aValue);
Element(nsIAtom *aPrefix, nsIAtom *aLocalName, PRInt32 aNamespaceID,
Document* aOwner);
nsAutoPtr<Attr> mFirstAttribute;
nsString mIDValue;
nsCOMPtr<nsIAtom> mPrefix;
PRInt32 mNamespaceID;
};
//
//Definition and Implementation of a Attr
// NOTE: For the time bing use just the default functionality found in the
// NodeDefinition class
//
class Attr : public NodeDefinition
{
public:
Node* appendChild(Node* newChild);
//txXPathNode functions override
nsresult getNodeName(nsAString& aName) const;
bool getLocalName(nsIAtom** aLocalName);
PRInt32 getNamespaceID();
Node* getXPathParent();
bool equals(nsIAtom *aLocalName, PRInt32 aNamespaceID)
{
return mLocalName == aLocalName && aNamespaceID == mNamespaceID;
}
Attr *getNextAttribute()
{
return mNextAttribute;
}
private:
friend class Element;
Attr(nsIAtom *aPrefix, nsIAtom *aLocalName, PRInt32 aNamespaceID,
Element *aOwnerElement, const nsAString &aValue);
nsCOMPtr<nsIAtom> mPrefix;
PRInt32 mNamespaceID;
Element *mOwnerElement;
nsAutoPtr<Attr> mNextAttribute;
};
//
//Definition and Implemention of a ProcessingInstruction node. Most
//functionality is inherrited from NodeDefinition.
// The Target of a processing instruction is stored in the nodeName datamember
// inherrited from NodeDefinition.
// The Data of a processing instruction is stored in the nodeValue datamember
// inherrited from NodeDefinition
//
class ProcessingInstruction : public NodeDefinition
{
public:
//txXPathNode functions override
bool getLocalName(nsIAtom** aLocalName);
private:
friend class Document;
ProcessingInstruction(nsIAtom *theTarget, const nsAString& theData,
Document* owner);
};
class txStandaloneNamespaceManager
{
public:
static PRInt32 getNamespaceID(const nsAString& aURI)
{
if (!mNamespaces && !init())
return kNameSpaceID_Unknown;
PRInt32 id = mNamespaces->IndexOf(aURI);
if (id != -1) {
return id + 1;
}
if (!mNamespaces->AppendString(aURI)) {
NS_ERROR("Out of memory, namespaces are getting lost");
return kNameSpaceID_Unknown;
}
return mNamespaces->Count();
}
static nsresult getNamespaceURI(const PRInt32 aID, nsAString& aNSURI)
{
// empty namespace, and errors
aNSURI.Truncate();
if (aID <= 0 || (!mNamespaces && !init()) ||
aID > mNamespaces->Count()) {
return NS_OK;
}
aNSURI = *mNamespaces->StringAt(aID - 1);
return NS_OK;
}
static bool init()
{
NS_ASSERTION(!mNamespaces,
"called without matching shutdown()");
if (mNamespaces)
return true;
mNamespaces = new nsStringArray();
if (!mNamespaces)
return false;
/*
* Hardwiring some Namespace IDs.
* no Namespace is 0
* xmlns prefix is 1, mapped to http://www.w3.org/2000/xmlns/
* xml prefix is 2, mapped to http://www.w3.org/XML/1998/namespace
*/
if (!mNamespaces->AppendString(NS_LITERAL_STRING("http://www.w3.org/2000/xmlns/")) ||
!mNamespaces->AppendString(NS_LITERAL_STRING("http://www.w3.org/XML/1998/namespace")) ||
!mNamespaces->AppendString(NS_LITERAL_STRING("http://www.w3.org/1999/XSL/Transform"))) {
delete mNamespaces;
mNamespaces = 0;
return false;
}
return true;
}
static void shutdown()
{
NS_ASSERTION(mNamespaces, "called without matching init()");
if (!mNamespaces)
return;
delete mNamespaces;
mNamespaces = nsnull;
}
private:
static nsStringArray* mNamespaces;
};
#define TX_IMPL_DOM_STATICS \
nsStringArray* txStandaloneNamespaceManager::mNamespaces = 0
#endif

Просмотреть файл

@ -1951,7 +1951,7 @@ nsXULDocument::RemoveElementFromRefMap(Element* aElement)
//
NS_IMETHODIMP
nsXULDocument::CloneNode(bool aDeep, nsIDOMNode** aReturn)
nsXULDocument::CloneNode(bool aDeep, PRUint8 aOptionalArgc, nsIDOMNode** aReturn)
{
// We don't allow cloning of a document
*aReturn = nsnull;

Просмотреть файл

@ -58,6 +58,8 @@
#include "nsIStreamListener.h"
#include "nsICSSLoaderObserver.h"
#include "mozilla/Attributes.h"
class nsIRDFResource;
class nsIRDFService;
class nsPIWindowRoot;
@ -165,7 +167,8 @@ public:
bool OnDocumentParserError();
// nsIDOMNode interface overrides
NS_IMETHOD CloneNode(bool deep, nsIDOMNode **_retval);
NS_IMETHOD CloneNode(bool deep, PRUint8 aOptionalArgc, nsIDOMNode **_retval)
MOZ_OVERRIDE;
// nsIDOMDocument
NS_IMETHOD GetContentType(nsAString& aContentType);

Просмотреть файл

@ -91,7 +91,6 @@ public:
virtual nsresult EnsureScriptEnvironment();
virtual nsIScriptContext *GetScriptContext();
virtual nsresult SetScriptContext(nsIScriptContext *ctx);
// nsIScriptObjectPrincipal methods
virtual nsIPrincipal* GetPrincipal();
@ -686,34 +685,6 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXULPDGlobalObject)
// nsIScriptGlobalObject methods
//
nsresult
nsXULPDGlobalObject::SetScriptContext(nsIScriptContext *aScriptContext)
{
// almost a clone of nsGlobalWindow
if (!aScriptContext) {
NS_WARNING("Possibly early removal of script object, see bug #41608");
} else {
// should probably assert the context is clean???
aScriptContext->WillInitializeContext();
nsresult rv = aScriptContext->InitContext();
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ASSERTION(!aScriptContext || !mContext, "Bad call to SetContext()!");
JSObject* global = NULL;
if (aScriptContext) {
aScriptContext->SetGCOnDestruction(false);
aScriptContext->DidInitializeContext();
global = aScriptContext->GetNativeGlobal();
NS_ASSERTION(global, "GetNativeGlobal returned NULL!");
}
mContext = aScriptContext;
mJSObject = global;
return NS_OK;
}
nsresult
nsXULPDGlobalObject::EnsureScriptEnvironment()
{
@ -727,8 +698,10 @@ nsXULPDGlobalObject::EnsureScriptEnvironment()
NS_ENSURE_SUCCESS(rv, NS_OK);
nsCOMPtr<nsIScriptContext> ctxNew = languageRuntime->CreateContext();
MOZ_ASSERT(ctxNew);
// We have to setup a special global object. We do this then
// attach it as the global for this context. Then, ::SetScriptContext
// attach it as the global for this context. Then, we
// will re-fetch the global and set it up in our language globals array.
{
JSContext *cx = ctxNew->GetNativeContext();
@ -750,9 +723,20 @@ nsXULPDGlobalObject::EnsureScriptEnvironment()
NS_ADDREF(this);
}
// should probably assert the context is clean???
ctxNew->WillInitializeContext();
rv = ctxNew->InitContext();
NS_ENSURE_SUCCESS(rv, NS_OK);
rv = SetScriptContext(ctxNew);
NS_ENSURE_SUCCESS(rv, NS_OK);
ctxNew->SetGCOnDestruction(false);
ctxNew->DidInitializeContext();
JSObject* global = ctxNew->GetNativeGlobal();
NS_ASSERTION(global, "GetNativeGlobal returned NULL!");
mContext = ctxNew;
mJSObject = global;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,6 @@
<script>
function foo(o) {
o instanceof CSS2Properties;
}
foo({})
</script>

Просмотреть файл

@ -29,6 +29,7 @@ load 612018-1.html
load 637116.html
load 666869.html
load 675621-1.html
load 677194.html
load 693894.html
load 693811-1.html
load 693811-2.html

Просмотреть файл

@ -1350,14 +1350,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
// since a call to addProperty() is always followed by a call to
// setProperty(), except in the case when a getter or setter is set
// for a property. But we don't care about getters or setters here.
NS_DEFINE_CLASSINFO_DATA(StorageObsolete, nsStorageSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS |
nsIXPCScriptable::WANT_NEWRESOLVE |
nsIXPCScriptable::WANT_GETPROPERTY |
nsIXPCScriptable::WANT_SETPROPERTY |
nsIXPCScriptable::WANT_DELPROPERTY |
nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |
nsIXPCScriptable::WANT_NEWENUMERATE)
NS_DEFINE_CLASSINFO_DATA(StorageObsolete, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(Storage, nsStorage2SH,
DOM_DEFAULT_SCRIPTABLE_FLAGS |
@ -1371,8 +1365,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(StorageEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(StorageEventObsolete, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DOMParser, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -2444,10 +2436,8 @@ nsDOMClassInfo::Init()
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
JSContext *cx = nsnull;
rv = stack->GetSafeJSContext(&cx);
NS_ENSURE_SUCCESS(rv, rv);
JSContext* cx = stack->GetSafeJSContext();
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
@ -3959,10 +3949,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(StorageEventObsolete, nsIDOMStorageEventObsolete)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageEventObsolete)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMParser, nsIDOMParser)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMParser)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMParserJS)
@ -9592,7 +9578,7 @@ public:
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
NS_ENSURE_TRUE(stack, NS_OK);
stack->GetSafeJSContext(&cx);
cx = stack->GetSafeJSContext();
NS_ENSURE_TRUE(cx, NS_OK);
}
@ -10215,186 +10201,6 @@ nsTreeColumnsSH::GetNamedItem(nsISupports *aNative,
#endif
// Storage scriptable helper
// One reason we need a newResolve hook is that in order for
// enumeration of storage object keys to work the keys we're
// enumerating need to exist on the storage object for the JS engine
// to find them.
NS_IMETHODIMP
nsStorageSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, PRUint32 flags,
JSObject **objp, bool *_retval)
{
if (ObjectIsNativeWrapper(cx, obj)) {
return NS_OK;
}
JSObject *realObj;
wrapper->GetJSObject(&realObj);
JSAutoEnterCompartment ac;
if (!ac.enter(cx, realObj)) {
*_retval = false;
return NS_ERROR_FAILURE;
}
// First check to see if the property is defined on our prototype.
JSObject *proto = ::JS_GetPrototype(realObj);
JSBool hasProp;
if (proto &&
(::JS_HasPropertyById(cx, proto, id, &hasProp) &&
hasProp)) {
// We found the property we're resolving on the prototype,
// nothing left to do here then.
return NS_OK;
}
// We're resolving property that doesn't exist on the prototype,
// check if the key exists in the storage object.
nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
JSString *jsstr = IdToString(cx, id);
if (!jsstr)
return JS_FALSE;
nsDependentJSString depStr;
if (!depStr.init(cx, jsstr))
return JS_FALSE;
// GetItem() will return null if the caller can't access the session
// storage item.
nsCOMPtr<nsIDOMStorageItem> item;
nsresult rv = storage->GetItem(depStr, getter_AddRefs(item));
NS_ENSURE_SUCCESS(rv, rv);
if (item) {
if (!::JS_DefinePropertyById(cx, realObj, id, JSVAL_VOID, nsnull, nsnull,
JSPROP_ENUMERATE)) {
return NS_ERROR_FAILURE;
}
*objp = realObj;
}
return NS_OK;
}
nsISupports*
nsStorageSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsWrapperCache **aCache, nsresult *aResult)
{
nsDOMStorage* storage = nsDOMStorage::FromSupports(aNative);
return storage->GetNamedItem(aName, aResult);
}
NS_IMETHODIMP
nsStorageSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj, jsid id,
jsval *vp, bool *_retval)
{
nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
JSString *key = IdToString(cx, id);
NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
nsDependentJSString keyStr;
NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
JSString *value = ::JS_ValueToString(cx, *vp);
NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED);
nsDependentJSString valueStr;
NS_ENSURE_TRUE(valueStr.init(cx, value), NS_ERROR_UNEXPECTED);
nsresult rv = storage->SetItem(keyStr, valueStr);
if (NS_SUCCEEDED(rv)) {
rv = NS_SUCCESS_I_DID_SOMETHING;
}
return rv;
}
NS_IMETHODIMP
nsStorageSH::DelProperty(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj, jsid id,
jsval *vp, bool *_retval)
{
nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
JSString *key = IdToString(cx, id);
NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
nsDependentJSString keyStr;
NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
nsresult rv = storage->RemoveItem(keyStr);
if (NS_SUCCEEDED(rv)) {
rv = NS_SUCCESS_I_DID_SOMETHING;
}
return rv;
}
NS_IMETHODIMP
nsStorageSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRUint32 enum_op, jsval *statep,
jsid *idp, bool *_retval)
{
if (enum_op == JSENUMERATE_INIT || enum_op == JSENUMERATE_INIT_ALL) {
nsCOMPtr<nsPIDOMStorage> storage(do_QueryWrappedNative(wrapper));
// XXXndeakin need to free the keys afterwards
nsTArray<nsString> *keys = storage->GetKeys();
NS_ENSURE_TRUE(keys, NS_ERROR_OUT_OF_MEMORY);
*statep = PRIVATE_TO_JSVAL(keys);
if (idp) {
*idp = INT_TO_JSID(keys->Length());
}
return NS_OK;
}
nsTArray<nsString> *keys =
(nsTArray<nsString> *)JSVAL_TO_PRIVATE(*statep);
if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
nsString& key = keys->ElementAt(0);
JSString *str =
JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
(key.get()),
key.Length());
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
JS_ValueToId(cx, STRING_TO_JSVAL(str), idp);
keys->RemoveElementAt(0);
return NS_OK;
}
// destroy the keys array if we have no keys or if we're done
NS_ABORT_IF_FALSE(enum_op == JSENUMERATE_DESTROY ||
(enum_op == JSENUMERATE_NEXT && keys->Length() == 0),
"Bad call from the JS engine");
delete keys;
*statep = JSVAL_NULL;
return NS_OK;
}
// Storage2SH
// One reason we need a newResolve hook is that in order for

Просмотреть файл

@ -1355,47 +1355,6 @@ public:
// WebApps Storage helpers
class nsStorageSH : public nsNamedArraySH
{
protected:
nsStorageSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
{
}
virtual ~nsStorageSH()
{
}
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, PRUint32 flags,
JSObject **objp, bool *_retval);
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, bool *_retval);
NS_IMETHOD DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, bool *_retval);
NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRUint32 enum_op, jsval *statep,
jsid *idp, bool *_retval);
virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
nsWrapperCache **aCache, nsresult *aResult)
{
return nsnull;
}
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsWrapperCache **cache,
nsresult *aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
{
return new nsStorageSH(aData);
}
};
class nsStorage2SH : public nsDOMGenericSH
{
protected:

Просмотреть файл

@ -378,7 +378,6 @@ DOMCI_CLASS(StorageObsolete)
DOMCI_CLASS(Storage)
DOMCI_CLASS(StorageItem)
DOMCI_CLASS(StorageEvent)
DOMCI_CLASS(StorageEventObsolete)
// DOMParser, XMLSerializer
DOMCI_CLASS(DOMParser)

Просмотреть файл

@ -966,7 +966,7 @@ nsDOMWindowUtils::GarbageCollect(nsICycleCollectorListener *aListener,
}
#endif
nsJSContext::GarbageCollectNow(js::gcreason::DOM_UTILS);
nsJSContext::GarbageCollectNow(js::gcreason::DOM_UTILS, nsGCNormal, true);
nsJSContext::CycleCollectNow(aListener, aExtraForgetSkippableCalls);
return NS_OK;

Просмотреть файл

@ -1167,7 +1167,7 @@ nsGlobalWindow::FreeInnerObjects()
JSObject* obj = FastGetGlobalJSObject();
if (obj) {
if (!cx) {
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
}
JSAutoRequest ar(cx);
@ -1390,44 +1390,14 @@ nsGlobalWindow::UnmarkGrayTimers()
// nsGlobalWindow::nsIScriptGlobalObject
//*****************************************************************************
nsresult
nsGlobalWindow::SetScriptContext(nsIScriptContext *aScriptContext)
{
NS_ASSERTION(IsOuterWindow(), "Uh, SetScriptContext() called on inner window!");
NS_ASSERTION(!aScriptContext || !mContext, "Bad call to SetContext()!");
if (aScriptContext) {
// should probably assert the context is clean???
aScriptContext->WillInitializeContext();
// We need point the context to the global window before initializing it
// so that it can make various decisions properly.
aScriptContext->SetGlobalObject(this);
nsresult rv = aScriptContext->InitContext();
NS_ENSURE_SUCCESS(rv, rv);
if (IsFrame()) {
// This window is a [i]frame, don't bother GC'ing when the
// frame's context is destroyed since a GC will happen when the
// frameset or host document is destroyed anyway.
aScriptContext->SetGCOnDestruction(false);
}
}
mContext = aScriptContext;
return NS_OK;
}
nsresult
nsGlobalWindow::EnsureScriptEnvironment()
{
FORWARD_TO_OUTER(EnsureScriptEnvironment, (), NS_ERROR_NOT_INITIALIZED);
if (mJSObject)
return NS_OK;
if (mJSObject) {
return NS_OK;
}
NS_ASSERTION(!GetCurrentInnerWindowInternal(),
"mJSObject is null, but we have an inner window?");
@ -1437,7 +1407,29 @@ nsGlobalWindow::EnsureScriptEnvironment()
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIScriptContext> context = scriptRuntime->CreateContext();
return SetScriptContext(context);
NS_ASSERTION(!mContext, "Will overwrite mContext!");
// should probably assert the context is clean???
context->WillInitializeContext();
// We need point the context to the global window before initializing it
// so that it can make various decisions properly.
context->SetGlobalObject(this);
rv = context->InitContext();
NS_ENSURE_SUCCESS(rv, rv);
if (IsFrame()) {
// This window is a [i]frame, don't bother GC'ing when the
// frame's context is destroyed since a GC will happen when the
// frameset or host document is destroyed anyway.
context->SetGCOnDestruction(false);
}
mContext = context;
return NS_OK;
}
nsIScriptContext *
@ -2244,8 +2236,8 @@ nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell)
if (currentInner) {
JSObject* obj = currentInner->FastGetGlobalJSObject();
if (obj) {
JSContext* cx;
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
JSContext* cx =
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
JSAutoRequest ar(cx);
@ -5981,7 +5973,7 @@ PostMessageEvent::Run()
// we need to find a JSContext.
nsIThreadJSContextStack* cxStack = nsContentUtils::ThreadJSContextStack();
if (cxStack) {
cxStack->GetSafeJSContext(&cx);
cx = cxStack->GetSafeJSContext();
}
if (!cx) {

Просмотреть файл

@ -300,10 +300,6 @@ public:
virtual nsIScriptContext *GetScriptContext();
// Set a new script language context for this global. The native global
// for the context is created by the context's GetNativeGlobal() method.
virtual nsresult SetScriptContext(nsIScriptContext *aContext);
virtual void OnFinalize(JSObject* aObject);
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts);

Просмотреть файл

@ -100,8 +100,8 @@ NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
#define NS_ISCRIPTGLOBALOBJECT_IID \
{ 0x8f19a761, 0x0717, 0x4b3f, \
{ 0x80, 0xc5, 0xed, 0x7e, 0x9c, 0xbc, 0x40, 0xb1 } }
{ 0xd1549969, 0x92df, 0x4a75, \
{ 0x8c, 0x12, 0x35, 0x14, 0xd1, 0x0b, 0xbc, 0x18 } }
/**
* The global object which keeps a script context for each supported script
@ -130,17 +130,10 @@ public:
virtual JSObject* GetGlobalJSObject() = 0;
virtual nsIScriptContext *GetContext() {
return GetScriptContext();
nsIScriptContext* GetContext() {
return GetScriptContext();
}
/**
* Set a new language context for this global. The native global for the
* context is created by the context's GetNativeGlobal() method.
*/
virtual nsresult SetScriptContext(nsIScriptContext *aContext) = 0;
/**
* Called when the global script for a language is finalized, typically as
* part of its GC process. By the time this call is made, the

Просмотреть файл

@ -134,6 +134,10 @@ static PRLogModuleInfo* gJSDiagnostics;
// doing the first GC.
#define NS_FIRST_GC_DELAY 10000 // ms
#define NS_FULL_GC_DELAY 30000 // ms
#define NS_MAX_COMPARTMENT_GC_COUNT 10
// Maximum amount of time that should elapse between incremental GC slices
#define NS_INTERSLICE_GC_DELAY 100 // ms
@ -159,6 +163,7 @@ static PRLogModuleInfo* gJSDiagnostics;
static nsITimer *sGCTimer;
static nsITimer *sShrinkGCBuffersTimer;
static nsITimer *sCCTimer;
static nsITimer *sFullGCTimer;
static PRTime sLastCCEndTime;
@ -178,6 +183,7 @@ static bool sLoadingInProgress;
static PRUint32 sCCollectedWaitingForGC;
static bool sPostGCEventsToConsole;
static bool sDisableExplicitCompartmentGC;
static PRUint32 sCCTimerFireCount = 0;
static PRUint32 sMinForgetSkippableTime = PR_UINT32_MAX;
static PRUint32 sMaxForgetSkippableTime = 0;
@ -185,7 +191,9 @@ static PRUint32 sTotalForgetSkippableTime = 0;
static PRUint32 sRemovedPurples = 0;
static PRUint32 sForgetSkippableBeforeCC = 0;
static PRUint32 sPreviousSuspectedCount = 0;
static PRUint32 sCompartmentGCCount = NS_MAX_COMPARTMENT_GC_COUNT;
static bool sContextDeleted = false;
static bool sDidRunInitialGC = false;
static PRUint32 sCleanupsSinceLastGC = PR_UINT32_MAX;
static bool sNeedsFullCC = false;
@ -229,7 +237,8 @@ nsMemoryPressureObserver::Observe(nsISupports* aSubject, const char* aTopic,
const PRUnichar* aData)
{
if (sGCOnMemoryPressure) {
nsJSContext::GarbageCollectNow(js::gcreason::MEM_PRESSURE, nsGCShrinking);
nsJSContext::GarbageCollectNow(js::gcreason::MEM_PRESSURE, nsGCShrinking,
true);
nsJSContext::CycleCollectNow();
}
return NS_OK;
@ -929,6 +938,8 @@ static const char js_pccounts_content_str[] = JS_OPTIONS_DOT_STR "pccounts.con
static const char js_pccounts_chrome_str[] = JS_OPTIONS_DOT_STR "pccounts.chrome";
static const char js_jit_hardening_str[] = JS_OPTIONS_DOT_STR "jit_hardening";
static const char js_memlog_option_str[] = JS_OPTIONS_DOT_STR "mem.log";
static const char js_disable_explicit_compartment_gc[] =
JS_OPTIONS_DOT_STR "disable_explicit_compartment_gc";
int
nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
@ -938,6 +949,8 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
PRUint32 newDefaultJSOptions = oldDefaultJSOptions;
sPostGCEventsToConsole = Preferences::GetBool(js_memlog_option_str);
sDisableExplicitCompartmentGC =
Preferences::GetBool(js_disable_explicit_compartment_gc);
bool strict = Preferences::GetBool(js_strict_option_str);
if (strict)
@ -1115,6 +1128,7 @@ nsJSContext::DestroyJSContext()
js_options_dot_str, this);
if (mGCOnDestruction) {
sContextDeleted = true;
PokeGC(js::gcreason::NSJSCONTEXT_DESTROY);
}
@ -2849,6 +2863,11 @@ nsJSContext::ScriptEvaluated(bool aTerminated)
if (aTerminated) {
mOperationCallbackTime = 0;
mModalStateTime = 0;
JSObject* global = GetNativeGlobal();
if (global) {
js::PrepareCompartmentForGC(js::GetObjectCompartment(global));
}
}
}
@ -2916,9 +2935,20 @@ nsJSContext::ScriptExecuted()
return NS_OK;
}
void
FullGCTimerFired(nsITimer* aTimer, void* aClosure)
{
NS_RELEASE(sFullGCTimer);
uintptr_t reason = reinterpret_cast<uintptr_t>(aClosure);
nsJSContext::GarbageCollectNow(static_cast<js::gcreason::Reason>(reason),
nsGCNormal, true);
}
//static
void
nsJSContext::GarbageCollectNow(js::gcreason::Reason reason, PRUint32 gckind)
nsJSContext::GarbageCollectNow(js::gcreason::Reason aReason, PRUint32 aGckind,
bool aGlobal)
{
NS_TIME_FUNCTION_MIN(1.0);
SAMPLE_LABEL("GC", "GarbageCollectNow");
@ -2935,9 +2965,36 @@ nsJSContext::GarbageCollectNow(js::gcreason::Reason reason, PRUint32 gckind)
sPendingLoadCount = 0;
sLoadingInProgress = false;
if (nsContentUtils::XPConnect()) {
nsContentUtils::XPConnect()->GarbageCollect(reason, gckind);
if (!nsContentUtils::XPConnect()) {
return;
}
// Use compartment GC when we're not asked to do a shrinking GC nor
// global GC and compartment GC has been called less than
// NS_MAX_COMPARTMENT_GC_COUNT times after the previous global GC. If a top
// level browsing context has been deleted, we do a global GC.
if (sDidRunInitialGC &&
!sDisableExplicitCompartmentGC &&
aGckind != nsGCShrinking && !aGlobal &&
!sContextDeleted && sCompartmentGCCount < NS_MAX_COMPARTMENT_GC_COUNT) {
if (!sFullGCTimer) {
CallCreateInstance("@mozilla.org/timer;1", &sFullGCTimer);
}
if (sFullGCTimer) {
sFullGCTimer->Cancel();
js::gcreason::Reason reason = js::gcreason::FULL_GC_TIMER;
sFullGCTimer->InitWithFuncCallback(FullGCTimerFired,
reinterpret_cast<void *>(reason),
NS_FULL_GC_DELAY,
nsITimer::TYPE_ONE_SHOT);
}
if (js::IsGCScheduled(nsJSRuntime::sRuntime)) {
js::IncrementalGC(nsJSRuntime::sRuntime, aReason);
}
return;
}
nsContentUtils::XPConnect()->GarbageCollect(aReason, aGckind);
}
//static
@ -2963,7 +3020,7 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener,
if (sCCLockedOut) {
// We're in the middle of an incremental GC; finish it first
nsJSContext::GarbageCollectNow(js::gcreason::CC_FORCED, nsGCNormal);
nsJSContext::GarbageCollectNow(js::gcreason::CC_FORCED, nsGCNormal, true);
}
SAMPLE_LABEL("GC", "CycleCollectNow");
@ -3100,7 +3157,8 @@ GCTimerFired(nsITimer *aTimer, void *aClosure)
NS_RELEASE(sGCTimer);
uintptr_t reason = reinterpret_cast<uintptr_t>(aClosure);
nsJSContext::GarbageCollectNow(static_cast<js::gcreason::Reason>(reason), nsGCIncremental);
nsJSContext::GarbageCollectNow(static_cast<js::gcreason::Reason>(reason),
nsGCNormal, false);
}
void
@ -3156,7 +3214,7 @@ CCTimerFired(nsITimer *aTimer, void *aClosure)
}
// Finish the current incremental GC
nsJSContext::GarbageCollectNow(js::gcreason::CC_FORCED, nsGCNormal);
nsJSContext::GarbageCollectNow(js::gcreason::CC_FORCED, nsGCNormal, true);
}
++sCCTimerFireCount;
@ -3309,6 +3367,15 @@ nsJSContext::KillGCTimer()
}
}
void
nsJSContext::KillFullGCTimer()
{
if (sFullGCTimer) {
sFullGCTimer->Cancel();
NS_RELEASE(sFullGCTimer);
}
}
//static
void
nsJSContext::KillShrinkGCBuffersTimer()
@ -3336,6 +3403,8 @@ nsJSContext::KillCCTimer()
void
nsJSContext::GC(js::gcreason::Reason aReason)
{
// Force full gc.
sCompartmentGCCount = NS_MAX_COMPARTMENT_GC_COUNT;
PokeGC(aReason);
}
@ -3419,6 +3488,7 @@ DOMGCSliceCallback(JSRuntime *aRt, js::GCProgress aProgress, const js::GCDescrip
sCleanupsSinceLastGC = 0;
if (aDesc.isCompartment) {
++sCompartmentGCCount;
// If this is a compartment GC, restart it. We still want
// a full GC to happen. Compartment GCs usually happen as a
// result of last-ditch or MaybeGC. In both cases it is
@ -3431,6 +3501,11 @@ DOMGCSliceCallback(JSRuntime *aRt, js::GCProgress aProgress, const js::GCDescrip
nsJSContext::MaybePokeCC();
if (!aDesc.isCompartment) {
sDidRunInitialGC = true;
sContextDeleted = false;
sCompartmentGCCount = 0;
nsJSContext::KillFullGCTimer();
// Avoid shrinking during heavy activity, which is suggested by
// compartment GC.
nsJSContext::PokeShrinkGCBuffers();
@ -3530,7 +3605,7 @@ void
nsJSRuntime::Startup()
{
// initialize all our statics, so that we can restart XPCOM
sGCTimer = sCCTimer = nsnull;
sGCTimer = sFullGCTimer = sCCTimer = nsnull;
sCCLockedOut = false;
sCCLockedOutTime = 0;
sLastCCEndTime = 0;
@ -3538,6 +3613,7 @@ nsJSRuntime::Startup()
sLoadingInProgress = false;
sCCollectedWaitingForGC = 0;
sPostGCEventsToConsole = false;
sDisableExplicitCompartmentGC = false;
sNeedsFullCC = false;
gNameSpaceManager = nsnull;
sRuntimeService = nsnull;
@ -3829,6 +3905,7 @@ nsJSRuntime::Shutdown()
nsJSContext::KillGCTimer();
nsJSContext::KillShrinkGCBuffersTimer();
nsJSContext::KillCCTimer();
nsJSContext::KillFullGCTimer();
NS_IF_RELEASE(gNameSpaceManager);

Просмотреть файл

@ -184,7 +184,9 @@ public:
static void LoadStart();
static void LoadEnd();
static void GarbageCollectNow(js::gcreason::Reason reason, PRUint32 gckind = nsGCNormal);
static void GarbageCollectNow(js::gcreason::Reason reason,
PRUint32 aGckind,
bool aGlobal);
static void ShrinkGCBuffersNow();
// If aExtraForgetSkippableCalls is -1, forgetSkippable won't be
// called even if the previous collection was GC.
@ -199,6 +201,7 @@ public:
static void MaybePokeCC();
static void KillCCTimer();
static void KillFullGCTimer();
virtual void GC(js::gcreason::Reason aReason);

Просмотреть файл

@ -5,5 +5,59 @@
"webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-11.xml": {
"document.getElementsByClassName(): \"tricky\" compound": true
},
"webapps/WebStorage/tests/submissions/Infraware/test_event_constructor.html": {
"storageeventinit test": true
},
"webapps/WebStorage/tests/submissions/Infraware/test_storage_local_security.html": {
"storage local security test": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_event_constructor_js.html": {
"StorageEvent constructor and nulls": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_getitem_js.html": {
"All 3 items should be added.": true,
"array access should be correct": true,
"getItem should be correct": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_in_js.html": {
"Web Storage 1": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_index_js.html": {
"Web Storage 1": true,
"Web Storage 2": true,
"Web Storage 3": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_removeitem_js.html": {
"Web Storage 2": true,
"Web Storage 3": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_getitem_js.html": {
"All 3 items should be added.": true,
"array access should be correct": true,
"getItem should be correct": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_in_js.html": {
"Web Storage 1": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_index_js.html": {
"Web Storage 1": true,
"Web Storage 2": true,
"Web Storage 3": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_removeitem_js.html": {
"Web Storage 2": true,
"Web Storage 3": true
}
}

Просмотреть файл

@ -1,3 +1,4 @@
DIRS += \
webapps/DOMCore/tests/submissions/Opera \
webapps/WebStorage/tests/submissions \
$(NULL)

Просмотреть файл

@ -1,2 +1,3 @@
https://dvcs.w3.org/hg/webapps|webapps
DOMCore/tests/submissions/Opera
WebStorage/tests/submissions

Просмотреть файл

@ -0,0 +1,50 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
DEPTH = ../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware
DIRS = \
iframe \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TESTS = \
test_event_constructor.html \
test_event_local_key.html \
test_event_local_newvalue.html \
test_event_local_oldvalue.html \
test_event_local_storagearea.html \
test_event_local_storageeventinit.html \
test_event_local_url.html \
test_event_session_key.html \
test_event_session_newvalue.html \
test_event_session_oldvalue.html \
test_event_session_storagearea.html \
test_event_session_storageeventinit.html \
test_event_session_url.html \
test_storage_local_clear.html \
test_storage_local_getitem.html \
test_storage_local_key.html \
test_storage_local_length.html \
test_storage_local_removeitem.html \
test_storage_local_security.html \
test_storage_local_setitem.html \
test_storage_session_clear.html \
test_storage_session_getitem.html \
test_storage_session_key.html \
test_storage_session_length.html \
test_storage_session_removeitem.html \
test_storage_session_setitem.html \
$(NULL)
_TESTS += \
$(NULL)
libs:: $(_TESTS)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

Просмотреть файл

@ -0,0 +1,30 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
DEPTH = ../../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/iframe
DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TESTS = \
$(NULL)
_TESTS += \
local_change_item_iframe.html \
local_security_iframe.html \
local_set_item_clear_iframe.html \
local_set_item_iframe.html \
session_change_item_iframe.html \
session_set_item_clear_iframe.html \
session_set_item_iframe.html \
$(NULL)
libs:: $(_TESTS)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

Просмотреть файл

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('localStorage' in window) && window.localStorage !== null){
try {
localStorage.setItem("name", "user1");
localStorage.setItem("name", "user2");
} catch (e) {
parent.fail("setItem method is failed.");
}
localStorage.clear();
} else {
parent.fail("localStorage is not supported.");
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('localStorage' in window) && window.localStorage != null){
try {
localStorage.setItem("Security", "false");
parent.localStorage.clear();
} catch (e) {
if(e.code == e['SECURITY_ERR'])
localStorage.setItem("Security", "true");
}
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('localStorage' in window) && window.localStorage !== null){
try {
localStorage.setItem("name", "user1");
} catch (e) {
parent.fail("setItem method is failed.");
}
localStorage.clear();
} else {
parent.fail("localStorage is not supported.");
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('localStorage' in window) && window.localStorage !== null){
try {
localStorage.setItem("name", "user1");
} catch (e) {
parent.fail("setItem method is failed.");
}
} else {
parent.fail("localStorage is not supported.");
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('sessionStorage' in window) && window.sessionStorage !== null){
try {
sessionStorage.setItem("name", "user1");
sessionStorage.setItem("name", "user2");
} catch (e) {
parent.fail("setItem method is failed.");
}
sessionStorage.clear();
} else {
parent.fail("sessionStorage is not supported.");
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('sessionStorage' in window) && window.sessionStorage !== null){
try {
sessionStorage.setItem('name', 'user1');
} catch (e) {
parent.fail('setItem method is failed.');
}
sessionStorage.clear();
} else {
parent.fail('sessionStorage is not supported.');
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('sessionStorage' in window) && window.sessionStorage !== null){
try {
sessionStorage.setItem('name', 'user1');
} catch (e) {
parent.fail('setItem method is failed.');
}
} else {
parent.fail('sessionStorage is not supported.');
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,32 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>event_session_Constructor</h1>
<div id="log"></div>
<script>
test(function() {
var t = async_test("storageeventinit test");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.type, 'storage');
assert_equals(event.key, null);
assert_equals(event.oldValue, null);
assert_equals(event.newValue, null);
assert_equals(event.url, '');
assert_equals(event.storageArea, null);
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var event = new StorageEvent('storage');
window.dispatchEvent(event);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_local_key</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
var t = async_test("key property test of local event");
var expected = ['name', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/local_set_item_clear_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_local_newValue</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
var t = async_test("newValue property test of local event");
var expected = ['user1', 'user2', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.newValue, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/local_change_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_local_oldValue</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
var t = async_test("oldValue property test of local event");
var expected = [null, 'user1', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.oldValue, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/local_change_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_local_storageArea</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
var t = async_test("storageArea property test of local event");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.storageArea.length, 1);
var key = event.storageArea.key(0);
var value = event.storageArea.getItem(key);
assert_equals(key, "name");
assert_equals(value, "user1");
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/local_set_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,39 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>event_local_StorageEventInit</h1>
<div id="log"></div>
<script>
test(function() {
var t = async_test("storageeventinit test");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, 'key');
assert_equals(event.oldValue, 'oldValue');
assert_equals(event.newValue, 'newValue');
assert_equals(event.url, window.location.href);
assert_equals(event.storageArea, window.localStorage);
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var event = new StorageEvent('storage', {
key: 'key',
oldValue: 'oldValue',
newValue: 'newValue',
url: window.location.href,
storageArea: window.localStorage
});
window.dispatchEvent(event);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_local_url</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
var t = async_test("url property test of local event");
function onStorageEvent(event) {
t.step(function() {
var url = window.location.href;
var pos = url.lastIndexOf("/");
if (pos != -1) {
url = url.substr(0, pos + 1);
url = url + "iframe/local_set_item_iframe.html";
}
assert_equals(event.url, url);
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/local_set_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_session_key</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
var t = async_test("key property test of session event");
var expected = ['name', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/session_set_item_clear_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_session_newValue</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
var t = async_test("newvalue property test of session event");
var expected = ['user1', 'user2', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.newValue, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/session_change_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_session_oldValue</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
var t = async_test("oldvalue property test of session event");
var expected = [null, 'user1', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.oldValue, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/session_change_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_session_storageArea</h1>
<div id="log"></div>
<script>
test(function() {
var t = async_test("storageArea property test of session event");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.storageArea.length, 1);
var key = event.storageArea.key(0);
var value = event.storageArea.getItem(key);
assert_equals(key, "name");
assert_equals(value, "user1");
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/session_set_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,39 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>event_session_StorageEventInit</h1>
<div id="log"></div>
<script>
test(function() {
var t = async_test("storageeventinit test");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, 'key');
assert_equals(event.oldValue, 'oldValue');
assert_equals(event.newValue, 'newValue');
assert_equals(event.url, window.location.href);
assert_equals(event.storageArea, window.sessionStorage);
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var event = new StorageEvent('storage', {
key: 'key',
oldValue: 'oldValue',
newValue: 'newValue',
url: window.location.href,
storageArea: window.sessionStorage
});
window.dispatchEvent(event);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_session_url</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
var t = async_test("url property test of session event");
function onStorageEvent(event) {
t.step(function() {
var url = window.location.href;
var pos = url.lastIndexOf("/");
if (pos != -1) {
url = url.substr(0, pos + 1);
url = url + "iframe/session_set_item_iframe.html";
}
assert_equals(event.url, url);
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/session_set_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_clear</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
assert_not_equals(localStorage.getItem("name"), null);
assert_equals(localStorage.length, 1);
localStorage.clear();
assert_equals(localStorage.getItem("name"), null, "localStorage.getItem('name')")
assert_equals(localStorage.length, 0, "localStorage.length")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_getItem</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
localStorage.setItem("age", "20");
test(function() {
assert_equals(localStorage.getItem("name"), "user1", "localStorage.getItem('name')")
assert_equals(localStorage.getItem("unknown"), null, "localStorage.getItem('unknown')")
}, "getItem method test")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_key</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
localStorage.setItem("age", "20");
localStorage.setItem("a", "1");
localStorage.setItem("b", "2");
var keys = ["name", "age", "a", "b"];
function doTest(index) {
test(function() {
var key = localStorage.key(index);
assert_not_equals(key, null);
assert_true(keys.indexOf(key) >= 0,
"Unexpected key " + key + " found.");
}, "key(" + index + ") should return the right thing.");
}
for (var i = 0; i < keys.length; ++i) {
doTest(i);
doTest(i + 0x100000000);
}
test(function() {
assert_equals(localStorage.key(-1), null, "localStorage.key(-1)");
assert_equals(localStorage.key(4), null, "localStorage.key(4)");
}, "key() should return null for out-of-range arguments.");
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_length</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
assert_equals(localStorage.length, 0, "localStorage.length")
localStorage.setItem("name", "user1");
localStorage.setItem("age", "20");
assert_equals(localStorage.length, 2, "localStorage.length")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_removeItem</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
assert_equals(localStorage.getItem("name"), "user1");
localStorage.removeItem("name");
localStorage.removeItem("unknown");
assert_equals(localStorage.getItem("name"), null, "localStorage.getItem('name')")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,32 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_security</h1>
<iframe id="frame" src="iframe/local_security_iframe.html" style="width: 0px; height: 0px;"></iframe>
<div id="log"></div>
<script>
var t1 = async_test('storage local security test');
iframeWindow = document.getElementById('frame').contentWindow;
setTimeout(function(){
try {
var errFlag =iframeWindow.localStorage.getItem("Security");
t1.step(function() {
assert_equals(errFlag, "true", 'SECURITY_ERR error is not raised.')
});
} catch (e) {
t1.step(function() {
assert_unreached('Error is raised.');
});
}
t1.done();
}, 500);
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_setItem</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
assert_equals(localStorage.length, 1, "localStorage.setItem")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_clear</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
assert_not_equals(sessionStorage.getItem("name"), null);
assert_equals(sessionStorage.length, 1);
sessionStorage.clear();
assert_equals(sessionStorage.getItem("name"), null, "sessionStorage.getItem('name')")
assert_equals(sessionStorage.length, 0, "sessionStorage.length")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_getItem</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
sessionStorage.setItem("age", "20");
test(function() {
assert_equals(sessionStorage.getItem("name"), "user1", "sessionStorage.getItem('name')")
assert_equals(sessionStorage.getItem("unknown"), null, "sessionStorage.getItem('unknown')")
}, "getItem method test")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_key</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
sessionStorage.setItem("age", "20");
sessionStorage.setItem("a", "1");
sessionStorage.setItem("b", "2");
var keys = ["name", "age", "a", "b"];
function doTest(index) {
test(function() {
var key = sessionStorage.key(index);
assert_not_equals(key, null);
assert_true(keys.indexOf(key) >= 0,
"Unexpected key " + key + " found.");
}, "key(" + index + ") should return the right thing.");
}
for (var i = 0; i < keys.length; ++i) {
doTest(i);
doTest(i + 0x100000000);
}
test(function() {
assert_equals(sessionStorage.key(-1), null, "sessionStorage.key(-1)");
assert_equals(sessionStorage.key(4), null, "sessionStorage.key(4)");
}, "key() should return null for out-of-range arguments.");
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_length</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
assert_equals(sessionStorage.length, 0, "sessionStorage.length")
sessionStorage.setItem("name", "user1");
sessionStorage.setItem("age", "20");
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_removeItem</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
assert_equals(sessionStorage.getItem("name"), "user1");
sessionStorage.removeItem("name");
sessionStorage.removeItem("unknown");
assert_equals(sessionStorage.getItem("name"), null, "sessionStorage.getItem('name')")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_setItem</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
assert_equals(sessionStorage.length, 1, "localStorage.setItem")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
DEPTH = ../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests/webapps/WebStorage/tests/submissions
DIRS = \
Infraware \
Ms2ger \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,38 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
DEPTH = ../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger
DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TESTS = \
test_event_constructor_js.html \
test_storage_local_clear_js.html \
test_storage_local_getitem_js.html \
test_storage_local_index_js.html \
test_storage_local_in_js.html \
test_storage_local_length_js.html \
test_storage_local_removeitem_js.html \
test_storage_local_setitem_js.html \
test_storage_session_clear_js.html \
test_storage_session_getitem_js.html \
test_storage_session_index_js.html \
test_storage_session_in_js.html \
test_storage_session_length_js.html \
test_storage_session_removeitem_js.html \
test_storage_session_setitem_js.html \
$(NULL)
_TESTS += \
$(NULL)
libs:: $(_TESTS)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

Просмотреть файл

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>event_Constructor</h1>
<div id="log"></div>
<script>
test(function() {
var t = async_test("StorageEvent constructor and nulls");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.type, 'storage', 'type');
assert_equals(event.key, null, 'key');
assert_equals(event.oldValue, null, 'oldValue');
assert_equals(event.newValue, null, 'newValue');
assert_equals(event.url, 'null', 'url');
assert_equals(event.storageArea, null, 'storageArea');
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var event = new StorageEvent('storage', {
key: null,
oldValue: null,
newValue: null,
url: null
});
window.dispatchEvent(event);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_clear</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
assert_not_equals(localStorage.name, undefined);
assert_equals(localStorage.length, 1);
localStorage.clear();
assert_equals(localStorage.name, undefined, "localStorage.name")
assert_equals(localStorage.length, 0, "localStorage.length")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_getItem</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("undefined", "foo");
localStorage.setItem("null", "bar");
localStorage.setItem("", "baz");
test(function() {
assert_equals(localStorage.length, 3);
}, "All 3 items should be added.");
test(function() {
assert_equals(localStorage["unknown"], undefined, "localStorage['unknown']")
assert_equals(localStorage["undefined"], "foo", "localStorage['undefined']")
assert_equals(localStorage["null"], "bar", "localStorage['null']")
assert_equals(localStorage[undefined], "foo", "localStorage[undefined]")
assert_equals(localStorage[null], "bar", "localStorage[null]")
assert_equals(localStorage[""], "baz", "localStorage['']")
}, "array access should be correct");
test(function() {
assert_equals(localStorage.getItem("undefined"), "foo", "localStorage.getItem('undefined')")
assert_equals(localStorage.getItem("null"), "bar", "localStorage.getItem('null')")
assert_equals(localStorage.getItem(undefined), "foo", "localStorage.getItem(undefined)")
assert_equals(localStorage.getItem(null), "bar", "localStorage.getItem(null)")
assert_equals(localStorage.getItem(""), "baz", "localStorage.getItem('')")
}, "getItem should be correct")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_in</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
assert_false("name" in localStorage);
localStorage["name"] = "user1";
assert_true("name" in localStorage);
});
test(function() {
localStorage.clear();
assert_false("name" in localStorage);
localStorage.setItem("name", "user1");
assert_true("name" in localStorage);
assert_equals(localStorage.name, "user1");
localStorage.removeItem("name");
assert_false("name" in localStorage);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,36 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_index</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage["name"] = "user1";
localStorage["age"] = "42";
test(function() {
assert_equals(localStorage[-1], undefined);
assert_equals(localStorage[0], undefined);
assert_equals(localStorage[1], undefined);
assert_equals(localStorage[2], undefined);
})
test(function() {
assert_equals(localStorage["-1"], undefined);
assert_equals(localStorage["0"], undefined);
assert_equals(localStorage["1"], undefined);
assert_equals(localStorage["2"], undefined);
})
localStorage.setItem(1, "number");
test(function() {
assert_equals(localStorage[1], "number");
assert_equals(localStorage["1"], "number");
})
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_length</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
assert_equals(localStorage.length, 0, "localStorage.length")
localStorage["name"] = "user1";
localStorage["age"] = "20";
assert_equals(localStorage.length, 2, "localStorage.length")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_removeItem</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
assert_equals(localStorage.getItem("name"), "user1");
test(function() {
delete localStorage["name"];
delete localStorage["unknown"];
assert_equals(localStorage.getItem("name"), null, "localStorage.getItem('name')")
});
test(function() {
localStorage.setItem("null", "test");
assert_true("null" in localStorage);
localStorage.removeItem(null, "test");
assert_false("null" in localStorage);
});
test(function() {
localStorage.setItem("undefined", "test");
assert_true("undefined" in localStorage);
localStorage.removeItem(undefined, "test");
assert_false("undefined" in localStorage);
});
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,119 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_setItem</h1>
<div id="log"></div>
<script>
var test_error = { name: "test" };
test(function() {
localStorage.clear();
test(function() {
assert_false("name" in localStorage);
assert_false("age" in localStorage);
});
test(function() {
localStorage["name"] = "user1";
assert_true("name" in localStorage);
assert_equals(localStorage.length, 1, "localStorage.length")
assert_equals(localStorage.getItem("name"), "user1");
assert_equals(localStorage["name"], "user1");
});
test(function() {
localStorage["name"] = "user2";
assert_true("name" in localStorage);
assert_equals(localStorage.length, 1, "localStorage.length")
assert_equals(localStorage.getItem("name"), "user2");
assert_equals(localStorage["name"], "user2");
});
test(function() {
localStorage.setItem("name", "user3");
assert_true("name" in localStorage);
assert_equals(localStorage.length, 1, "localStorage.length")
assert_equals(localStorage.getItem("name"), "user3");
assert_equals(localStorage["name"], "user3");
});
test(function() {
localStorage.setItem("age", null);
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "null");
assert_equals(localStorage["age"], "null");
});
test(function() {
localStorage["age"] = null;
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "null");
assert_equals(localStorage["age"], "null");
});
test(function() {
localStorage.setItem("age", undefined);
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "undefined");
assert_equals(localStorage["age"], "undefined");
});
test(function() {
localStorage["age"] = undefined;
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "undefined");
assert_equals(localStorage["age"], "undefined");
});
test(function() {
assert_throws(test_error, function() {
localStorage.setItem("age",
{ toString: function() { throw test_error; } });
});
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "undefined");
assert_equals(localStorage["age"], "undefined");
});
test(function() {
assert_throws(test_error, function() {
localStorage["age"] =
{ toString: function() { throw test_error; } };
});
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "undefined");
assert_equals(localStorage["age"], "undefined");
});
test(function() {
localStorage.setItem(undefined, "test");
assert_true("undefined" in localStorage);
assert_equals(localStorage.length, 3, "localStorage.length")
assert_equals(localStorage.getItem("undefined"), "test");
assert_equals(localStorage["undefined"], "test");
});
test(function() {
localStorage[undefined] = "test2";
assert_true("undefined" in localStorage);
assert_equals(localStorage.length, 3, "localStorage.length")
assert_equals(localStorage.getItem("undefined"), "test2");
assert_equals(localStorage["undefined"], "test2");
});
test(function() {
localStorage.setItem(null, "test");
assert_true("null" in localStorage);
assert_equals(localStorage.length, 4, "localStorage.length")
assert_equals(localStorage.getItem("null"), "test");
assert_equals(localStorage["null"], "test");
});
test(function() {
localStorage[null] = "test2";
assert_true("null" in localStorage);
assert_equals(localStorage.length, 4, "localStorage.length")
assert_equals(localStorage.getItem("null"), "test2");
assert_equals(localStorage["null"], "test2");
});
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_clear</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
assert_not_equals(sessionStorage.name, undefined);
assert_equals(sessionStorage.length, 1);
sessionStorage.clear();
assert_equals(sessionStorage.name, undefined, "sessionStorage.name")
assert_equals(sessionStorage.length, 0, "sessionStorage.length")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_getItem</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("undefined", "foo");
sessionStorage.setItem("null", "bar");
sessionStorage.setItem("", "baz");
test(function() {
assert_equals(sessionStorage.length, 3);
}, "All 3 items should be added.");
test(function() {
assert_equals(sessionStorage["unknown"], undefined, "sessionStorage['unknown']")
assert_equals(sessionStorage["undefined"], "foo", "sessionStorage['undefined']")
assert_equals(sessionStorage["null"], "bar", "sessionStorage['null']")
assert_equals(sessionStorage[undefined], "foo", "sessionStorage[undefined]")
assert_equals(sessionStorage[null], "bar", "sessionStorage[null]")
assert_equals(sessionStorage[""], "baz", "sessionStorage['']")
}, "array access should be correct");
test(function() {
assert_equals(sessionStorage.getItem("undefined"), "foo", "sessionStorage.getItem('undefined')")
assert_equals(sessionStorage.getItem("null"), "bar", "sessionStorage.getItem('null')")
assert_equals(sessionStorage.getItem(undefined), "foo", "sessionStorage.getItem(undefined)")
assert_equals(sessionStorage.getItem(null), "bar", "sessionStorage.getItem(null)")
assert_equals(sessionStorage.getItem(""), "baz", "sessionStorage.getItem('')")
}, "getItem should be correct")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_in</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
assert_false("name" in sessionStorage);
sessionStorage["name"] = "user1";
assert_true("name" in sessionStorage);
});
test(function() {
sessionStorage.clear();
assert_false("name" in sessionStorage);
sessionStorage.setItem("name", "user1");
assert_true("name" in sessionStorage);
assert_equals(sessionStorage.name, "user1");
sessionStorage.removeItem("name");
assert_false("name" in sessionStorage);
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,36 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_index</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage["name"] = "user1";
sessionStorage["age"] = "42";
test(function() {
assert_equals(sessionStorage[-1], undefined);
assert_equals(sessionStorage[0], undefined);
assert_equals(sessionStorage[1], undefined);
assert_equals(sessionStorage[2], undefined);
})
test(function() {
assert_equals(sessionStorage["-1"], undefined);
assert_equals(sessionStorage["0"], undefined);
assert_equals(sessionStorage["1"], undefined);
assert_equals(sessionStorage["2"], undefined);
})
sessionStorage.setItem(1, "number");
test(function() {
assert_equals(sessionStorage[1], "number");
assert_equals(sessionStorage["1"], "number");
})
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_length</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
assert_equals(sessionStorage.length, 0, "sessionStorage.length")
sessionStorage["name"] = "user1";
sessionStorage["age"] = "20";
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_removeItem</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
assert_equals(sessionStorage.getItem("name"), "user1");
test(function() {
delete sessionStorage["name"];
delete sessionStorage["unknown"];
assert_equals(sessionStorage.getItem("name"), null, "sessionStorage.getItem('name')")
});
test(function() {
sessionStorage.setItem("null", "test");
assert_true("null" in sessionStorage);
sessionStorage.removeItem(null, "test");
assert_false("null" in sessionStorage);
});
test(function() {
sessionStorage.setItem("undefined", "test");
assert_true("undefined" in sessionStorage);
sessionStorage.removeItem(undefined, "test");
assert_false("undefined" in sessionStorage);
});
});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,119 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_setItem</h1>
<div id="log"></div>
<script>
var test_error = { name: "test" };
test(function() {
sessionStorage.clear();
test(function() {
assert_false("name" in sessionStorage);
assert_false("age" in sessionStorage);
});
test(function() {
sessionStorage["name"] = "user1";
assert_true("name" in sessionStorage);
assert_equals(sessionStorage.length, 1, "sessionStorage.length")
assert_equals(sessionStorage.getItem("name"), "user1");
assert_equals(sessionStorage["name"], "user1");
});
test(function() {
sessionStorage["name"] = "user2";
assert_true("name" in sessionStorage);
assert_equals(sessionStorage.length, 1, "sessionStorage.length")
assert_equals(sessionStorage.getItem("name"), "user2");
assert_equals(sessionStorage["name"], "user2");
});
test(function() {
sessionStorage.setItem("name", "user3");
assert_true("name" in sessionStorage);
assert_equals(sessionStorage.length, 1, "sessionStorage.length")
assert_equals(sessionStorage.getItem("name"), "user3");
assert_equals(sessionStorage["name"], "user3");
});
test(function() {
sessionStorage.setItem("age", null);
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "null");
assert_equals(sessionStorage["age"], "null");
});
test(function() {
sessionStorage["age"] = null;
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "null");
assert_equals(sessionStorage["age"], "null");
});
test(function() {
sessionStorage.setItem("age", undefined);
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "undefined");
assert_equals(sessionStorage["age"], "undefined");
});
test(function() {
sessionStorage["age"] = undefined;
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "undefined");
assert_equals(sessionStorage["age"], "undefined");
});
test(function() {
assert_throws(test_error, function() {
sessionStorage.setItem("age",
{ toString: function() { throw test_error; } });
});
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "undefined");
assert_equals(sessionStorage["age"], "undefined");
});
test(function() {
assert_throws(test_error, function() {
sessionStorage["age"] =
{ toString: function() { throw test_error; } };
});
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "undefined");
assert_equals(sessionStorage["age"], "undefined");
});
test(function() {
sessionStorage.setItem(undefined, "test");
assert_true("undefined" in sessionStorage);
assert_equals(sessionStorage.length, 3, "sessionStorage.length")
assert_equals(sessionStorage.getItem("undefined"), "test");
assert_equals(sessionStorage["undefined"], "test");
});
test(function() {
sessionStorage[undefined] = "test2";
assert_true("undefined" in sessionStorage);
assert_equals(sessionStorage.length, 3, "sessionStorage.length")
assert_equals(sessionStorage.getItem("undefined"), "test2");
assert_equals(sessionStorage["undefined"], "test2");
});
test(function() {
sessionStorage.setItem(null, "test");
assert_true("null" in sessionStorage);
assert_equals(sessionStorage.length, 4, "sessionStorage.length")
assert_equals(sessionStorage.getItem("null"), "test");
assert_equals(sessionStorage["null"], "test");
});
test(function() {
sessionStorage[null] = "test2";
assert_true("null" in sessionStorage);
assert_equals(sessionStorage.length, 4, "sessionStorage.length")
assert_equals(sessionStorage.getItem("null"), "test2");
assert_equals(sessionStorage["null"], "test2");
});
});
</script>
</body>
</html>

Просмотреть файл

@ -134,7 +134,8 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
nsIThreadJSContextStack* cxStack = nsContentUtils::ThreadJSContextStack();
NS_ASSERTION(cxStack, "Failed to get thread context stack!");
if (NS_FAILED(cxStack->GetSafeJSContext(&cx))) {
cx = cxStack->GetSafeJSContext();
if (!cx) {
NS_WARNING("Failed to get safe JSContext!");
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
mError = DOMError::CreateForNSResult(rv);

Просмотреть файл

@ -59,7 +59,6 @@ SDK_XPIDLSRCS = \
nsIDOMStorage.idl \
nsIDOMStorageObsolete.idl\
nsIDOMStorageEvent.idl \
nsIDOMStorageEventObsolete.idl \
nsIDOMStorageItem.idl \
nsIDOMStorageIndexedDB.idl \
$(NULL)

Просмотреть файл

@ -1,65 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Neil Deakin <enndeakin@sympatico.ca>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
#include "nsIDOMEvent.idl"
/**
* Interface for a client side storage. See
* http://www.whatwg.org/specs/web-apps/current-work/#scs-client-side
* for more information.
*
* Event sent to a window when a storage area changes.
*/
[scriptable, uuid(2b3b40fe-4734-4661-b7ff-dc555215db4e)]
interface nsIDOMStorageEventObsolete : nsIDOMEvent
{
/**
* Domain of the storage area which changed, or #session for
* session storage.
*/
readonly attribute DOMString domain;
/**
* Initialize a storage event.
*/
void initStorageEvent(in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
in DOMString domainArg);
};

Просмотреть файл

@ -791,14 +791,14 @@ ContentChild::GetIndexedDBPath()
bool
ContentChild::RecvGarbageCollect()
{
nsJSContext::GarbageCollectNow(js::gcreason::DOM_IPC);
nsJSContext::GarbageCollectNow(js::gcreason::DOM_IPC, nsGCNormal, true);
return true;
}
bool
ContentChild::RecvCycleCollect()
{
nsJSContext::GarbageCollectNow(js::gcreason::DOM_IPC);
nsJSContext::GarbageCollectNow(js::gcreason::DOM_IPC, nsGCNormal, true);
nsJSContext::CycleCollectNow();
return true;
}

Просмотреть файл

@ -1985,8 +1985,7 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
return;
}
JSContext *cx;
stack->GetSafeJSContext(&cx);
JSContext* cx = stack->GetSafeJSContext();
if (!cx) {
NS_ERROR("No safe JS context available!");

Просмотреть файл

@ -1349,10 +1349,10 @@ _getstringidentifier(const NPUTF8* name)
if (!stack)
return NULL;
JSContext *cx = nsnull;
stack->GetSafeJSContext(&cx);
if (!cx)
JSContext* cx = stack->GetSafeJSContext();
if (!cx) {
return NULL;
}
JSAutoRequest ar(cx);
return doGetIdentifier(cx, name);
@ -1370,10 +1370,10 @@ _getstringidentifiers(const NPUTF8** names, int32_t nameCount,
if (!stack)
return;
JSContext *cx = nsnull;
stack->GetSafeJSContext(&cx);
if (!cx)
JSContext* cx = stack->GetSafeJSContext();
if (!cx) {
return;
}
JSAutoRequest ar(cx);

Просмотреть файл

@ -69,8 +69,7 @@ PluginIdentifierParent::RecvRetain()
return false;
}
JSContext *cx = nsnull;
stack->GetSafeJSContext(&cx);
JSContext* cx = stack->GetSafeJSContext();
if (!cx) {
return false;
}

Просмотреть файл

@ -615,23 +615,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMStorage)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StorageObsolete)
NS_INTERFACE_MAP_END
nsresult
NS_NewDOMStorage(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
nsDOMStorage* storage = new nsDOMStorage();
if (!storage)
return NS_ERROR_OUT_OF_MEMORY;
return storage->QueryInterface(aIID, aResult);
}
nsresult
NS_NewDOMStorage2(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
nsDOMStorage2* storage = new nsDOMStorage2();
if (!storage)
return NS_ERROR_OUT_OF_MEMORY;
return storage->QueryInterface(aIID, aResult);
}
@ -1821,16 +1808,8 @@ already_AddRefed<nsIDOMStorage>
nsDOMStorage2::Fork(const nsSubstring &aDocumentURI)
{
nsRefPtr<nsDOMStorage2> storage = new nsDOMStorage2();
if (!storage)
return nsnull;
nsresult rv = storage->InitAsSessionStorageFork(mPrincipal, aDocumentURI, mStorage);
if (NS_FAILED(rv))
return nsnull;
nsIDOMStorage* result = static_cast<nsIDOMStorage*>(storage.get());
storage.forget();
return result;
storage->InitAsSessionStorageFork(mPrincipal, aDocumentURI, mStorage);
return storage.forget();
}
bool nsDOMStorage2::IsForkOf(nsIDOMStorage* aThat)
@ -1842,14 +1821,12 @@ bool nsDOMStorage2::IsForkOf(nsIDOMStorage* aThat)
return mStorage == storage->mStorage;
}
nsresult
nsDOMStorage2::InitAsSessionStorageFork(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI, nsIDOMStorageObsolete* aStorage)
void
nsDOMStorage2::InitAsSessionStorageFork(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI, nsDOMStorage* aStorage)
{
mPrincipal = aPrincipal;
mDocumentURI = aDocumentURI;
mStorage = static_cast<nsDOMStorage*>(aStorage);
return NS_OK;
mStorage = aStorage;
}
nsTArray<nsString> *
@ -2193,41 +2170,3 @@ nsDOMStorageEvent::InitFromCtor(const nsAString& aType,
return InitStorageEvent(aType, d.bubbles, d.cancelable, d.key, d.oldValue,
d.newValue, d.url, d.storageArea);
}
// Obsolete globalStorage event
DOMCI_DATA(StorageEventObsolete, nsDOMStorageEventObsolete)
// QueryInterface implementation for nsDOMStorageEventObsolete
NS_INTERFACE_MAP_BEGIN(nsDOMStorageEventObsolete)
NS_INTERFACE_MAP_ENTRY(nsIDOMStorageEventObsolete)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StorageEventObsolete)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(nsDOMStorageEventObsolete, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMStorageEventObsolete, nsDOMEvent)
NS_IMETHODIMP
nsDOMStorageEventObsolete::GetDomain(nsAString& aDomain)
{
// mDomain will be #session for session storage for events that fire
// due to a change in a session storage object.
aDomain = mDomain;
return NS_OK;
}
NS_IMETHODIMP
nsDOMStorageEventObsolete::InitStorageEvent(const nsAString& aTypeArg,
bool aCanBubbleArg,
bool aCancelableArg,
const nsAString& aDomainArg)
{
nsresult rv = InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
mDomain = aDomainArg;
return NS_OK;
}

Просмотреть файл

@ -54,7 +54,6 @@
#include "nsIDOMToString.h"
#include "nsDOMEvent.h"
#include "nsIDOMStorageEvent.h"
#include "nsIDOMStorageEventObsolete.h"
#include "nsIDOMStorageManager.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIObserver.h"
@ -387,11 +386,6 @@ public:
nsIDOMStorageItem* GetNamedItem(const nsAString& aKey, nsresult* aResult);
static nsDOMStorage* FromSupports(nsISupports* aSupports)
{
return static_cast<nsDOMStorage*>(static_cast<nsIDOMStorageObsolete*>(aSupports));
}
nsresult SetSecure(const nsAString& aKey, bool aSecure)
{
return mStorageImpl->SetSecure(aKey, aSecure);
@ -448,9 +442,9 @@ public:
void BroadcastChangeNotification(const nsSubstring &aKey,
const nsSubstring &aOldValue,
const nsSubstring &aNewValue);
nsresult InitAsSessionStorageFork(nsIPrincipal *aPrincipal,
const nsSubstring &aDocumentURI,
nsIDOMStorageObsolete* aStorage);
void InitAsSessionStorageFork(nsIPrincipal *aPrincipal,
const nsSubstring &aDocumentURI,
nsDOMStorage* aStorage);
private:
// storages bound to an origin hold the principal to
@ -555,30 +549,6 @@ protected:
nsCOMPtr<nsIDOMStorage> mStorageArea;
};
class nsDOMStorageEventObsolete : public nsDOMEvent,
public nsIDOMStorageEventObsolete
{
public:
nsDOMStorageEventObsolete()
: nsDOMEvent(nsnull, nsnull)
{
}
virtual ~nsDOMStorageEventObsolete()
{
}
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMSTORAGEEVENTOBSOLETE
NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)
protected:
nsString mDomain;
};
nsresult
NS_NewDOMStorage(nsISupports* aOuter, REFNSIID aIID, void** aResult);
nsresult
NS_NewDOMStorage2(nsISupports* aOuter, REFNSIID aIID, void** aResult);

Просмотреть файл

@ -215,16 +215,15 @@ SystemWorkerManager::Init()
NS_ASSERTION(NS_IsMainThread(), "We can only initialize on the main thread");
NS_ASSERTION(!mShutdown, "Already shutdown!");
JSContext *cx;
nsresult rv = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
NS_ENSURE_SUCCESS(rv, rv);
JSContext* cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
nsCxPusher pusher;
if (!cx || !pusher.Push(cx, false)) {
if (!pusher.Push(cx, false)) {
return NS_ERROR_FAILURE;
}
rv = InitRIL(cx);
nsresult rv = InitRIL(cx);
NS_ENSURE_SUCCESS(rv, rv);
rv = InitWifi(cx);

Просмотреть файл

@ -1336,8 +1336,8 @@ RuntimeService::AutoSafeJSContext::GetSafeContext()
nsIThreadJSContextStack* stack = nsContentUtils::ThreadJSContextStack();
NS_ASSERTION(stack, "This should never be null!");
JSContext* cx;
if (NS_FAILED(stack->GetSafeJSContext(&cx))) {
JSContext* cx = stack->GetSafeJSContext();
if (!cx) {
NS_ERROR("Couldn't get safe JSContext!");
return nsnull;
}

Просмотреть файл

@ -46,6 +46,7 @@
#include "nsIDOMElement.h"
#include "nsIAtom.h"
#include "nsGkAtoms.h"
#include "nsIClipboard.h"
@ -63,8 +64,7 @@ nsresult GetListState(nsIHTMLEditor* aEditor, bool* aMixed,
nsAString& aLocalName);
nsresult RemoveOneProperty(nsIHTMLEditor* aEditor, const nsAString& aProp);
nsresult RemoveTextProperty(nsIHTMLEditor* aEditor, const nsAString& aProp);
nsresult SetTextProperty(nsIEditor *aEditor, const PRUnichar *prop,
const PRUnichar *attr, const PRUnichar *value);
nsresult SetTextProperty(nsIHTMLEditor *aEditor, const nsAString& aProp);
//defines
@ -282,7 +282,7 @@ nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
rv = RemoveTextProperty(htmlEditor, tagName);
}
if (NS_SUCCEEDED(rv))
rv = SetTextProperty(aEditor, tagName.get(), nsnull, nsnull);
rv = SetTextProperty(htmlEditor, tagName);
aEditor->EndTransaction();
}
@ -723,32 +723,27 @@ nsFontFaceStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
nsresult rv;
nsCOMPtr<nsIAtom> ttAtom = do_GetAtom("tt");
nsCOMPtr<nsIAtom> fontAtom = do_GetAtom("font");
if (newState.EqualsLiteral("tt"))
{
// The old "teletype" attribute
rv = htmlEditor->SetInlineProperty(ttAtom, EmptyString(),
EmptyString());
if (newState.EqualsLiteral("tt")) {
// The old "teletype" attribute
nsresult rv = htmlEditor->SetInlineProperty(nsGkAtoms::tt, EmptyString(),
EmptyString());
NS_ENSURE_SUCCESS(rv, rv);
// Clear existing font face
rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face"));
return htmlEditor->RemoveInlineProperty(nsGkAtoms::font,
NS_LITERAL_STRING("face"));
}
else
{
// Remove any existing TT nodes
rv = htmlEditor->RemoveInlineProperty(ttAtom, EmptyString());
if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {
rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face"));
} else {
rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("face"),
newState);
}
// Remove any existing TT nodes
nsresult rv = htmlEditor->RemoveInlineProperty(nsGkAtoms::tt, EmptyString());
NS_ENSURE_SUCCESS(rv, rv);
if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {
return htmlEditor->RemoveInlineProperty(nsGkAtoms::font,
NS_LITERAL_STRING("face"));
}
return rv;
return htmlEditor->SetInlineProperty(nsGkAtoms::font,
NS_LITERAL_STRING("face"), newState);
}
nsFontSizeStateCommand::nsFontSizeStateCommand()
@ -802,29 +797,22 @@ nsFontSizeStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_INVALID_ARG);
nsresult rv;
nsCOMPtr<nsIAtom> fontAtom = do_GetAtom("font");
if (newState.IsEmpty() ||
newState.EqualsLiteral("normal") ||
newState.EqualsLiteral("medium")) {
// remove any existing font size, big or small
rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("size"));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAtom> bigAtom = do_GetAtom("big");
rv = htmlEditor->RemoveInlineProperty(bigAtom, EmptyString());
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAtom> smallAtom = do_GetAtom("small");
rv = htmlEditor->RemoveInlineProperty(smallAtom, EmptyString());
NS_ENSURE_SUCCESS(rv, rv);
} else {
// set the size
rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("size"),
newState);
if (!newState.IsEmpty() &&
!newState.EqualsLiteral("normal") &&
!newState.EqualsLiteral("medium")) {
return htmlEditor->SetInlineProperty(nsGkAtoms::font,
NS_LITERAL_STRING("size"), newState);
}
return rv;
// remove any existing font size, big or small
nsresult rv = htmlEditor->RemoveInlineProperty(nsGkAtoms::font,
NS_LITERAL_STRING("size"));
NS_ENSURE_SUCCESS(rv, rv);
rv = htmlEditor->RemoveInlineProperty(nsGkAtoms::big, EmptyString());
NS_ENSURE_SUCCESS(rv, rv);
return htmlEditor->RemoveInlineProperty(nsGkAtoms::small, EmptyString());
}
nsFontColorStateCommand::nsFontColorStateCommand()
@ -844,14 +832,13 @@ nsFontColorStateCommand::GetCurrentState(nsIEditor *aEditor,
bool outMixed;
nsAutoString outStateString;
nsresult rv = htmlEditor->GetFontColorState(&outMixed, outStateString);
if (NS_SUCCEEDED(rv))
{
nsCAutoString tOutStateString;
tOutStateString.AssignWithConversion(outStateString);
aParams->SetBooleanValue(STATE_MIXED,outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
}
return rv;
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString tOutStateString;
tOutStateString.AssignWithConversion(outStateString);
aParams->SetBooleanValue(STATE_MIXED, outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
return NS_OK;
}
nsresult
@ -861,17 +848,13 @@ nsFontColorStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
nsresult rv;
nsCOMPtr<nsIAtom> fontAtom = do_GetAtom("font");
if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {
rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("color"));
} else {
rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("color"),
newState);
return htmlEditor->RemoveInlineProperty(nsGkAtoms::font,
NS_LITERAL_STRING("color"));
}
return rv;
return htmlEditor->SetInlineProperty(nsGkAtoms::font,
NS_LITERAL_STRING("color"), newState);
}
nsHighlightColorStateCommand::nsHighlightColorStateCommand()
@ -890,14 +873,13 @@ nsHighlightColorStateCommand::GetCurrentState(nsIEditor *aEditor,
bool outMixed;
nsAutoString outStateString;
nsresult rv = htmlEditor->GetHighlightColorState(&outMixed, outStateString);
if (NS_SUCCEEDED(rv))
{
nsCAutoString tOutStateString;
tOutStateString.AssignWithConversion(outStateString);
aParams->SetBooleanValue(STATE_MIXED,outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
}
return rv;
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString tOutStateString;
tOutStateString.AssignWithConversion(outStateString);
aParams->SetBooleanValue(STATE_MIXED, outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
return NS_OK;
}
nsresult
@ -907,18 +889,14 @@ nsHighlightColorStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
nsresult rv;
nsCOMPtr<nsIAtom> fontAtom = do_GetAtom("font");
if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {
// rv = RemoveOneProperty(htmlEditor, NS_LITERAL_STRING("font"), NS_LITERAL_STRING("bgcolor"));
rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("bgcolor"));
} else {
rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("bgcolor"),
newState);
return htmlEditor->RemoveInlineProperty(nsGkAtoms::font,
NS_LITERAL_STRING("bgcolor"));
}
return rv;
return htmlEditor->SetInlineProperty(nsGkAtoms::font,
NS_LITERAL_STRING("bgcolor"),
newState);
}
NS_IMETHODIMP
@ -952,14 +930,13 @@ nsBackgroundColorStateCommand::GetCurrentState(nsIEditor *aEditor,
bool outMixed;
nsAutoString outStateString;
nsresult rv = htmlEditor->GetBackgroundColorState(&outMixed, outStateString);
if (NS_SUCCEEDED(rv))
{
nsCAutoString tOutStateString;
tOutStateString.AssignWithConversion(outStateString);
aParams->SetBooleanValue(STATE_MIXED,outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
}
return rv;
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString tOutStateString;
tOutStateString.AssignWithConversion(outStateString);
aParams->SetBooleanValue(STATE_MIXED, outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
return NS_OK;
}
nsresult
@ -1096,14 +1073,7 @@ nsAbsolutePositioningCommand::ToggleState(nsIEditor *aEditor, const char* aTagNa
nsresult rv = htmlEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
NS_ENSURE_SUCCESS(rv, rv);
if (elt) {
// we have to remove positioning on an element
rv = htmlEditor->AbsolutePositionSelection(false);
}
else {
rv = htmlEditor->AbsolutePositionSelection(true);
}
return rv;
return htmlEditor->AbsolutePositionSelection(!elt);
}
@ -1589,25 +1559,13 @@ RemoveTextProperty(nsIHTMLEditor* aEditor, const nsAString& aProp)
// the name of the attribute here should be the contents of the appropriate
// tag, e.g. 'b' for bold, 'i' for italics.
nsresult
SetTextProperty(nsIEditor *aEditor, const PRUnichar *prop,
const PRUnichar *attr, const PRUnichar *value)
SetTextProperty(nsIHTMLEditor* aEditor, const nsAString& aProp)
{
//static initialization
static const PRUnichar sEmptyStr = PRUnichar('\0');
NS_ENSURE_TRUE(aEditor, NS_ERROR_NOT_INITIALIZED);
MOZ_ASSERT(aEditor);
/// XXX Hack alert! Look in nsIEditProperty.h for this
nsCOMPtr<nsIAtom> styleAtom = do_GetAtom(prop);
NS_ENSURE_TRUE( styleAtom, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsIAtom> styleAtom = do_GetAtom(aProp);
NS_ENSURE_TRUE(styleAtom, NS_ERROR_OUT_OF_MEMORY);
nsresult err = NS_NOINTERFACE;
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor,&err);
if (htmlEditor)
err = htmlEditor->SetInlineProperty(styleAtom,
nsDependentString(attr?attr:&sEmptyStr),
nsDependentString(value?value:&sEmptyStr));
return err;
return aEditor->SetInlineProperty(styleAtom, EmptyString(), EmptyString());
}

Просмотреть файл

@ -1103,39 +1103,28 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
}
NS_IMETHODIMP
nsEditor::EndOfDocument()
nsEditor::EndOfDocument()
{
if (!mDocWeak) { return NS_ERROR_NOT_INITIALIZED; }
nsresult res;
NS_ENSURE_TRUE(mDocWeak, NS_ERROR_NOT_INITIALIZED);
// get selection
nsCOMPtr<nsISelection> selection;
res = GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(res, res);
nsresult rv = GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
// get the root element
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(GetRoot());
nsINode* node = GetRoot();
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> child;
nsINode* child = node->GetLastChild();
do {
node->GetLastChild(getter_AddRefs(child));
while (child && IsContainer(child->AsDOMNode())) {
node = child;
child = node->GetLastChild();
}
if (child) {
if (IsContainer(child)) {
node = child;
} else {
break;
}
}
} while (child);
PRUint32 length = 0;
res = GetLengthOfDOMNode(node, length);
NS_ENSURE_SUCCESS(res, res);
return selection->Collapse(node, (PRInt32)length);
PRUint32 length = node->Length();
return selection->CollapseNative(node, PRInt32(length));
}
NS_IMETHODIMP
@ -3162,39 +3151,53 @@ nsEditor::GetPriorNode(nsIDOMNode *aParentNode,
bool bNoBlockCrossing,
nsIContent *aActiveEditorRoot)
{
// just another version of GetPriorNode that takes a {parent, offset}
// instead of a node
if (!aParentNode || !aResultNode) { return NS_ERROR_NULL_POINTER; }
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
*aResultNode = nsnull;
// if we are at beginning of node, or it is a textnode, then just look before it
if (!aOffset || IsTextNode(aParentNode))
{
if (bNoBlockCrossing && IsBlockNode(aParentNode))
{
// if we aren't allowed to cross blocks, don't look before this block
return NS_OK;
nsCOMPtr<nsINode> parentNode = do_QueryInterface(aParentNode);
NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER);
*aResultNode = do_QueryInterface(GetPriorNode(parentNode, aOffset,
aEditableNode, bNoBlockCrossing,
aActiveEditorRoot));
return NS_OK;
}
nsIContent*
nsEditor::GetPriorNode(nsINode* aParentNode,
PRInt32 aOffset,
bool aEditableNode,
bool aNoBlockCrossing,
nsIContent* aActiveEditorRoot)
{
MOZ_ASSERT(aParentNode);
// If we are at the beginning of the node, or it is a text node, then just
// look before it.
if (!aOffset || aParentNode->NodeType() == nsIDOMNode::TEXT_NODE) {
if (aNoBlockCrossing && IsBlockNode(aParentNode)) {
// If we aren't allowed to cross blocks, don't look before this block.
return nsnull;
}
return GetPriorNode(aParentNode, aEditableNode, aResultNode,
bNoBlockCrossing, aActiveEditorRoot);
return GetPriorNode(aParentNode, aEditableNode,
aNoBlockCrossing, aActiveEditorRoot);
}
// else look before the child at 'aOffset'
nsCOMPtr<nsIDOMNode> child = GetChildAt(aParentNode, aOffset);
if (child)
return GetPriorNode(child, aEditableNode, aResultNode, bNoBlockCrossing,
if (nsIContent* child = aParentNode->GetChildAt(aOffset)) {
return GetPriorNode(child, aEditableNode, aNoBlockCrossing,
aActiveEditorRoot);
}
// unless there isn't one, in which case we are at the end of the node
// and want the deep-right child.
*aResultNode = GetRightmostChild(aParentNode, bNoBlockCrossing);
if (!*aResultNode || !aEditableNode || IsEditable(*aResultNode))
return NS_OK;
nsIContent* resultNode = GetRightmostChild(aParentNode, aNoBlockCrossing);
if (!resultNode || !aEditableNode || IsEditable(resultNode)) {
return resultNode;
}
// restart the search from the non-editable node we just found
nsCOMPtr<nsIDOMNode> notEditableNode = *aResultNode;
return GetPriorNode(notEditableNode, aEditableNode, aResultNode,
bNoBlockCrossing, aActiveEditorRoot);
return GetPriorNode(resultNode, aEditableNode, aNoBlockCrossing, aActiveEditorRoot);
}
@ -3206,58 +3209,68 @@ nsEditor::GetNextNode(nsIDOMNode *aParentNode,
bool bNoBlockCrossing,
nsIContent *aActiveEditorRoot)
{
// just another version of GetNextNode that takes a {parent, offset}
// instead of a node
if (!aParentNode || !aResultNode) { return NS_ERROR_NULL_POINTER; }
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
*aResultNode = nsnull;
nsCOMPtr<nsINode> parentNode = do_QueryInterface(aParentNode);
NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER);
*aResultNode = do_QueryInterface(GetNextNode(parentNode, aOffset,
aEditableNode, bNoBlockCrossing,
aActiveEditorRoot));
return NS_OK;
}
nsIContent*
nsEditor::GetNextNode(nsINode* aParentNode,
PRInt32 aOffset,
bool aEditableNode,
bool aNoBlockCrossing,
nsIContent* aActiveEditorRoot)
{
MOZ_ASSERT(aParentNode);
// if aParentNode is a text node, use its location instead
if (IsTextNode(aParentNode))
{
nsCOMPtr<nsIDOMNode> parent;
nsEditor::GetNodeLocation(aParentNode, address_of(parent), &aOffset);
if (aParentNode->NodeType() == nsIDOMNode::TEXT_NODE) {
nsINode* parent = aParentNode->GetNodeParent();
NS_ENSURE_TRUE(parent, nsnull);
aOffset = parent->IndexOf(aParentNode) + 1; // _after_ the text node
aParentNode = parent;
aOffset++; // _after_ the text node
}
// look at the child at 'aOffset'
nsCOMPtr<nsIDOMNode> child = GetChildAt(aParentNode, aOffset);
if (child)
{
if (bNoBlockCrossing && IsBlockNode(child))
{
*aResultNode = child; // return this block
return NS_OK;
}
*aResultNode = GetLeftmostChild(child, bNoBlockCrossing);
if (!*aResultNode)
{
*aResultNode = child;
return NS_OK;
}
if (!IsDescendantOfBody(*aResultNode))
{
*aResultNode = nsnull;
return NS_OK;
nsIContent* child = aParentNode->GetChildAt(aOffset);
if (child) {
if (aNoBlockCrossing && IsBlockNode(child)) {
return child;
}
if (!aEditableNode || IsEditable(*aResultNode))
return NS_OK;
nsIContent* resultNode = GetLeftmostChild(child, aNoBlockCrossing);
if (!resultNode) {
return child;
}
if (!IsDescendantOfBody(resultNode)) {
return nsnull;
}
if (!aEditableNode || IsEditable(resultNode)) {
return resultNode;
}
// restart the search from the non-editable node we just found
nsCOMPtr<nsIDOMNode> notEditableNode = do_QueryInterface(*aResultNode);
return GetNextNode(notEditableNode, aEditableNode, aResultNode,
bNoBlockCrossing, aActiveEditorRoot);
return GetNextNode(resultNode, aEditableNode, aNoBlockCrossing,
aActiveEditorRoot);
}
// unless there isn't one, in which case we are at the end of the node
// and want the next one.
if (bNoBlockCrossing && IsBlockNode(aParentNode))
{
if (aNoBlockCrossing && IsBlockNode(aParentNode)) {
// don't cross out of parent block
return NS_OK;
}
return GetNextNode(aParentNode, aEditableNode, aResultNode, bNoBlockCrossing,
return GetNextNode(aParentNode, aEditableNode, aNoBlockCrossing,
aActiveEditorRoot);
}
@ -3269,22 +3282,33 @@ nsEditor::GetPriorNode(nsIDOMNode *aCurrentNode,
bool bNoBlockCrossing,
nsIContent *aActiveEditorRoot)
{
if (!aCurrentNode || !aResultNode) { return NS_ERROR_NULL_POINTER; }
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode);
NS_ENSURE_TRUE(currentNode, NS_ERROR_NULL_POINTER);
if (!IsDescendantOfBody(currentNode) ||
*aResultNode = do_QueryInterface(GetPriorNode(currentNode, aEditableNode,
bNoBlockCrossing,
aActiveEditorRoot));
return NS_OK;
}
nsIContent*
nsEditor::GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
bool aNoBlockCrossing /* = false */,
nsIContent* aActiveEditorRoot /* = null */)
{
MOZ_ASSERT(aCurrentNode);
if (!IsDescendantOfBody(aCurrentNode) ||
(aActiveEditorRoot &&
!nsContentUtils::ContentIsDescendantOf(currentNode,
!nsContentUtils::ContentIsDescendantOf(aCurrentNode,
aActiveEditorRoot))) {
*aResultNode = nsnull;
return NS_OK;
return nsnull;
}
*aResultNode =
do_QueryInterface(FindNode(currentNode, false, aEditableNode,
bNoBlockCrossing, aActiveEditorRoot));
return NS_OK;
return FindNode(aCurrentNode, false, aEditableNode, aNoBlockCrossing,
aActiveEditorRoot);
}
nsIContent*
@ -3610,6 +3634,9 @@ nsEditor::IsContainer(nsIDOMNode *aNode)
bool
nsEditor::IsTextInDirtyFrameVisible(nsIContent *aNode)
{
MOZ_ASSERT(aNode);
MOZ_ASSERT(aNode->NodeType() == nsIDOMNode::TEXT_NODE);
// virtual method
//
// If this is a simple non-html editor,

Просмотреть файл

@ -461,6 +461,9 @@ public:
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false,
nsIContent *aActiveEditorRoot = nsnull);
nsIContent* GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
bool aNoBlockCrossing = false,
nsIContent* aActiveEditorRoot = nsnull);
// and another version that takes a {parent,offset} pair rather than a node
nsresult GetPriorNode(nsIDOMNode *aParentNode,
@ -469,7 +472,13 @@ public:
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false,
nsIContent *aActiveEditorRoot = nsnull);
nsIContent* GetPriorNode(nsINode* aParentNode,
PRInt32 aOffset,
bool aEditableNode,
bool aNoBlockCrossing = false,
nsIContent* aActiveEditorRoot = nsnull);
/** get the node immediately after to aCurrentNode
* @param aCurrentNode the node from which we start the search
* @param aEditableNode if true, only return an editable node
@ -494,6 +503,11 @@ public:
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false,
nsIContent *aActiveEditorRoot = nsnull);
nsIContent* GetNextNode(nsINode* aParentNode,
PRInt32 aOffset,
bool aEditableNode,
bool aNoBlockCrossing = false,
nsIContent* aActiveEditorRoot = nsnull);
// Helper for GetNextNode and GetPriorNode
nsIContent* FindNode(nsINode *aCurrentNode,
@ -554,6 +568,9 @@ public:
bool IsEditable(nsIDOMNode *aNode);
bool IsEditable(nsIContent *aNode);
/**
* aNode must be a non-null text node.
*/
virtual bool IsTextInDirtyFrameVisible(nsIContent *aNode);
/** returns true if aNode is a MozEditorBogus node */

Просмотреть файл

@ -154,68 +154,58 @@ void TypeInState::Reset()
}
nsresult TypeInState::SetProp(nsIAtom *aProp, const nsString &aAttr, const nsString &aValue)
void
TypeInState::SetProp(nsIAtom* aProp, const nsAString& aAttr,
const nsAString& aValue)
{
// special case for big/small, these nest
if (nsEditProperty::big == aProp)
{
if (nsEditProperty::big == aProp) {
mRelativeFontSize++;
return NS_OK;
return;
}
if (nsEditProperty::small == aProp)
{
if (nsEditProperty::small == aProp) {
mRelativeFontSize--;
return NS_OK;
return;
}
PRInt32 index;
PropItem *item;
if (IsPropSet(aProp,aAttr,nsnull,index))
{
if (IsPropSet(aProp, aAttr, NULL, index)) {
// if it's already set, update the value
item = mSetArray[index];
item->value = aValue;
mSetArray[index]->value = aValue;
return;
}
else
{
// make a new propitem
item = new PropItem(aProp,aAttr,aValue);
NS_ENSURE_TRUE(item, NS_ERROR_OUT_OF_MEMORY);
// add it to the list of set properties
mSetArray.AppendElement(item);
// remove it from the list of cleared properties, if we have a match
RemovePropFromClearedList(aProp,aAttr);
}
return NS_OK;
// Make a new propitem and add it to the list of set properties.
mSetArray.AppendElement(new PropItem(aProp, aAttr, aValue));
// remove it from the list of cleared properties, if we have a match
RemovePropFromClearedList(aProp, aAttr);
}
nsresult TypeInState::ClearAllProps()
void
TypeInState::ClearAllProps()
{
// null prop means "all" props
return ClearProp(nsnull,EmptyString());
ClearProp(nsnull, EmptyString());
}
nsresult TypeInState::ClearProp(nsIAtom *aProp, const nsString &aAttr)
void
TypeInState::ClearProp(nsIAtom* aProp, const nsAString& aAttr)
{
// if it's already cleared we are done
if (IsPropCleared(aProp,aAttr)) return NS_OK;
if (IsPropCleared(aProp, aAttr)) {
return;
}
// make a new propitem
PropItem *item = new PropItem(aProp,aAttr,EmptyString());
NS_ENSURE_TRUE(item, NS_ERROR_OUT_OF_MEMORY);
PropItem* item = new PropItem(aProp, aAttr, EmptyString());
// remove it from the list of set properties, if we have a match
RemovePropFromSetList(aProp,aAttr);
RemovePropFromSetList(aProp, aAttr);
// add it to the list of cleared properties
mClearedArray.AppendElement(item);
return NS_OK;
}
@ -223,47 +213,46 @@ nsresult TypeInState::ClearProp(nsIAtom *aProp, const nsString &aAttr)
* TakeClearProperty: hands back next property item on the clear list.
* caller assumes ownership of PropItem and must delete it.
*/
nsresult TypeInState::TakeClearProperty(PropItem **outPropItem)
PropItem*
TypeInState::TakeClearProperty()
{
NS_ENSURE_TRUE(outPropItem, NS_ERROR_NULL_POINTER);
*outPropItem = nsnull;
PRUint32 count = mClearedArray.Length();
if (count)
{
count--; // indizes are zero based
*outPropItem = mClearedArray[count];
mClearedArray.RemoveElementAt(count);
if (!count) {
return NULL;
}
return NS_OK;
--count; // indices are zero based
PropItem* propItem = mClearedArray[count];
mClearedArray.RemoveElementAt(count);
return propItem;
}
/***************************************************************************
* TakeSetProperty: hands back next poroperty item on the set list.
* caller assumes ownership of PropItem and must delete it.
*/
nsresult TypeInState::TakeSetProperty(PropItem **outPropItem)
PropItem*
TypeInState::TakeSetProperty()
{
NS_ENSURE_TRUE(outPropItem, NS_ERROR_NULL_POINTER);
*outPropItem = nsnull;
PRUint32 count = mSetArray.Length();
if (count)
{
count--; // indizes are zero based
*outPropItem = mSetArray[count];
mSetArray.RemoveElementAt(count);
if (!count) {
return NULL;
}
return NS_OK;
count--; // indices are zero based
PropItem* propItem = mSetArray[count];
mSetArray.RemoveElementAt(count);
return propItem;
}
//**************************************************************************
// TakeRelativeFontSize: hands back relative font value, which is then
// cleared out.
nsresult TypeInState::TakeRelativeFontSize(PRInt32 *outRelSize)
PRInt32
TypeInState::TakeRelativeFontSize()
{
NS_ENSURE_TRUE(outRelSize, NS_ERROR_NULL_POINTER);
*outRelSize = mRelativeFontSize;
PRInt32 relSize = mRelativeFontSize;
mRelativeFontSize = 0;
return NS_OK;
return relSize;
}
nsresult TypeInState::GetTypingState(bool &isSet, bool &theSetting, nsIAtom *aProp)
@ -300,8 +289,8 @@ nsresult TypeInState::GetTypingState(bool &isSet,
* protected methods
*******************************************************************/
nsresult TypeInState::RemovePropFromSetList(nsIAtom *aProp,
const nsString &aAttr)
nsresult TypeInState::RemovePropFromSetList(nsIAtom* aProp,
const nsAString& aAttr)
{
PRInt32 index;
if (!aProp)
@ -322,8 +311,8 @@ nsresult TypeInState::RemovePropFromSetList(nsIAtom *aProp,
}
nsresult TypeInState::RemovePropFromClearedList(nsIAtom *aProp,
const nsString &aAttr)
nsresult TypeInState::RemovePropFromClearedList(nsIAtom* aProp,
const nsAString& aAttr)
{
PRInt32 index;
if (FindPropInList(aProp, aAttr, nsnull, mClearedArray, index))
@ -335,19 +324,19 @@ nsresult TypeInState::RemovePropFromClearedList(nsIAtom *aProp,
}
bool TypeInState::IsPropSet(nsIAtom *aProp,
const nsString &aAttr,
nsString* outValue)
bool TypeInState::IsPropSet(nsIAtom *aProp,
const nsAString& aAttr,
nsAString* outValue)
{
PRInt32 i;
return IsPropSet(aProp, aAttr, outValue, i);
}
bool TypeInState::IsPropSet(nsIAtom *aProp,
const nsString &aAttr,
nsString *outValue,
PRInt32 &outIndex)
bool TypeInState::IsPropSet(nsIAtom* aProp,
const nsAString& aAttr,
nsAString* outValue,
PRInt32& outIndex)
{
// linear search. list should be short.
PRUint32 i, count = mSetArray.Length();
@ -366,17 +355,17 @@ bool TypeInState::IsPropSet(nsIAtom *aProp,
}
bool TypeInState::IsPropCleared(nsIAtom *aProp,
const nsString &aAttr)
bool TypeInState::IsPropCleared(nsIAtom* aProp,
const nsAString& aAttr)
{
PRInt32 i;
return IsPropCleared(aProp, aAttr, i);
}
bool TypeInState::IsPropCleared(nsIAtom *aProp,
const nsString &aAttr,
PRInt32 &outIndex)
bool TypeInState::IsPropCleared(nsIAtom* aProp,
const nsAString& aAttr,
PRInt32& outIndex)
{
if (FindPropInList(aProp, aAttr, nsnull, mClearedArray, outIndex))
return true;

Просмотреть файл

@ -74,25 +74,25 @@ public:
// nsISelectionListener
NS_DECL_NSISELECTIONLISTENER
nsresult SetProp(nsIAtom *aProp, const nsString &aAttr, const nsString &aValue);
void SetProp(nsIAtom* aProp, const nsAString& aAttr, const nsAString& aValue);
nsresult ClearAllProps();
nsresult ClearProp(nsIAtom *aProp, const nsString &aAttr);
void ClearAllProps();
void ClearProp(nsIAtom* aProp, const nsAString& aAttr);
//**************************************************************************
// TakeClearProperty: hands back next property item on the clear list.
// caller assumes ownership of PropItem and must delete it.
nsresult TakeClearProperty(PropItem **outPropItem);
PropItem* TakeClearProperty();
//**************************************************************************
// TakeSetProperty: hands back next property item on the set list.
// caller assumes ownership of PropItem and must delete it.
nsresult TakeSetProperty(PropItem **outPropItem);
PropItem* TakeSetProperty();
//**************************************************************************
// TakeRelativeFontSize: hands back relative font value, which is then
// cleared out.
nsresult TakeRelativeFontSize(PRInt32 *outRelSize);
PRInt32 TakeRelativeFontSize();
nsresult GetTypingState(bool &isSet, bool &theSetting, nsIAtom *aProp);
nsresult GetTypingState(bool &isSet, bool &theSetting, nsIAtom *aProp,
@ -102,12 +102,12 @@ public:
protected:
nsresult RemovePropFromSetList(nsIAtom *aProp, const nsString &aAttr);
nsresult RemovePropFromClearedList(nsIAtom *aProp, const nsString &aAttr);
bool IsPropSet(nsIAtom *aProp, const nsString &aAttr, nsString* outValue);
bool IsPropSet(nsIAtom *aProp, const nsString &aAttr, nsString* outValue, PRInt32 &outIndex);
bool IsPropCleared(nsIAtom *aProp, const nsString &aAttr);
bool IsPropCleared(nsIAtom *aProp, const nsString &aAttr, PRInt32 &outIndex);
nsresult RemovePropFromSetList(nsIAtom* aProp, const nsAString& aAttr);
nsresult RemovePropFromClearedList(nsIAtom* aProp, const nsAString& aAttr);
bool IsPropSet(nsIAtom* aProp, const nsAString& aAttr, nsAString* outValue);
bool IsPropSet(nsIAtom* aProp, const nsAString& aAttr, nsAString* outValue, PRInt32& outIndex);
bool IsPropCleared(nsIAtom* aProp, const nsAString& aAttr);
bool IsPropCleared(nsIAtom* aProp, const nsAString& aAttr, PRInt32& outIndex);
nsTArray<PropItem*> mSetArray;
nsTArray<PropItem*> mClearedArray;

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше