mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Merge mozilla-central with electrolysis.
This commit is contained in:
commit
c161f955a7
16
Makefile.in
16
Makefile.in
@ -88,7 +88,7 @@ DIST_GARBAGE = config.cache config.log config.status config-defs.h \
|
||||
netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \
|
||||
$(topsrcdir)/.mozconfig.mk $(topsrcdir)/.mozconfig.out
|
||||
|
||||
default alldep all::
|
||||
default alldep all:: $(topsrcdir)/configure config.status
|
||||
$(RM) -rf $(DIST)/sdk
|
||||
$(RM) -rf $(DIST)/include
|
||||
$(RM) -rf $(DIST)/private
|
||||
@ -96,6 +96,20 @@ default alldep all::
|
||||
$(RM) -rf $(DIST)/bin/components
|
||||
$(RM) -rf _tests
|
||||
|
||||
$(topsrcdir)/configure: $(topsrcdir)/configure.in
|
||||
@echo "STOP! configure.in has changed, and your configure is out of date."
|
||||
@echo "Please rerun autoconf and re-configure your build directory."
|
||||
@echo "To ignore this message, touch 'configure' in the source directory,"
|
||||
@echo "but your build might not succeed."
|
||||
@exit 1
|
||||
|
||||
config.status: $(topsrcdir)/configure
|
||||
@echo "STOP! configure has changed and needs to be run in this build directory."
|
||||
@echo "Please rerun configure."
|
||||
@echo "To ignore this message, touch 'config.status' in the build directory,"
|
||||
@echo "but your build might not succeed."
|
||||
@exit 1
|
||||
|
||||
# Build pseudo-external modules first when export is explicitly called
|
||||
export::
|
||||
$(RM) -rf $(DIST)/sdk
|
||||
|
@ -39,14 +39,12 @@
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIAccessibleRetrieval.idl"
|
||||
|
||||
interface nsIAccessibleEventListener;
|
||||
interface nsIDocument;
|
||||
interface nsIFrame;
|
||||
interface nsObjectFrame;
|
||||
interface nsIContent;
|
||||
interface nsITimer;
|
||||
|
||||
[uuid(61098f48-4fcc-4b05-9cf3-c11b8efbe682)]
|
||||
[uuid(e0498def-1552-4763-8c47-6c6cc36c7aa0)]
|
||||
interface nsIAccessibilityService : nsIAccessibleRetrieval
|
||||
{
|
||||
nsIAccessible createOuterDocAccessible(in nsIDOMNode aNode);
|
||||
@ -113,16 +111,6 @@ interface nsIAccessibilityService : nsIAccessibleRetrieval
|
||||
void invalidateSubtreeFor(in nsIPresShell aPresShell, in nsIContent aContent,
|
||||
in PRUint32 aChangeType);
|
||||
|
||||
/**
|
||||
* An internal doc load event has occured. Handle the event and remove it from the list.
|
||||
* @param aTimer The timer created to handle this doc load event
|
||||
* @param aClosure The nsIWebProgress* for the load event
|
||||
* @param aEventType The type of load event, one of: nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_START,
|
||||
* nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE or
|
||||
* nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED
|
||||
*/
|
||||
void processDocLoadEvent(in nsITimer aTimer, in voidPtr aClosure, in PRUint32 aEventType);
|
||||
|
||||
/**
|
||||
* Notify accessibility that anchor jump has been accomplished to the given
|
||||
* target. Used by layout.
|
||||
|
@ -64,7 +64,6 @@
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsIObserverService.h"
|
||||
@ -75,7 +74,6 @@
|
||||
|
||||
nsIStringBundle *nsAccessNode::gStringBundle = 0;
|
||||
nsIStringBundle *nsAccessNode::gKeyStringBundle = 0;
|
||||
nsITimer *nsAccessNode::gDoCommandTimer = 0;
|
||||
nsIDOMNode *nsAccessNode::gLastFocusedNode = 0;
|
||||
#ifdef DEBUG
|
||||
PRBool nsAccessNode::gIsAccessibilityActive = PR_FALSE;
|
||||
@ -310,7 +308,6 @@ void nsAccessNode::ShutdownXPAccessibility()
|
||||
|
||||
NS_IF_RELEASE(gStringBundle);
|
||||
NS_IF_RELEASE(gKeyStringBundle);
|
||||
NS_IF_RELEASE(gDoCommandTimer);
|
||||
NS_IF_RELEASE(gLastFocusedNode);
|
||||
|
||||
nsApplicationAccessibleWrap::Unload();
|
||||
|
@ -63,7 +63,6 @@ class nsPresContext;
|
||||
class nsIAccessibleDocument;
|
||||
class nsIFrame;
|
||||
class nsIDOMNodeList;
|
||||
class nsITimer;
|
||||
class nsRootAccessible;
|
||||
class nsApplicationAccessibleWrap;
|
||||
class nsIDocShellTreeItem;
|
||||
@ -191,7 +190,7 @@ protected:
|
||||
// Static data, we do our own refcounting for our static data
|
||||
static nsIStringBundle *gStringBundle;
|
||||
static nsIStringBundle *gKeyStringBundle;
|
||||
static nsITimer *gDoCommandTimer;
|
||||
|
||||
#ifdef DEBUG
|
||||
static PRBool gIsAccessibilityActive;
|
||||
#endif
|
||||
|
@ -161,19 +161,6 @@ nsAccessibilityService::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
if (progress)
|
||||
progress->RemoveProgressListener(static_cast<nsIWebProgressListener*>(this));
|
||||
|
||||
// Cancel and release load timers.
|
||||
while (mLoadTimers.Count() > 0 ) {
|
||||
nsCOMPtr<nsITimer> timer = mLoadTimers.ObjectAt(0);
|
||||
void *closure = nsnull;
|
||||
timer->GetClosure(&closure);
|
||||
if (closure) {
|
||||
nsIWebProgress *webProgress = static_cast<nsIWebProgress*>(closure);
|
||||
NS_RELEASE(webProgress); // Release nsIWebProgress for timer
|
||||
}
|
||||
timer->Cancel();
|
||||
mLoadTimers.RemoveObjectAt(0);
|
||||
}
|
||||
|
||||
// Application is going to be closed, shutdown accessibility and mark
|
||||
// accessibility service as shutdown to prevent calls of its methods.
|
||||
// Don't null accessibility service static member at this point to be safe
|
||||
@ -206,38 +193,36 @@ NS_IMETHODIMP nsAccessibilityService::OnStateChange(nsIWebProgress *aWebProgress
|
||||
|
||||
if (NS_FAILED(aStatus) && (aStateFlags & STATE_START))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
if (!timer)
|
||||
return NS_OK;
|
||||
mLoadTimers.AppendObject(timer);
|
||||
NS_ADDREF(aWebProgress);
|
||||
|
||||
if (aStateFlags & STATE_START)
|
||||
timer->InitWithFuncCallback(StartLoadCallback, aWebProgress, 0,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
else if (NS_SUCCEEDED(aStatus))
|
||||
timer->InitWithFuncCallback(EndLoadCallback, aWebProgress, 0,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
else // Failed end load
|
||||
timer->InitWithFuncCallback(FailedLoadCallback, aWebProgress, 0,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
if (aStateFlags & STATE_START) {
|
||||
NS_DISPATCH_RUNNABLEMETHOD_ARG2(ProcessDocLoadEvent, this, aWebProgress,
|
||||
nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_START)
|
||||
} else if (NS_SUCCEEDED(aStatus)) {
|
||||
NS_DISPATCH_RUNNABLEMETHOD_ARG2(ProcessDocLoadEvent, this, aWebProgress,
|
||||
nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE)
|
||||
} else { // Failed end load
|
||||
NS_DISPATCH_RUNNABLEMETHOD_ARG2(ProcessDocLoadEvent, this, aWebProgress,
|
||||
nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED)
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessibilityService::ProcessDocLoadEvent(nsITimer *aTimer, void *aClosure, PRUint32 aEventType)
|
||||
void
|
||||
nsAccessibilityService::ProcessDocLoadEvent(nsIWebProgress *aWebProgress,
|
||||
PRUint32 aEventType)
|
||||
{
|
||||
if (gIsShutdown)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
nsIWebProgress *webProgress = static_cast<nsIWebProgress*>(aClosure);
|
||||
webProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
||||
NS_RELEASE(webProgress);
|
||||
mLoadTimers.RemoveObject(aTimer);
|
||||
NS_ENSURE_STATE(domWindow);
|
||||
aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
||||
NS_ENSURE_TRUE(domWindow,);
|
||||
|
||||
if (aEventType == nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_START) {
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(domWindow));
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
|
||||
NS_ENSURE_STATE(docShell);
|
||||
NS_ENSURE_TRUE(docShell,);
|
||||
PRUint32 loadType;
|
||||
docShell->GetLoadType(&loadType);
|
||||
if (loadType == LOAD_RELOAD_NORMAL ||
|
||||
@ -251,17 +236,15 @@ NS_IMETHODIMP nsAccessibilityService::ProcessDocLoadEvent(nsITimer *aTimer, void
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
domWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDOMNode> docNode = do_QueryInterface(domDoc);
|
||||
NS_ENSURE_STATE(docNode);
|
||||
NS_ENSURE_TRUE(docNode,);
|
||||
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
GetAccessibleFor(docNode, getter_AddRefs(accessible));
|
||||
nsRefPtr<nsDocAccessible> docAcc =
|
||||
nsAccUtils::QueryAccessibleDocument(accessible);
|
||||
NS_ENSURE_STATE(docAcc);
|
||||
NS_ENSURE_TRUE(docAcc,);
|
||||
|
||||
docAcc->FireDocLoadEvents(aEventType);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -301,30 +284,6 @@ nsAccessibilityService::FireAccessibleEvent(PRUint32 aEvent,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsAccessibilityService::StartLoadCallback(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
if (gAccessibilityService)
|
||||
gAccessibilityService->
|
||||
ProcessDocLoadEvent(aTimer, aClosure,
|
||||
nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_START);
|
||||
}
|
||||
|
||||
void nsAccessibilityService::EndLoadCallback(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
if (gAccessibilityService)
|
||||
gAccessibilityService->
|
||||
ProcessDocLoadEvent(aTimer, aClosure,
|
||||
nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE);
|
||||
}
|
||||
|
||||
void nsAccessibilityService::FailedLoadCallback(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
if (gAccessibilityService)
|
||||
gAccessibilityService->
|
||||
ProcessDocLoadEvent(aTimer, aClosure,
|
||||
nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED);
|
||||
}
|
||||
|
||||
/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
|
||||
NS_IMETHODIMP nsAccessibilityService::OnProgressChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress,
|
||||
|
@ -40,9 +40,11 @@
|
||||
#define __nsAccessibilityService_h__
|
||||
|
||||
#include "nsIAccessibilityService.h"
|
||||
|
||||
#include "nsCoreUtils.h"
|
||||
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsWeakReference.h"
|
||||
@ -157,10 +159,19 @@ private:
|
||||
*/
|
||||
PRBool HasUniversalAriaProperty(nsIContent *aContent, nsIWeakReference *aWeakShell);
|
||||
|
||||
static void StartLoadCallback(nsITimer *aTimer, void *aClosure);
|
||||
static void EndLoadCallback(nsITimer *aTimer, void *aClosure);
|
||||
static void FailedLoadCallback(nsITimer *aTimer, void *aClosure);
|
||||
nsCOMArray<nsITimer> mLoadTimers;
|
||||
/**
|
||||
* Process the internal doc load event.
|
||||
*
|
||||
* @param aWebProgress [in] the nsIWebProgress object for the load event
|
||||
* @param aEventType [in] the type of load event, one of:
|
||||
* nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_START,
|
||||
* nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE,
|
||||
* nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED
|
||||
*/
|
||||
void ProcessDocLoadEvent(nsIWebProgress *aWebProgress, PRUint32 aEventType);
|
||||
|
||||
NS_DECL_RUNNABLEMETHOD_ARG2(nsAccessibilityService, ProcessDocLoadEvent,
|
||||
nsCOMPtr<nsIWebProgress>, PRUint32)
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,6 @@
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsArrayUtils.h"
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsIObserverService.h"
|
||||
@ -2120,8 +2119,8 @@ nsAccessible::DoAction(PRUint8 aIndex)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (GetActionRule(nsAccUtils::State(this)) != eNoAction) {
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
return DoCommand(content);
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -2492,44 +2491,15 @@ NS_IMETHODIMP nsAccessible::GetNativeInterface(void **aOutAccessible)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsAccessible::DoCommand(nsIContent *aContent, PRUint32 aActionIndex)
|
||||
{
|
||||
if (gDoCommandTimer) {
|
||||
// Already have timer going for another command
|
||||
NS_WARNING("Doubling up on do command timers doesn't work. This wasn't expected.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
NS_ENSURE_TRUE(timer, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIContent> content = aContent;
|
||||
if (!content)
|
||||
content = do_QueryInterface(mDOMNode);
|
||||
|
||||
// Command closure object memory will be free in DoCommandCallback().
|
||||
nsCommandClosure *closure =
|
||||
new nsCommandClosure(this, content, aActionIndex);
|
||||
NS_ENSURE_TRUE(closure, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(gDoCommandTimer = timer);
|
||||
return gDoCommandTimer->InitWithFuncCallback(DoCommandCallback,
|
||||
static_cast<void*>(closure),
|
||||
0, nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
|
||||
void
|
||||
nsAccessible::DoCommandCallback(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
NS_ASSERTION(gDoCommandTimer,
|
||||
"How did we get here if there was no gDoCommandTimer?");
|
||||
NS_RELEASE(gDoCommandTimer);
|
||||
|
||||
nsCommandClosure *closure = static_cast<nsCommandClosure*>(aClosure);
|
||||
closure->accessible->DispatchClickEvent(closure->content,
|
||||
closure->actionIndex);
|
||||
delete closure;
|
||||
NS_DISPATCH_RUNNABLEMETHOD_ARG2(DispatchClickEvent, this,
|
||||
content, aActionIndex)
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -374,20 +374,6 @@ protected:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Action helpers
|
||||
|
||||
/**
|
||||
* Used to describe click action target. See DoCommand() method.
|
||||
*/
|
||||
struct nsCommandClosure
|
||||
{
|
||||
nsCommandClosure(nsAccessible *aAccessible, nsIContent *aContent,
|
||||
PRUint32 aActionIndex) :
|
||||
accessible(aAccessible), content(aContent), actionIndex(aActionIndex) {}
|
||||
|
||||
nsRefPtr<nsAccessible> accessible;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
PRUint32 actionIndex;
|
||||
};
|
||||
|
||||
/**
|
||||
* Prepares click action that will be invoked in timeout.
|
||||
*
|
||||
@ -400,21 +386,16 @@ protected:
|
||||
* @param aContent [in, optional] element to click
|
||||
* @param aActionIndex [in, optional] index of accessible action
|
||||
*/
|
||||
nsresult DoCommand(nsIContent *aContent = nsnull, PRUint32 aActionIndex = 0);
|
||||
|
||||
/**
|
||||
* Dispatch click event to target by calling DispatchClickEvent() method.
|
||||
*
|
||||
* @param aTimer [in] timer object
|
||||
* @param aClosure [in] nsCommandClosure object describing a target.
|
||||
*/
|
||||
static void DoCommandCallback(nsITimer *aTimer, void *aClosure);
|
||||
void DoCommand(nsIContent *aContent = nsnull, PRUint32 aActionIndex = 0);
|
||||
|
||||
/**
|
||||
* Dispatch click event.
|
||||
*/
|
||||
virtual void DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex);
|
||||
|
||||
NS_DECL_RUNNABLEMETHOD_ARG2(nsAccessible, DispatchClickEvent,
|
||||
nsCOMPtr<nsIContent>, PRUint32)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Helpers
|
||||
|
||||
|
@ -56,7 +56,6 @@
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIPresShell.h"
|
||||
@ -560,17 +559,12 @@ nsCoreUtils::GetDOMNodeForContainer(nsIDocShellTreeItem *aContainer)
|
||||
if (!cv)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
||||
if (!docv)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
docv->GetDocument(getter_AddRefs(doc));
|
||||
nsIDocument* doc = cv->GetDocument();
|
||||
if (!doc)
|
||||
return nsnull;
|
||||
|
||||
nsIDOMNode* node = nsnull;
|
||||
CallQueryInterface(doc.get(), &node);
|
||||
CallQueryInterface(doc, &node);
|
||||
return node;
|
||||
}
|
||||
|
||||
|
@ -464,5 +464,132 @@ public:
|
||||
static void GeneratePopupTree(nsIDOMNode *aNode, PRBool aIsAnon = PR_FALSE);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsRunnable helpers
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Use NS_DECL_RUNNABLEMETHOD_ macros to declare a runnable class for the given
|
||||
* method of the given class. There are three macros:
|
||||
* NS_DECL_RUNNABLEMETHOD(Class, Method)
|
||||
* NS_DECL_RUNNABLEMETHOD_ARG1(Class, Method, Arg1Type)
|
||||
* NS_DECL_RUNNABLEMETHOD_ARG2(Class, Method, Arg1Type, Arg2Type)
|
||||
* Note Arg1Type and Arg2Type must be types which keeps the objects alive.
|
||||
*
|
||||
* Use NS_DISPATCH_RUNNABLEMETHOD_ macros to create an instance of declared
|
||||
* runnable class and dispatch it to main thread. Availabe macros are:
|
||||
* NS_DISPATCH_RUNNABLEMETHOD(Method, Object)
|
||||
* NS_DISPATCH_RUNNABLEMETHOD_ARG1(Method, Object, Arg1)
|
||||
* NS_DISPATCH_RUNNABLEMETHOD_ARG2(Method, Object, Arg1, Arg2)
|
||||
*/
|
||||
|
||||
#define NS_DECL_RUNNABLEMETHOD_HELPER(ClassType, Method) \
|
||||
void Revoke() \
|
||||
{ \
|
||||
NS_IF_RELEASE(mObj); \
|
||||
} \
|
||||
\
|
||||
protected: \
|
||||
virtual ~nsRunnableMethod_##Method() \
|
||||
{ \
|
||||
NS_IF_RELEASE(mObj); \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
ClassType *mObj; \
|
||||
|
||||
|
||||
#define NS_DECL_RUNNABLEMETHOD(ClassType, Method) \
|
||||
class nsRunnableMethod_##Method : public nsRunnable \
|
||||
{ \
|
||||
public: \
|
||||
nsRunnableMethod_##Method(ClassType *aObj) : mObj(aObj) \
|
||||
{ \
|
||||
NS_IF_ADDREF(mObj); \
|
||||
} \
|
||||
\
|
||||
NS_IMETHODIMP Run() \
|
||||
{ \
|
||||
if (!mObj) \
|
||||
return NS_OK; \
|
||||
(mObj-> Method)(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
\
|
||||
NS_DECL_RUNNABLEMETHOD_HELPER(ClassType, Method) \
|
||||
\
|
||||
};
|
||||
|
||||
#define NS_DECL_RUNNABLEMETHOD_ARG1(ClassType, Method, Arg1Type) \
|
||||
class nsRunnableMethod_##Method : public nsRunnable \
|
||||
{ \
|
||||
public: \
|
||||
nsRunnableMethod_##Method(ClassType *aObj, Arg1Type aArg1) : \
|
||||
mObj(aObj), mArg1(aArg1) \
|
||||
{ \
|
||||
NS_IF_ADDREF(mObj); \
|
||||
} \
|
||||
\
|
||||
NS_IMETHODIMP Run() \
|
||||
{ \
|
||||
if (!mObj) \
|
||||
return NS_OK; \
|
||||
(mObj-> Method)(mArg1); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
\
|
||||
NS_DECL_RUNNABLEMETHOD_HELPER(ClassType, Method) \
|
||||
Arg1Type mArg1; \
|
||||
};
|
||||
|
||||
#define NS_DECL_RUNNABLEMETHOD_ARG2(ClassType, Method, Arg1Type, Arg2Type) \
|
||||
class nsRunnableMethod_##Method : public nsRunnable \
|
||||
{ \
|
||||
public: \
|
||||
\
|
||||
nsRunnableMethod_##Method(ClassType *aObj, \
|
||||
Arg1Type aArg1, Arg2Type aArg2) : \
|
||||
mObj(aObj), mArg1(aArg1), mArg2(aArg2) \
|
||||
{ \
|
||||
NS_IF_ADDREF(mObj); \
|
||||
} \
|
||||
\
|
||||
NS_IMETHODIMP Run() \
|
||||
{ \
|
||||
if (!mObj) \
|
||||
return NS_OK; \
|
||||
(mObj-> Method)(mArg1, mArg2); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
\
|
||||
NS_DECL_RUNNABLEMETHOD_HELPER(ClassType, Method) \
|
||||
Arg1Type mArg1; \
|
||||
Arg2Type mArg2; \
|
||||
};
|
||||
|
||||
#define NS_DISPATCH_RUNNABLEMETHOD(Method, Obj) \
|
||||
{ \
|
||||
nsCOMPtr<nsIRunnable> runnable = \
|
||||
new nsRunnableMethod_##Method(Obj); \
|
||||
if (runnable) \
|
||||
NS_DispatchToMainThread(runnable); \
|
||||
}
|
||||
|
||||
#define NS_DISPATCH_RUNNABLEMETHOD_ARG1(Method, Obj, Arg1) \
|
||||
{ \
|
||||
nsCOMPtr<nsIRunnable> runnable = \
|
||||
new nsRunnableMethod_##Method(Obj, Arg1); \
|
||||
if (runnable) \
|
||||
NS_DispatchToMainThread(runnable); \
|
||||
}
|
||||
|
||||
#define NS_DISPATCH_RUNNABLEMETHOD_ARG2(Method, Obj, Arg1, Arg2) \
|
||||
{ \
|
||||
nsCOMPtr<nsIRunnable> runnable = \
|
||||
new nsRunnableMethod_##Method(Obj, Arg1, Arg2); \
|
||||
if (runnable) \
|
||||
NS_DispatchToMainThread(runnable); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -74,13 +74,14 @@ NS_IMETHODIMP nsRadioButtonAccessible::GetActionName(PRUint8 aIndex, nsAString&
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/** Our only action is to click */
|
||||
NS_IMETHODIMP nsRadioButtonAccessible::DoAction(PRUint8 aIndex)
|
||||
NS_IMETHODIMP
|
||||
nsRadioButtonAccessible::DoAction(PRUint8 aIndex)
|
||||
{
|
||||
if (aIndex == eAction_Click) {
|
||||
return DoCommand();
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -542,8 +542,12 @@ nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void nsRootAccessible::FireCurrentFocusEvent()
|
||||
void
|
||||
nsRootAccessible::FireCurrentFocusEvent()
|
||||
{
|
||||
if (IsDefunct())
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> focusedNode = GetCurrentFocus();
|
||||
if (!focusedNode) {
|
||||
return; // No current focus
|
||||
@ -772,13 +776,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
||||
// Got focus event for the window, we will make sure that an accessible
|
||||
// focus event for initial focus is fired. We do this on a short timer
|
||||
// because the initial focus may not have been set yet.
|
||||
if (!mFireFocusTimer) {
|
||||
mFireFocusTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
}
|
||||
if (mFireFocusTimer) {
|
||||
mFireFocusTimer->InitWithFuncCallback(FireFocusCallback, this,
|
||||
0, nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
NS_DISPATCH_RUNNABLEMETHOD(FireCurrentFocusEvent, this)
|
||||
}
|
||||
|
||||
// Keep a reference to the target node. We might want to change
|
||||
@ -934,13 +932,6 @@ void nsRootAccessible::GetTargetNode(nsIDOMEvent *aEvent, nsIDOMNode **aTargetNo
|
||||
NS_ADDREF(*aTargetNode = eventTarget);
|
||||
}
|
||||
|
||||
void nsRootAccessible::FireFocusCallback(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
nsRootAccessible *rootAccessible = static_cast<nsRootAccessible*>(aClosure);
|
||||
NS_ASSERTION(rootAccessible, "How did we get here without a root accessible?");
|
||||
rootAccessible->FireCurrentFocusEvent();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsAccessNode
|
||||
|
||||
@ -970,11 +961,6 @@ nsRootAccessible::Shutdown()
|
||||
|
||||
mCurrentARIAMenubar = nsnull;
|
||||
|
||||
if (mFireFocusTimer) {
|
||||
mFireFocusTimer->Cancel();
|
||||
mFireFocusTimer = nsnull;
|
||||
}
|
||||
|
||||
return nsDocAccessibleWrap::Shutdown();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIDOMFormListener.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
#define NS_ROOTACCESSIBLE_IMPL_CID \
|
||||
{ /* eaba2cf0-21b1-4e2b-b711-d3a89dcd5e1a */ \
|
||||
@ -122,11 +121,9 @@ public:
|
||||
|
||||
nsCaretAccessible *GetCaretAccessible();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsITimer> mFireFocusTimer;
|
||||
static void FireFocusCallback(nsITimer *aTimer, void *aClosure);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
NS_DECL_RUNNABLEMETHOD(nsRootAccessible, FireCurrentFocusEvent)
|
||||
|
||||
nsresult AddEventListeners();
|
||||
nsresult RemoveEventListeners();
|
||||
nsresult HandleEventWithTarget(nsIDOMEvent* aEvent,
|
||||
|
@ -98,12 +98,14 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetActionName(PRUint8 aIndex, nsAString&
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLCheckboxAccessible::DoAction(PRUint8 index)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLCheckboxAccessible::DoAction(PRUint8 aIndex)
|
||||
{
|
||||
if (index == 0) { // 0 is the magic value for default action
|
||||
return DoCommand();
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex != 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -256,12 +258,14 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetActionName(PRUint8 aIndex, nsAString& a
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::DoAction(PRUint8 index)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonAccessible::DoAction(PRUint8 aIndex)
|
||||
{
|
||||
if (index == eAction_Click) {
|
||||
return DoCommand();
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -349,12 +353,14 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetActionName(PRUint8 aIndex, nsAString&
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::DoAction(PRUint8 index)
|
||||
NS_IMETHODIMP
|
||||
nsHTML4ButtonAccessible::DoAction(PRUint8 aIndex)
|
||||
{
|
||||
if (index == 0) {
|
||||
return DoCommand();
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex != 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -160,8 +160,8 @@ nsHTMLLinkAccessible::DoAction(PRUint8 aIndex)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
return DoCommand(content);
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -626,7 +626,8 @@ nsXFormsSelectableItemAccessible::DoAction(PRUint8 aIndex)
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
return DoCommand();
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -130,10 +130,11 @@ nsXFormsTriggerAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
||||
NS_IMETHODIMP
|
||||
nsXFormsTriggerAccessible::DoAction(PRUint8 aIndex)
|
||||
{
|
||||
if (aIndex == eAction_Click)
|
||||
return DoCommand();
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsXFormsInputAccessible
|
||||
@ -246,7 +247,8 @@ nsXFormsInputBooleanAccessible::DoAction(PRUint8 aIndex)
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
return DoCommand();
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsXFormsInputDateAccessible
|
||||
|
@ -96,10 +96,11 @@ nsXULButtonAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
||||
NS_IMETHODIMP
|
||||
nsXULButtonAccessible::DoAction(PRUint8 aIndex)
|
||||
{
|
||||
if (aIndex == 0)
|
||||
return DoCommand();
|
||||
if (aIndex != 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -419,12 +420,14 @@ NS_IMETHODIMP nsXULCheckboxAccessible::GetActionName(PRUint8 aIndex, nsAString&
|
||||
/**
|
||||
* Tell the checkbox to do its only action -- check( or uncheck) itself
|
||||
*/
|
||||
NS_IMETHODIMP nsXULCheckboxAccessible::DoAction(PRUint8 index)
|
||||
NS_IMETHODIMP
|
||||
nsXULCheckboxAccessible::DoAction(PRUint8 aIndex)
|
||||
{
|
||||
if (index == eAction_Click) {
|
||||
return DoCommand();
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,7 +147,8 @@ nsXULColumnItemAccessible::DoAction(PRUint8 aIndex)
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
return DoCommand();
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -120,7 +120,8 @@ nsXULSliderAccessible::DoAction(PRUint8 aIndex)
|
||||
nsCOMPtr<nsIContent> sliderContent(GetSliderNode());
|
||||
NS_ENSURE_STATE(sliderContent);
|
||||
|
||||
return DoCommand(sliderContent);
|
||||
DoCommand(sliderContent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIAccessibleValue
|
||||
|
@ -233,8 +233,8 @@ nsXULLinkAccessible::DoAction(PRUint8 aIndex)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
return DoCommand(content);
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -935,7 +935,8 @@ nsXULTreeItemAccessibleBase::DoAction(PRUint8 aIndex)
|
||||
(aIndex != eAction_Expand || !IsExpandable()))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
return DoCommand(nsnull, aIndex);
|
||||
DoCommand(nsnull, aIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -973,13 +973,17 @@ nsXULTreeGridCellAccessible::DoAction(PRUint8 aIndex)
|
||||
|
||||
PRBool isCycler = PR_FALSE;
|
||||
mColumn->GetCycler(&isCycler);
|
||||
if (isCycler)
|
||||
return DoCommand();
|
||||
if (isCycler) {
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt16 type;
|
||||
mColumn->GetType(&type);
|
||||
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable())
|
||||
return DoCommand();
|
||||
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
@ -77,6 +77,10 @@
|
||||
label="©LinkCmd.label;"
|
||||
accesskey="©LinkCmd.accesskey;"
|
||||
oncommand="goDoCommand('cmd_copyLink');"/>
|
||||
<menuitem id="context-copylinktext"
|
||||
label="©LinkText2Cmd.label;"
|
||||
accesskey="©LinkText2Cmd.accesskey;"
|
||||
oncommand="gContextMenu.copyLinkText();"/>
|
||||
<menuseparator id="context-sep-copylink"/>
|
||||
<menuitem id="context-media-play"
|
||||
label="&mediaPlay.label;"
|
||||
|
@ -732,8 +732,10 @@ var allTabs = {
|
||||
siblingPreview.parentNode.insertBefore(preview, siblingPreview);
|
||||
else
|
||||
this.container.lastChild.appendChild(preview);
|
||||
if (this.isOpen && !preview.hidden)
|
||||
if (this.isOpen && !preview.hidden) {
|
||||
this._reflow();
|
||||
preview.focus();
|
||||
}
|
||||
break;
|
||||
case "TabClose":
|
||||
this._removePreview(preview);
|
||||
|
@ -84,6 +84,24 @@
|
||||
<handlers>
|
||||
<handler event="command" action="allTabs.pick(this);"/>
|
||||
<handler event="click" button="1" action="gBrowser.removeTab(this._tab);"/>
|
||||
|
||||
<handler event="dragstart"><![CDATA[
|
||||
event.dataTransfer.mozSetDataAt("application/x-moz-node", this._tab, 0);
|
||||
]]></handler>
|
||||
|
||||
<handler event="dragover"><![CDATA[
|
||||
let tab = event.dataTransfer.mozGetDataAt("application/x-moz-node", 0);
|
||||
if (tab && tab.parentNode == gBrowser.tabContainer)
|
||||
event.preventDefault();
|
||||
]]></handler>
|
||||
|
||||
<handler event="drop"><![CDATA[
|
||||
let tab = event.dataTransfer.mozGetDataAt("application/x-moz-node", 0);
|
||||
if (tab && tab.parentNode == gBrowser.tabContainer) {
|
||||
let newIndex = Array.indexOf(gBrowser.tabContainer.childNodes, this._tab);
|
||||
gBrowser.moveTabTo(tab, newIndex);
|
||||
}
|
||||
]]></handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
</bindings>
|
||||
|
@ -3339,12 +3339,8 @@ function BrowserCustomizeToolbar()
|
||||
else
|
||||
sheetFrame.setAttribute("src", customizeURL);
|
||||
|
||||
// XXXmano: there's apparently no better way to get this when the iframe is
|
||||
// hidden
|
||||
var sheetWidth = sheetFrame.style.width.match(/([0-9]+)px/)[1];
|
||||
document.getElementById("customizeToolbarSheetPopup")
|
||||
.openPopup(gNavToolbox, "after_start",
|
||||
(window.innerWidth - sheetWidth) / 2, 0);
|
||||
.openPopup(gNavToolbox, "after_start", 0, 0);
|
||||
|
||||
return sheetFrame.contentWindow;
|
||||
} else {
|
||||
@ -4524,6 +4520,13 @@ nsBrowserAccess.prototype = {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isExternal && (!aURI || aURI.spec == "about:blank")) {
|
||||
win.BrowserOpenTab(); // this also focuses the location bar
|
||||
win.focus();
|
||||
newWindow = win.content;
|
||||
break;
|
||||
}
|
||||
|
||||
let loadInBackground = gPrefService.getBoolPref("browser.tabs.loadDivertedInBackground");
|
||||
let referrer = aOpener ? makeURI(aOpener.location.href) : null;
|
||||
|
||||
@ -5276,8 +5279,10 @@ function stylesheetFillPopup(menuPopup) {
|
||||
continue;
|
||||
|
||||
// Skip any stylesheets that don't match the screen media type.
|
||||
let (media = currentStyleSheet.media.mediaText.toLowerCase()) {
|
||||
if (media && (media.indexOf("screen") == -1) && (media.indexOf("all") == -1))
|
||||
if (currentStyleSheet.media.length > 0) {
|
||||
let media = currentStyleSheet.media.mediaText.split(", ");
|
||||
if (media.indexOf("screen") == -1 &&
|
||||
media.indexOf("all") == -1)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,9 @@
|
||||
<!-- Bookmarks and history tooltip -->
|
||||
<tooltip id="bhTooltip"/>
|
||||
|
||||
<panel id="customizeToolbarSheetPopup" noautohide="true">
|
||||
<panel id="customizeToolbarSheetPopup"
|
||||
noautohide="true"
|
||||
onpopupshown="this.moveTo(this.boxObject.screenX + (window.innerWidth - this.boxObject.width) / 2, this.boxObject.screenY);">
|
||||
<iframe id="customizeToolbarSheetIFrame"
|
||||
style="&dialog.style;"
|
||||
hidden="true"/>
|
||||
|
@ -438,6 +438,8 @@ nsContextMenu.prototype = {
|
||||
|
||||
// Copy link location depends on whether we're on a non-mailto link.
|
||||
this.showItem("context-copylink", this.onLink && !this.onMailtoLink);
|
||||
this.showItem("context-copylinktext",
|
||||
this.onLink && !this.onImage && !this.isTextSelected);
|
||||
this.showItem("context-sep-copylink", this.onLink &&
|
||||
(this.onImage || this.onVideo || this.onAudio));
|
||||
|
||||
@ -1178,6 +1180,14 @@ nsContextMenu.prototype = {
|
||||
clipboard.copyString(addresses);
|
||||
},
|
||||
|
||||
copyLinkText: function() {
|
||||
let text = this.linkText();
|
||||
|
||||
let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
|
||||
getService(Ci.nsIClipboardHelper);
|
||||
clipboard.copyString(text);
|
||||
},
|
||||
|
||||
///////////////
|
||||
// Utilities //
|
||||
///////////////
|
||||
|
@ -1344,7 +1344,8 @@
|
||||
|
||||
b.addEventListener("DOMTitleChanged", this.onTitleChanged, true);
|
||||
|
||||
if (this.mStrip.collapsed)
|
||||
if (this.mStrip.collapsed &&
|
||||
this.mTabs.length - this._removingTabs.length > 1)
|
||||
this.setStripVisibilityTo(true);
|
||||
|
||||
// wire up a progress listener for the new browser object.
|
||||
|
@ -101,6 +101,7 @@ _BROWSER_FILES = \
|
||||
browser_bug477014.js \
|
||||
browser_bug495058.js \
|
||||
browser_bug517902.js \
|
||||
browser_bug520538.js \
|
||||
browser_bug521216.js \
|
||||
browser_bug537474.js \
|
||||
browser_discovery.js \
|
||||
|
15
browser/base/content/test/browser_bug520538.js
Normal file
15
browser/base/content/test/browser_bug520538.js
Normal file
@ -0,0 +1,15 @@
|
||||
function test() {
|
||||
var tabs = gBrowser.tabContainer.childElementCount;
|
||||
content.focus();
|
||||
browserDOMWindow.openURI(makeURI("about:blank"),
|
||||
null,
|
||||
Ci.nsIBrowserDOMWindow.OPEN_NEWTAB,
|
||||
Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
|
||||
is(gBrowser.tabContainer.childElementCount, tabs + 1,
|
||||
"'-new-tab about:blank' opens a new tab");
|
||||
is(gBrowser.selectedTab, gBrowser.tabContainer.childNodes[tabs],
|
||||
"'-new-tab about:blank' selects the new tab");
|
||||
is(document.activeElement, gURLBar.inputField,
|
||||
"'-new-tab about:blank' focuses the location bar");
|
||||
gBrowser.removeCurrentTab();
|
||||
}
|
@ -23,9 +23,14 @@
|
||||
<link data-state="1" href="404.css" title="13" rel="alternate stylesheet" media="screen">
|
||||
<link data-state="1" href="404.css" title="14" rel="alternate stylesheet" media=" Screen">
|
||||
<link data-state="1" href="404.css" title="15" rel="alternate stylesheet" media="screen foo">
|
||||
<link data-state="1" href="404.css" title="16" rel="alternate stylesheet" media="all screen">
|
||||
<link data-state="0-todo" href="404.css" title="17" rel="alternate stylesheet" media="allscreen">
|
||||
<link data-state="0-todo" href="404.css" title="18" rel="alternate stylesheet" media="_all">
|
||||
<link data-state="1" href="404.css" title="16" rel="alternate stylesheet" media="all screen">
|
||||
<link data-state="1" href="404.css" title="17" rel="alternate stylesheet" media="foo bar">
|
||||
<link data-state="1" href="404.css" title="18" rel="alternate stylesheet" media="all,screen">
|
||||
<link data-state="1" href="404.css" title="19" rel="alternate stylesheet" media="all, screen">
|
||||
<link data-state="1" href="404.css" title="20" rel="alternate stylesheet" media="all screen">
|
||||
<link data-state="0" href="404.css" title="21" rel="alternate stylesheet" media="foo">
|
||||
<link data-state="0" href="404.css" title="22" rel="alternate stylesheet" media="allscreen">
|
||||
<link data-state="0" href="404.css" title="23" rel="alternate stylesheet" media="_all">
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
|
@ -173,14 +173,16 @@ function runTest(testNum) {
|
||||
"context-bookmarklink", true,
|
||||
"context-savelink", true,
|
||||
"context-sendlink", true,
|
||||
"context-copylink", true]);
|
||||
"context-copylink", true,
|
||||
"context-copylinktext", true]);
|
||||
closeContextMenu();
|
||||
openContextMenuFor(mailto); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// Context menu for text mailto-link
|
||||
checkContextMenu(["context-copyemail", true]);
|
||||
checkContextMenu(["context-copyemail", true,
|
||||
"context-copylinktext", true]);
|
||||
closeContextMenu();
|
||||
openContextMenuFor(input); // Invoke context menu for next test.
|
||||
break;
|
||||
|
@ -60,6 +60,8 @@
|
||||
this.inputField.addEventListener("mousedown", this, false);
|
||||
this.inputField.addEventListener("mousemove", this, false);
|
||||
this.inputField.addEventListener("mouseout", this, false);
|
||||
this.inputField.addEventListener("overflow", this, false);
|
||||
this.inputField.addEventListener("underflow", this, false);
|
||||
]]></constructor>
|
||||
|
||||
<destructor><![CDATA[
|
||||
@ -69,6 +71,8 @@
|
||||
this.inputField.removeEventListener("mousedown", this, false);
|
||||
this.inputField.removeEventListener("mousemove", this, false);
|
||||
this.inputField.removeEventListener("mouseout", this, false);
|
||||
this.inputField.removeEventListener("overflow", this, false);
|
||||
this.inputField.removeEventListener("underflow", this, false);
|
||||
]]></destructor>
|
||||
|
||||
<method name="handleRevert">
|
||||
@ -211,10 +215,12 @@
|
||||
return [url, postData.value];
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<field name="_contentIsCropped">false</field>
|
||||
|
||||
<method name="_initURLTooltip">
|
||||
<body><![CDATA[
|
||||
if (this.focused || this.value == "")
|
||||
if (this.focused || !this._contentIsCropped)
|
||||
return;
|
||||
if (this._tooltipTimer)
|
||||
clearTimeout(this._tooltipTimer);
|
||||
@ -378,6 +384,13 @@
|
||||
case "mouseout":
|
||||
this._hideURLTooltip();
|
||||
break;
|
||||
case "overflow":
|
||||
this._contentIsCropped = true;
|
||||
break;
|
||||
case "underflow":
|
||||
this._contentIsCropped = false;
|
||||
this._hideURLTooltip();
|
||||
break;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
@ -70,14 +70,17 @@ static RedirEntry kRedirMap[] = {
|
||||
#ifdef MOZ_SAFE_BROWSING
|
||||
{ "blocked", "chrome://browser/content/safebrowsing/blockedSite.xhtml",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
nsIAboutModule::ALLOW_SCRIPT |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
|
||||
#endif
|
||||
{ "certerror", "chrome://browser/content/certerror/aboutCertError.xhtml",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
nsIAboutModule::ALLOW_SCRIPT |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
|
||||
{ "feeds", "chrome://browser/content/feeds/subscribe.xhtml",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
nsIAboutModule::ALLOW_SCRIPT |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
|
||||
{ "privatebrowsing", "chrome://browser/content/aboutPrivateBrowsing.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
{ "rights",
|
||||
|
@ -99,15 +99,6 @@ DirectoryProvider::GetFile(const char *aKey, PRBool *aPersist, nsIFile* *aResult
|
||||
file.swap(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (!strcmp(aKey, NS_APP_MICROSUMMARY_DIR)) {
|
||||
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
getter_AddRefs(file));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
file->AppendNative(NS_LITERAL_CSTRING("microsummary-generators"));
|
||||
file.swap(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (!strcmp(aKey, NS_APP_USER_MICROSUMMARY_DIR)) {
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
|
||||
getter_AddRefs(file));
|
||||
|
@ -52,7 +52,6 @@
|
||||
// Files and directories that exist on a per-browser basis.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define NS_APP_MICROSUMMARY_DIR "MicsumGens"
|
||||
#define NS_APP_EXISTING_PREF_OVERRIDE "ExistingPrefOverride"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -53,14 +53,6 @@ function test_usr_micsum() {
|
||||
do_check_true(mdir.exists());
|
||||
}
|
||||
|
||||
function test_app_micsum() {
|
||||
let mdir = gDirSvc.get("XCurProcD", Ci.nsIFile);
|
||||
mdir.append("microsummary-generators");
|
||||
|
||||
let tmdir = gDirSvc.get("MicsumGens", Ci.nsIFile);
|
||||
do_check_true(tmdir.equals(mdir));
|
||||
}
|
||||
|
||||
function test_bookmarkhtml() {
|
||||
let bmarks = gProfD.clone();
|
||||
bmarks.append("bookmarks.html");
|
||||
@ -79,7 +71,6 @@ function test_prefoverride() {
|
||||
|
||||
function run_test() {
|
||||
[test_usr_micsum,
|
||||
test_app_micsum,
|
||||
test_bookmarkhtml,
|
||||
test_prefoverride
|
||||
].forEach(function(f) {
|
||||
|
@ -401,6 +401,18 @@ WebContentConverterRegistrar.prototype = {
|
||||
registerProtocolHandler:
|
||||
function WCCR_registerProtocolHandler(aProtocol, aURIString, aTitle, aContentWindow) {
|
||||
LOG("registerProtocolHandler(" + aProtocol + "," + aURIString + "," + aTitle + ")");
|
||||
|
||||
if (Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService).
|
||||
privateBrowsingEnabled) {
|
||||
// Inside the private browsing mode, we don't want to alert the user to save
|
||||
// a protocol handler. We log it to the error console so that web developers
|
||||
// would have some way to tell what's going wrong.
|
||||
Cc["@mozilla.org/consoleservice;1"].
|
||||
getService(Ci.nsIConsoleService).
|
||||
logStringMessage("Web page denied access to register a protocol handler inside private browsing mode");
|
||||
return;
|
||||
}
|
||||
|
||||
// First, check to make sure this isn't already handled internally (we don't
|
||||
// want to let them take over, say "chrome").
|
||||
|
@ -266,15 +266,10 @@ MicrosummaryService.prototype = {
|
||||
*
|
||||
*/
|
||||
_cacheLocalGenerators: function MSS__cacheLocalGenerators() {
|
||||
// Load generators from the application directory.
|
||||
var appDir = this._dirs.get("MicsumGens", Ci.nsIFile);
|
||||
if (appDir.exists())
|
||||
this._cacheLocalGeneratorDir(appDir);
|
||||
|
||||
// Load generators from the user's profile.
|
||||
var profileDir = this._dirs.get("UsrMicsumGens", Ci.nsIFile);
|
||||
if (profileDir.exists())
|
||||
this._cacheLocalGeneratorDir(profileDir);
|
||||
var msDir = this._dirs.get("UsrMicsumGens", Ci.nsIFile);
|
||||
if (msDir.exists())
|
||||
this._cacheLocalGeneratorDir(msDir);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,6 @@ const Cu = Components.utils;
|
||||
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource:///modules/distribution.js");
|
||||
|
||||
const PREF_EM_NEW_ADDONS_LIST = "extensions.newAddons";
|
||||
const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
|
||||
@ -90,6 +89,7 @@ function BrowserGlue() {
|
||||
"nsIIdleService");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_distributionCustomizer", function() {
|
||||
Cu.import("resource:///modules/distribution.js");
|
||||
return new DistributionCustomizer();
|
||||
});
|
||||
|
||||
@ -1074,37 +1074,37 @@ BrowserGlue.prototype = {
|
||||
// this returns the most recent non-popup browser window
|
||||
getMostRecentBrowserWindow: function BG_getMostRecentBrowserWindow() {
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Components.interfaces.nsIWindowMediator);
|
||||
getService(Ci.nsIWindowMediator);
|
||||
|
||||
function isFullBrowserWindow(win) {
|
||||
return !win.closed &&
|
||||
!win.document.documentElement.getAttribute("chromehidden");
|
||||
}
|
||||
|
||||
#ifdef BROKEN_WM_Z_ORDER
|
||||
var win = wm.getMostRecentWindow("navigator:browser", true);
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
// if we're lucky, this isn't a popup, and we can just return this
|
||||
if (win && win.document.documentElement.getAttribute("chromehidden")) {
|
||||
if (win && !isFullBrowserWindow(win)) {
|
||||
win = null;
|
||||
var windowList = wm.getEnumerator("navigator:browser", true);
|
||||
let windowList = wm.getEnumerator("navigator:browser");
|
||||
// this is oldest to newest, so this gets a bit ugly
|
||||
while (windowList.hasMoreElements()) {
|
||||
var nextWin = windowList.getNext();
|
||||
if (!nextWin.document.documentElement.getAttribute("chromehidden"))
|
||||
let nextWin = windowList.getNext();
|
||||
if (isFullBrowserWindow(nextWin))
|
||||
win = nextWin;
|
||||
}
|
||||
}
|
||||
return win;
|
||||
#else
|
||||
var windowList = wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
|
||||
if (!windowList.hasMoreElements())
|
||||
return null;
|
||||
|
||||
var win = windowList.getNext();
|
||||
while (win.document.documentElement.getAttribute("chromehidden")) {
|
||||
if (!windowList.hasMoreElements())
|
||||
return null;
|
||||
|
||||
win = windowList.getNext();
|
||||
while (windowList.hasMoreElements()) {
|
||||
let win = windowList.getNext();
|
||||
if (isFullBrowserWindow(win))
|
||||
return win;
|
||||
}
|
||||
return null;
|
||||
#endif
|
||||
|
||||
return win;
|
||||
},
|
||||
|
||||
|
||||
|
@ -582,11 +582,13 @@ var gCookiesWindow = {
|
||||
if (item && seln.count == 1 && item.container && item.open)
|
||||
selectedCookieCount += 2;
|
||||
|
||||
var stringKey = selectedCookieCount == 1 ? "removeCookie" : "removeCookies";
|
||||
document.getElementById("removeCookie").label = this._bundle.getString(stringKey);
|
||||
var removeCookie = document.getElementById("removeCookie");
|
||||
var removeCookies = document.getElementById("removeCookies");
|
||||
removeCookie.parentNode.selectedPanel =
|
||||
selectedCookieCount == 1 ? removeCookie : removeCookies;
|
||||
|
||||
document.getElementById("removeAllCookies").disabled = this._view._filtered;
|
||||
document.getElementById("removeCookie").disabled = !(seln.count > 0);
|
||||
removeCookie.disabled = removeCookies.disabled = !(seln.count > 0);
|
||||
},
|
||||
|
||||
deleteCookie: function () {
|
||||
|
@ -124,9 +124,14 @@
|
||||
</vbox>
|
||||
<hbox align="end">
|
||||
<hbox class="actionButtons" flex="1">
|
||||
<button id="removeCookie" disabled="true" icon="remove"
|
||||
label="&button.removecookie.label;" accesskey="&button.removecookie.accesskey;"
|
||||
oncommand="gCookiesWindow.deleteCookie();"/>
|
||||
<deck oncommand="gCookiesWindow.deleteCookie();">
|
||||
<button id="removeCookie" disabled="true" icon="remove"
|
||||
label="&button.removecookie.label;"
|
||||
accesskey="&button.removecookie.accesskey;"/>
|
||||
<button id="removeCookies" disabled="true" icon="remove"
|
||||
label="&button.removecookies.label;"
|
||||
accesskey="&button.removecookie.accesskey;"/>
|
||||
</deck>
|
||||
<button id="removeAllCookies" disabled="true" icon="clear"
|
||||
label="&button.removeallcookies.label;" accesskey="&button.removeallcookies.accesskey;"
|
||||
oncommand="gCookiesWindow.deleteAllCookies();"/>
|
||||
|
@ -87,6 +87,8 @@ const STATE_RESTORE_FINISHED = 3;
|
||||
//// PrivateBrowsingService
|
||||
|
||||
function PrivateBrowsingService() {
|
||||
this._obs = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
this._obs.addObserver(this, "profile-after-change", true);
|
||||
this._obs.addObserver(this, "quit-application-granted", true);
|
||||
this._obs.addObserver(this, "private-browsing", true);
|
||||
@ -95,22 +97,12 @@ function PrivateBrowsingService() {
|
||||
}
|
||||
|
||||
PrivateBrowsingService.prototype = {
|
||||
// Observer Service
|
||||
__obs: null,
|
||||
get _obs() {
|
||||
if (!this.__obs)
|
||||
this.__obs = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
return this.__obs;
|
||||
},
|
||||
|
||||
// Preferences Service
|
||||
__prefs: null,
|
||||
get _prefs() {
|
||||
if (!this.__prefs)
|
||||
this.__prefs = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
return this.__prefs;
|
||||
let prefs = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
this.__defineGetter__("_prefs", function() prefs);
|
||||
return this._prefs;
|
||||
},
|
||||
|
||||
// Whether the private browsing mode is currently active or not.
|
||||
|
@ -64,6 +64,8 @@ _BROWSER_TEST_FILES = \
|
||||
browser_privatebrowsing_placestitle.js \
|
||||
browser_privatebrowsing_popupblocker.js \
|
||||
browser_privatebrowsing_popupmode.js \
|
||||
browser_privatebrowsing_protocolhandler.js \
|
||||
browser_privatebrowsing_protocolhandler_page.html \
|
||||
browser_privatebrowsing_searchbar.js \
|
||||
browser_privatebrowsing_sslsite_transition.js \
|
||||
browser_privatebrowsing_theming.js \
|
||||
|
@ -0,0 +1,86 @@
|
||||
/* ***** 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 Private Browsing Tests.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ehsan Akhgari <ehsan.akhgari@gmail.com> (Original Author)
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
// This test makes sure that the web pages can't register protocol handlers
|
||||
// inside the private browsing mode.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
const testPageURL = "http://example.com/browser/" +
|
||||
"browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler_page.html";
|
||||
waitForExplicitFinish();
|
||||
|
||||
const notificationValue = "Protocol Registration: testprotocol";
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
setTimeout(function() {
|
||||
// Make sure the notification is correctly displayed with a remember control
|
||||
let notificationBox = gBrowser.getNotificationBox();
|
||||
let notification = notificationBox.getNotificationWithValue(notificationValue);
|
||||
ok(notification, "Notification box should be displaying outside of private browsing mode");
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
// enter the private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
setTimeout(function () {
|
||||
// Make sure the notification is correctly displayed without a remember control
|
||||
let notificationBox = gBrowser.getNotificationBox();
|
||||
let notification = notificationBox.getNotificationWithValue(notificationValue);
|
||||
ok(!notification, "Notification box should not be displayed inside of private browsing mode");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
// cleanup
|
||||
pb.privateBrowsingEnabled = false;
|
||||
finish();
|
||||
}, 100); // remember control is added in a setTimeout(0) call
|
||||
}, true);
|
||||
content.location = testPageURL;
|
||||
}, 100); // remember control is added in a setTimeout(0) call
|
||||
}, true);
|
||||
content.location = testPageURL;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Protocol registrar page</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
navigator.registerProtocolHandler("testprotocol",
|
||||
"https://example.com/foobar?uri=%s",
|
||||
"Test Protocol");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -69,7 +69,8 @@
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const STATE_RUNNING_STR = "running";
|
||||
const MAX_FILE_SIZE = 100 * 1024 * 1024; // 100 megabytes
|
||||
@ -132,8 +133,8 @@ SessionStartup.prototype = {
|
||||
|
||||
try {
|
||||
// parse the session state into JS objects
|
||||
var s = new Components.utils.Sandbox("about:blank");
|
||||
var initialState = Components.utils.evalInSandbox("(" + this._iniString + ")", s);
|
||||
var s = new Cu.Sandbox("about:blank");
|
||||
var initialState = Cu.evalInSandbox("(" + this._iniString + ")", s);
|
||||
}
|
||||
catch (ex) { debug("The session file is invalid: " + ex); }
|
||||
|
||||
@ -294,7 +295,7 @@ SessionStartup.prototype = {
|
||||
|
||||
return content.replace(/\r\n?/g, "\n");
|
||||
}
|
||||
catch (ex) { Components.utils.reportError(ex); }
|
||||
catch (ex) { Cu.reportError(ex); }
|
||||
|
||||
return null;
|
||||
},
|
||||
|
@ -140,13 +140,13 @@ function test() {
|
||||
try {
|
||||
prev.value = "test value";
|
||||
|
||||
ok(false, "A locked preference should not be able to be modified.");
|
||||
ok(false, "A locked preference could be modified.");
|
||||
} catch(e){
|
||||
ok(true, "A locked preference should not be able to be modified.");
|
||||
}
|
||||
|
||||
pref.locked = false;
|
||||
ok(!pref.locked, "A single preference should not be locked.");
|
||||
ok(!pref.locked, "A single preference is unlocked.");
|
||||
|
||||
// check for change event when setting a value
|
||||
waitForExplicitFinish();
|
||||
@ -155,7 +155,7 @@ function test() {
|
||||
}
|
||||
|
||||
function onPrefChange(evt) {
|
||||
is(evt.data, testdata.dummy, "Check 'Application.prefs.set' fired a change event");
|
||||
is(evt.data, testdata.dummy, "Check 'Application.prefs.setValue' fired a change event");
|
||||
Application.prefs.events.removeListener("change", onPrefChange);
|
||||
|
||||
// We are removing the old listener after adding the new listener so we can test that
|
||||
@ -168,7 +168,7 @@ function onPrefChange(evt) {
|
||||
}
|
||||
|
||||
function onPrefChange2(evt) {
|
||||
is(evt.data, testdata.dummy, "Check 'Application.prefs.set' fired a change event for a single preference");
|
||||
is(evt.data, testdata.dummy, "Check 'Application.prefs.setValue' fired a change event for a single preference");
|
||||
Application.prefs.events.removeListener("change", onPrefChange2);
|
||||
|
||||
finish();
|
||||
|
@ -308,6 +308,8 @@
|
||||
<!ENTITY sendAudioCmd.accesskey "n">
|
||||
<!ENTITY copyLinkCmd.label "Copy Link Location">
|
||||
<!ENTITY copyLinkCmd.accesskey "a">
|
||||
<!ENTITY copyLinkText2Cmd.label "Copy Link Text">
|
||||
<!ENTITY copyLinkText2Cmd.accesskey "x">
|
||||
<!ENTITY copyImageCmd.label "Copy Image Location">
|
||||
<!ENTITY copyImageCmd.accesskey "o">
|
||||
<!ENTITY copyImageContentsCmd.label "Copy Image">
|
||||
|
@ -3,6 +3,7 @@
|
||||
<!ENTITY cookiesonsystem.label "The following cookies are stored on your computer:">
|
||||
<!ENTITY cookiename.label "Cookie Name">
|
||||
<!ENTITY cookiedomain.label "Site">
|
||||
<!ENTITY button.removecookies.label "Remove Cookies">
|
||||
<!ENTITY button.removecookie.label "Remove Cookie">
|
||||
<!ENTITY button.removecookie.accesskey "R">
|
||||
<!ENTITY button.removeallcookies.label "Remove All Cookies">
|
||||
|
@ -88,8 +88,6 @@ cannot=Block
|
||||
noCookieSelected=<no cookie selected>
|
||||
cookiesAll=The following cookies are stored on your computer:
|
||||
cookiesFiltered=The following cookies match your search:
|
||||
removeCookies=Remove Cookies
|
||||
removeCookie=Remove Cookie
|
||||
|
||||
#### Offline apps
|
||||
offlineAppRemoveTitle=Remove offline website data
|
||||
|
@ -47,11 +47,12 @@ struct JSPrincipals;
|
||||
%}
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIContentSecurityPolicy;
|
||||
|
||||
[ptr] native JSContext(JSContext);
|
||||
[ptr] native JSPrincipals(JSPrincipals);
|
||||
|
||||
[scriptable, uuid(b8268b9a-2403-44ed-81e3-614075c92034)]
|
||||
[scriptable, uuid(799ab95c-0038-4e0f-b705-74c21f185bb5)]
|
||||
interface nsIPrincipal : nsISerializable
|
||||
{
|
||||
/**
|
||||
@ -241,4 +242,9 @@ interface nsIPrincipal : nsISerializable
|
||||
* one, this will return null. Getting this attribute never throws.
|
||||
*/
|
||||
readonly attribute nsISupports certificate;
|
||||
|
||||
/**
|
||||
* A Content Security Policy associated with this principal.
|
||||
*/
|
||||
[noscript] attribute nsIContentSecurityPolicy csp;
|
||||
};
|
||||
|
@ -138,6 +138,7 @@ protected:
|
||||
|
||||
DomainPolicy* mSecurityPolicy;
|
||||
|
||||
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
|
||||
nsCOMPtr<nsIURI> mCodebase;
|
||||
nsCOMPtr<nsIURI> mDomain;
|
||||
PRPackedBool mTrusted;
|
||||
|
@ -251,6 +251,21 @@ nsNullPrincipal::GetURI(nsIURI** aURI)
|
||||
return NS_EnsureSafeToReturn(mURI, aURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipal::GetCsp(nsIContentSecurityPolicy** aCsp)
|
||||
{
|
||||
// CSP on a null principal makes no sense
|
||||
*aCsp = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipal::SetCsp(nsIContentSecurityPolicy* aCsp)
|
||||
{
|
||||
// CSP on a null principal makes no sense
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipal::GetDomain(nsIURI** aDomain)
|
||||
{
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
|
||||
#include "nsPrincipal.h"
|
||||
|
||||
@ -774,6 +775,25 @@ nsPrincipal::GetCertificate(nsISupports** aCertificate)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetCsp(nsIContentSecurityPolicy** aCsp)
|
||||
{
|
||||
NS_IF_ADDREF(*aCsp = mCSP);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::SetCsp(nsIContentSecurityPolicy* aCsp)
|
||||
{
|
||||
// If CSP was already set, it should not be destroyed! Instead, it should
|
||||
// get set anew when a new principal is created.
|
||||
if (mCSP)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
mCSP = aCsp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetHashValue(PRUint32* aValue)
|
||||
{
|
||||
|
@ -223,6 +223,20 @@ nsSystemPrincipal::GetHasCertificate(PRBool* aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSystemPrincipal::GetCsp(nsIContentSecurityPolicy** aCsp)
|
||||
{
|
||||
*aCsp = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSystemPrincipal::SetCsp(nsIContentSecurityPolicy* aCsp)
|
||||
{
|
||||
// CSP on a null principal makes no sense
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSystemPrincipal::GetDomain(nsIURI** aDomain)
|
||||
{
|
||||
|
@ -514,6 +514,8 @@ MOZ_ENABLE_GTK2 = @MOZ_ENABLE_GTK2@
|
||||
MOZ_ENABLE_QT = @MOZ_ENABLE_QT@
|
||||
MOZ_ENABLE_PHOTON = @MOZ_ENABLE_PHOTON@
|
||||
MOZ_ENABLE_XREMOTE = @MOZ_ENABLE_XREMOTE@
|
||||
MOZ_ENABLE_DWRITE_FONT = @MOZ_ENABLE_DWRITE_FONT@
|
||||
MOZ_ENABLE_D2D_SURFACE = @MOZ_ENABLE_D2D_SURFACE@
|
||||
|
||||
MOZ_GTK2_CFLAGS = @MOZ_GTK2_CFLAGS@
|
||||
MOZ_GTK2_LIBS = @MOZ_GTK2_LIBS@
|
||||
|
17
configure.in
17
configure.in
@ -1048,7 +1048,6 @@ DIRENT_INO=d_ino
|
||||
CYGWIN_WRAPPER=
|
||||
WIN_TOP_SRC=
|
||||
MOZ_USER_DIR=".mozilla"
|
||||
HOST_AR='$(AR)'
|
||||
HOST_AR_FLAGS='$(AR_FLAGS)'
|
||||
|
||||
MOZ_JPEG_CFLAGS=
|
||||
@ -2618,7 +2617,6 @@ alpha*-*-osf*)
|
||||
fi
|
||||
;;
|
||||
|
||||
dnl the qsort routine under solaris is faulty
|
||||
*-solaris*)
|
||||
AC_DEFINE(SOLARIS)
|
||||
TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
|
||||
@ -7685,8 +7683,19 @@ if test "$MOZ_TREE_CAIRO"; then
|
||||
WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
|
||||
if test -z "$WINCE"; then
|
||||
WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
|
||||
if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
|
||||
WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
|
||||
WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
|
||||
MOZ_ENABLE_D2D_SURFACE=1
|
||||
MOZ_ENABLE_DWRITE_FONT=1
|
||||
else
|
||||
WIN32_DWRITE_FONT_FEATURE=
|
||||
WIN32_D2D_SURFACE_FEATURE=
|
||||
fi
|
||||
else
|
||||
WIN32_FONT_FEATURE=
|
||||
WIN32_DWRITE_FONT_FEATURE=
|
||||
WIN32_D2D_SURFACE_FEATURE=
|
||||
fi
|
||||
|
||||
AC_TRY_COMPILE([#include <ddraw.h>], [int foo = DDLOCK_WAITNOTBUSY;], HAS_DDRAW=1, HAS_DDRAW=)
|
||||
@ -7734,6 +7743,8 @@ if test "$MOZ_TREE_CAIRO"; then
|
||||
FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
|
||||
fi
|
||||
AC_SUBST(MOZ_ENABLE_CAIRO_FT)
|
||||
AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
|
||||
AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
|
||||
AC_SUBST(CAIRO_FT_CFLAGS)
|
||||
AC_SUBST(HAS_OGLES)
|
||||
|
||||
@ -7762,6 +7773,8 @@ if test "$MOZ_TREE_CAIRO"; then
|
||||
AC_SUBST(FT_FONT_FEATURE)
|
||||
AC_SUBST(FC_FONT_FEATURE)
|
||||
AC_SUBST(WIN32_FONT_FEATURE)
|
||||
AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
|
||||
AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
|
||||
AC_SUBST(QUARTZ_FONT_FEATURE)
|
||||
AC_SUBST(PNG_FUNCTIONS_FEATURE)
|
||||
AC_SUBST(QT_SURFACE_FEATURE)
|
||||
|
@ -37,7 +37,7 @@ load 386794-1.html
|
||||
load 387460-1.html
|
||||
load 395469-1.xhtml
|
||||
load 395469-2.xhtml
|
||||
load 399712-1.html
|
||||
skip load 399712-1.html # sporadically times out (bug 473680)
|
||||
load 398088-1.xul
|
||||
load 400763-1.html
|
||||
load 401993-1.html
|
||||
@ -51,7 +51,7 @@ load 426987-1.html
|
||||
load 443538-1.svg
|
||||
load 450383-1.html
|
||||
load 450385-1.html
|
||||
skip load 458637-1.html # sporadically fails -- see bug 473680
|
||||
skip load 458637-1.html # sporadically times out (bug 473680)
|
||||
load 472593-1.html
|
||||
load 474041-1.svg
|
||||
load 483818-1.html
|
||||
|
@ -102,7 +102,7 @@ interface nsIXMLHttpRequestUpload : nsIXMLHttpRequestEventTarget {
|
||||
* you're aware of all the security implications. And then think twice about
|
||||
* it.
|
||||
*/
|
||||
[scriptable, uuid(ad78bf21-2227-447e-8ed5-824a017c265f)]
|
||||
[scriptable, uuid(6bb91106-85f0-4d93-8cb4-e57b3d0624f2)]
|
||||
interface nsIXMLHttpRequest : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -79,6 +79,7 @@ CPPSRCS = \
|
||||
nsContentUtils.cpp \
|
||||
nsCopySupport.cpp \
|
||||
nsCrossSiteListenerProxy.cpp \
|
||||
nsCSPService.cpp \
|
||||
nsDataDocumentContentPolicy.cpp \
|
||||
nsDOMAttribute.cpp \
|
||||
nsDOMAttributeMap.cpp \
|
||||
|
198
content/base/src/nsCSPService.cpp
Normal file
198
content/base/src/nsCSPService.cpp
Normal file
@ -0,0 +1,198 @@
|
||||
/* -*- Mode: C++; 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
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brandon Sterne <bsterne@mozilla.com>
|
||||
*
|
||||
* 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 "prlog.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCSPService.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
|
||||
/* Keeps track of whether or not CSP is enabled */
|
||||
static PRBool gCSPEnabled = PR_TRUE;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
static PRLogModuleInfo* gCspPRLog;
|
||||
#endif
|
||||
|
||||
CSPService::CSPService()
|
||||
{
|
||||
nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &gCSPEnabled);
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (!gCspPRLog)
|
||||
gCspPRLog = PR_NewLogModule("CSP");
|
||||
#endif
|
||||
}
|
||||
|
||||
CSPService::~CSPService()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(CSPService, nsIContentPolicy)
|
||||
|
||||
/* nsIContentPolicy implementation */
|
||||
NS_IMETHODIMP
|
||||
CSPService::ShouldLoad(PRUint32 aContentType,
|
||||
nsIURI *aContentLocation,
|
||||
nsIURI *aRequestOrigin,
|
||||
nsISupports *aRequestContext,
|
||||
const nsACString &aMimeTypeGuess,
|
||||
nsISupports *aExtra,
|
||||
PRInt16 *aDecision)
|
||||
{
|
||||
if (!aContentLocation)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
{
|
||||
nsCAutoString location;
|
||||
aContentLocation->GetSpec(location);
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("CSPService::ShouldLoad called for %s", location.get()));
|
||||
}
|
||||
#endif
|
||||
// default decision, CSP can revise it if there's a policy to enforce
|
||||
*aDecision = nsIContentPolicy::ACCEPT;
|
||||
|
||||
// No need to continue processing if CSP is disabled
|
||||
if (!gCSPEnabled)
|
||||
return NS_OK;
|
||||
|
||||
// find the nsDocument that initiated this request and see if it has a
|
||||
// CSP policy object
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsINode> node(do_QueryInterface(aRequestContext));
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
||||
if (node) {
|
||||
principal = node->NodePrincipal();
|
||||
principal->GetCsp(getter_AddRefs(csp));
|
||||
|
||||
if (csp) {
|
||||
#ifdef PR_LOGGING
|
||||
nsAutoString policy;
|
||||
csp->GetPolicy(policy);
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("Document has CSP: %s",
|
||||
NS_ConvertUTF16toUTF8(policy).get()));
|
||||
#endif
|
||||
// obtain the enforcement decision
|
||||
csp->ShouldLoad(aContentType,
|
||||
aContentLocation,
|
||||
aRequestOrigin,
|
||||
aRequestContext,
|
||||
aMimeTypeGuess,
|
||||
aExtra,
|
||||
aDecision);
|
||||
}
|
||||
}
|
||||
#ifdef PR_LOGGING
|
||||
else {
|
||||
nsCAutoString uriSpec;
|
||||
aContentLocation->GetSpec(uriSpec);
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("COULD NOT get nsINode for location: %s", uriSpec.get()));
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSPService::ShouldProcess(PRUint32 aContentType,
|
||||
nsIURI *aContentLocation,
|
||||
nsIURI *aRequestOrigin,
|
||||
nsISupports *aRequestContext,
|
||||
const nsACString &aMimeTypeGuess,
|
||||
nsISupports *aExtra,
|
||||
PRInt16 *aDecision)
|
||||
{
|
||||
if (!aContentLocation)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// default decision is to accept the item
|
||||
*aDecision = nsIContentPolicy::ACCEPT;
|
||||
|
||||
// No need to continue processing if CSP is disabled
|
||||
if (!gCSPEnabled)
|
||||
return NS_OK;
|
||||
|
||||
// find the nsDocument that initiated this request and see if it has a
|
||||
// CSP policy object
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsINode> node(do_QueryInterface(aRequestContext));
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
||||
if (node) {
|
||||
principal = node->NodePrincipal();
|
||||
principal->GetCsp(getter_AddRefs(csp));
|
||||
|
||||
if (csp) {
|
||||
#ifdef PR_LOGGING
|
||||
nsAutoString policy;
|
||||
csp->GetPolicy(policy);
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("shouldProcess - document has policy: %s",
|
||||
NS_ConvertUTF16toUTF8(policy).get()));
|
||||
#endif
|
||||
// obtain the enforcement decision
|
||||
csp->ShouldProcess(aContentType,
|
||||
aContentLocation,
|
||||
aRequestOrigin,
|
||||
aRequestContext,
|
||||
aMimeTypeGuess,
|
||||
aExtra,
|
||||
aDecision);
|
||||
}
|
||||
}
|
||||
#ifdef PR_LOGGING
|
||||
else {
|
||||
nsCAutoString uriSpec;
|
||||
aContentLocation->GetSpec(uriSpec);
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("COULD NOT get nsINode for location: %s", uriSpec.get()));
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
57
content/base/src/nsCSPService.h
Normal file
57
content/base/src/nsCSPService.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- Mode: C++; 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
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brandon Sterne <bsterne@mozilla.com>
|
||||
*
|
||||
* 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 "nsXPCOM.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
|
||||
#define CSPSERVICE_CONTRACTID "@mozilla.org/cspservice;1"
|
||||
#define CSPSERVICE_CID \
|
||||
{ 0x8d2f40b2, 0x4875, 0x4c95, \
|
||||
{ 0x97, 0xd9, 0x3f, 0x7d, 0xca, 0x2c, 0xb4, 0x60 } }
|
||||
class CSPService : public nsIContentPolicy
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONTENTPOLICY
|
||||
|
||||
CSPService();
|
||||
virtual ~CSPService();
|
||||
|
||||
private:
|
||||
PRBool mEnabled;
|
||||
};
|
@ -181,6 +181,9 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
||||
#include "nsSVGUtils.h"
|
||||
#endif // MOZ_SMIL
|
||||
|
||||
// FOR CSP (autogenerated by xpidl)
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
|
||||
|
||||
#ifdef MOZ_LOGGING
|
||||
// so we can get logging even in release builds
|
||||
@ -188,8 +191,12 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
||||
#endif
|
||||
#include "prlog.h"
|
||||
|
||||
/* Keeps track of whether or not CSP is enabled */
|
||||
static PRBool gCSPEnabled = PR_TRUE;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
static PRLogModuleInfo* gDocumentLeakPRLog;
|
||||
static PRLogModuleInfo* gCspPRLog;
|
||||
#endif
|
||||
|
||||
void
|
||||
@ -898,7 +905,7 @@ nsExternalResourceMap::AddExternalResource(nsIURI* aURI,
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (aViewer) {
|
||||
aViewer->GetDocument(getter_AddRefs(doc));
|
||||
doc = aViewer->GetDocument();
|
||||
NS_ASSERTION(doc, "Must have a document");
|
||||
|
||||
nsCOMPtr<nsIXULDocument> xulDoc = do_QueryInterface(doc);
|
||||
@ -1495,8 +1502,13 @@ nsDocument::nsDocument(const char* aContentType)
|
||||
if (gDocumentLeakPRLog)
|
||||
PR_LOG(gDocumentLeakPRLog, PR_LOG_DEBUG,
|
||||
("DOCUMENT %p created", this));
|
||||
|
||||
if (!gCspPRLog)
|
||||
gCspPRLog = PR_NewLogModule("CSP");
|
||||
#endif
|
||||
|
||||
nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &gCSPEnabled);
|
||||
|
||||
// Start out mLastStyleSheetSet as null, per spec
|
||||
SetDOMStringToNull(mLastStyleSheetSet);
|
||||
}
|
||||
@ -2251,10 +2263,114 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
||||
RetrieveRelevantHeaders(aChannel);
|
||||
|
||||
mChannel = aChannel;
|
||||
|
||||
nsresult rv = InitCSP();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::InitCSP()
|
||||
{
|
||||
if (gCSPEnabled) {
|
||||
nsAutoString cspHeaderValue;
|
||||
nsAutoString cspROHeaderValue;
|
||||
|
||||
this->GetHeaderData(nsGkAtoms::headerCSP, cspHeaderValue);
|
||||
this->GetHeaderData(nsGkAtoms::headerCSPReportOnly, cspROHeaderValue);
|
||||
|
||||
PRBool system = PR_FALSE;
|
||||
nsIScriptSecurityManager *ssm = nsContentUtils::GetSecurityManager();
|
||||
|
||||
if (NS_SUCCEEDED(ssm->IsSystemPrincipal(NodePrincipal(), &system)) && system) {
|
||||
// only makes sense to register new CSP if this document is not priviliged
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (cspHeaderValue.IsEmpty() && cspROHeaderValue.IsEmpty()) {
|
||||
// no CSP header present, stop processing
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG, ("CSP header specified for document %p", this));
|
||||
#endif
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
|
||||
mCSP = do_CreateInstance("@mozilla.org/contentsecuritypolicy;1", &rv);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
#ifdef PR_LOGGING
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG, ("Failed to create CSP object: %x", rv));
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Store the request context for violation reports
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
|
||||
mCSP->ScanRequestData(httpChannel);
|
||||
|
||||
// Start parsing the policy
|
||||
nsCOMPtr<nsIURI> chanURI;
|
||||
mChannel->GetURI(getter_AddRefs(chanURI));
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG, ("CSP Loaded"));
|
||||
#endif
|
||||
|
||||
// ReportOnly mode is enabled *only* if there are no regular-strength CSP
|
||||
// headers present. If there are, then we ignore the ReportOnly mode and
|
||||
// toss a warning into the error console, proceeding with enforcing the
|
||||
// regular-strength CSP.
|
||||
if (cspHeaderValue.IsEmpty()) {
|
||||
mCSP->SetReportOnlyMode(true);
|
||||
mCSP->RefinePolicy(cspROHeaderValue, chanURI);
|
||||
#ifdef PR_LOGGING
|
||||
{
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("CSP (report only) refined, policy: \"%s\"",
|
||||
NS_ConvertUTF16toUTF8(cspROHeaderValue).get()));
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
//XXX(sstamm): maybe we should post a warning when both read only and regular
|
||||
// CSP headers are present.
|
||||
mCSP->RefinePolicy(cspHeaderValue, chanURI);
|
||||
#ifdef PR_LOGGING
|
||||
{
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("CSP refined, policy: \"%s\"",
|
||||
NS_ConvertUTF16toUTF8(cspHeaderValue).get()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//Copy into principal
|
||||
nsIPrincipal* principal = GetPrincipal();
|
||||
|
||||
if (principal) {
|
||||
principal->SetCsp(mCSP);
|
||||
#ifdef PR_LOGGING
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("Inserted CSP into principal %p", principal));
|
||||
}
|
||||
else {
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("Couldn't copy CSP into absent principal %p", principal));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef PR_LOGGING
|
||||
else { //CSP was not enabled!
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("CSP is disabled, skipping CSP init for document %p", this));
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::StopDocumentLoad()
|
||||
{
|
||||
@ -6648,6 +6764,8 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel)
|
||||
"content-disposition",
|
||||
"refresh",
|
||||
"x-dns-prefetch-control",
|
||||
"x-content-security-policy",
|
||||
"x-content-security-policy-read-only",
|
||||
// add more http headers if you need
|
||||
// XXXbz don't add content-location support without reading bug
|
||||
// 238654 and its dependencies/dups first.
|
||||
|
@ -1213,6 +1213,8 @@ private:
|
||||
void PostUnblockOnloadEvent();
|
||||
void DoUnblockOnload();
|
||||
|
||||
nsresult InitCSP();
|
||||
|
||||
/**
|
||||
* See if aDocument is a child of this. If so, return the frame element in
|
||||
* this document that holds currentDoc (or an ancestor).
|
||||
|
@ -1007,6 +1007,8 @@ GK_ATOM(withParam, "with-param")
|
||||
GK_ATOM(wizard, "wizard")
|
||||
GK_ATOM(wrap, "wrap")
|
||||
GK_ATOM(headerDNSPrefetchControl,"x-dns-prefetch-control")
|
||||
GK_ATOM(headerCSP, "x-content-security-policy")
|
||||
GK_ATOM(headerCSPReportOnly, "x-content-security-policy-report-only")
|
||||
GK_ATOM(xml, "xml")
|
||||
GK_ATOM(xmlns, "xmlns")
|
||||
GK_ATOM(xmp, "xmp")
|
||||
|
@ -68,8 +68,6 @@
|
||||
#include "nsLWBrkCIID.h"
|
||||
#include "nsIScriptElement.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsHtml5Module.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
|
||||
static const char kMozStr[] = "moz";
|
||||
|
||||
@ -118,31 +116,8 @@ nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
|
||||
nsAutoString nameStr, valueStr;
|
||||
NS_NAMED_LITERAL_STRING(_mozStr, "_moz");
|
||||
|
||||
// HTML5 parser stored them in the order they were parsed so we want to
|
||||
// loop forward in that case.
|
||||
nsIDocument* doc = aContent->GetOwnerDocument();
|
||||
PRBool loopForward = PR_FALSE;
|
||||
if (!doc || doc->IsHTML()) {
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(doc));
|
||||
if (htmlDoc) {
|
||||
loopForward = nsHtml5Module::sEnabled;
|
||||
}
|
||||
}
|
||||
PRInt32 index, limit, step;
|
||||
if (loopForward) {
|
||||
index = 0;
|
||||
limit = count;
|
||||
step = 1;
|
||||
}
|
||||
else {
|
||||
// Loop backward over the attributes, since the order they are stored in is
|
||||
// the opposite of the order they were parsed in (see bug 213347 for reason).
|
||||
index = count - 1;
|
||||
limit = -1;
|
||||
step = -1;
|
||||
}
|
||||
|
||||
for (; index != limit; index += step) {
|
||||
for (PRInt32 index = count; index > 0;) {
|
||||
--index;
|
||||
const nsAttrName* name = aContent->GetAttrNameAt(index);
|
||||
PRInt32 namespaceID = name->NamespaceID();
|
||||
nsIAtom* attrName = name->LocalName();
|
||||
|
@ -333,6 +333,10 @@ _TEST_FILES = test_bug5141.html \
|
||||
test_bug503481b.html \
|
||||
file_bug503481b_inner.html \
|
||||
test_viewport_scroll.html \
|
||||
test_CSP.html \
|
||||
file_CSP.sjs \
|
||||
file_CSP_main.html \
|
||||
file_CSP_main.js \
|
||||
$(NULL)
|
||||
|
||||
# Disabled; see bug 492181
|
||||
|
44
content/base/test/file_CSP.sjs
Normal file
44
content/base/test/file_CSP.sjs
Normal file
@ -0,0 +1,44 @@
|
||||
// SJS file for CSP mochitests
|
||||
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
var query = {};
|
||||
request.queryString.split('&').forEach(function (val) {
|
||||
var [name, value] = val.split('=');
|
||||
query[name] = unescape(value);
|
||||
});
|
||||
|
||||
var isPreflight = request.method == "OPTIONS";
|
||||
|
||||
|
||||
//avoid confusing cache behaviors
|
||||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
|
||||
if ("main" in query) {
|
||||
var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
|
||||
.createInstance(Components.interfaces.nsIXMLHttpRequest);
|
||||
//serve the main page with a CSP header!
|
||||
// -- anything served from 'self' (localhost:8888) will be allowed,
|
||||
// -- anything served from other hosts (example.com:80) will be blocked.
|
||||
// -- XHR tests are set up in the file_CSP_main.js file which is sourced.
|
||||
response.setHeader("X-Content-Security-Policy",
|
||||
"allow 'self'",
|
||||
false);
|
||||
xhr.open("GET", "http://localhost:8888/tests/content/base/test/file_CSP_main.html", false);
|
||||
xhr.send(null);
|
||||
if(xhr.status == 200) {
|
||||
response.write(xhr.responseText);
|
||||
}
|
||||
} else {
|
||||
if ("type" in query) {
|
||||
response.setHeader("Content-Type", unescape(query['type']), false);
|
||||
} else {
|
||||
response.setHeader("Content-Type", "text/html", false);
|
||||
}
|
||||
|
||||
if ("content" in query) {
|
||||
response.setHeader("Content-Type", "text/html", false);
|
||||
response.write(unescape(query['content']));
|
||||
}
|
||||
}
|
||||
}
|
55
content/base/test/file_CSP_main.html
Normal file
55
content/base/test/file_CSP_main.html
Normal file
@ -0,0 +1,55 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel='stylesheet' type='text/css'
|
||||
href='http://example.org/tests/content/base/test/file_CSP.sjs?testid=style_bad&type=text/css' />
|
||||
<link rel='stylesheet' type='text/css'
|
||||
href='file_CSP.sjs?testid=style_good&type=text/css' />
|
||||
|
||||
|
||||
<style>
|
||||
/* CSS font embedding tests */
|
||||
@font-face {
|
||||
font-family: "arbitrary_good";
|
||||
src: url('file_CSP.sjs?testid=font_good&type=application/octet-stream');
|
||||
}
|
||||
@font-face {
|
||||
font-family: "arbitrary_bad";
|
||||
src: url('http://example.org/tests/content/base/test/file_CSP.sjs?testid=font_bad&type=application/octet-stream');
|
||||
}
|
||||
|
||||
.div_arbitrary_good { font-family: "arbitrary_good"; }
|
||||
.div_arbitrary_bad { font-family: "arbitrary_bad"; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- these should be stopped by CSP. :) -->
|
||||
<img src="http://example.org/tests/content/base/test/file_CSP.sjs?testid=img_bad&type=img/png"> </img>
|
||||
<audio src="http://example.org/tests/content/base/test/file_CSP.sjs?testid=media_bad&type=audio/vorbis"></audio>
|
||||
<script src='http://example.org/tests/content/base/test/file_CSP.sjs?testid=script_bad&type=text/javascript'></script>
|
||||
<iframe src='http://example.org/tests/content/base/test/file_CSP.sjs?testid=frame_bad&content=FAIL'></iframe>
|
||||
<object width="10" height="10">
|
||||
<param name="movie" value="http://example.org/tests/content/base/test/file_CSP.sjs?testid=object_bad&type=application/x-shockwave-flash">
|
||||
<embed src="http://example.org/tests/content/base/test/file_CSP.sjs?testid=object_bad&type=application/x-shockwave-flash"></embed>
|
||||
</object>
|
||||
|
||||
<!-- these should load ok. :) -->
|
||||
<img src="file_CSP.sjs?testid=img_good&type=img/png" />
|
||||
<audio src="file_CSP.sjs?testid=media_good&type=audio/vorbis"></audio>
|
||||
<script src='file_CSP.sjs?testid=script_good&type=text/javascript'></script>
|
||||
<iframe src='file_CSP.sjs?testid=frame_good&content=PASS'></iframe>
|
||||
|
||||
<object width="10" height="10">
|
||||
<param name="movie" value="file_CSP.sjs?testid=object_good&type=application/x-shockwave-flash">
|
||||
<embed src="file_CSP.sjs?testid=object_good&type=application/x-shockwave-flash"></embed>
|
||||
</object>
|
||||
|
||||
<!-- XHR tests... they're taken care of in this script,
|
||||
and since the URI doesn't have any 'testid' values,
|
||||
it will just be ignored by the test framework. -->
|
||||
<script src='file_CSP_main.js'></script>
|
||||
|
||||
<!-- Support elements for the @font-face test -->
|
||||
<div class="div_arbitrary_good">arbitrary good</div>
|
||||
<div class="div_arbitrary_bad">arbitrary_bad</div>
|
||||
</body>
|
||||
</html>
|
16
content/base/test/file_CSP_main.js
Normal file
16
content/base/test/file_CSP_main.js
Normal file
@ -0,0 +1,16 @@
|
||||
// some javascript for the CSP XHR tests
|
||||
//
|
||||
|
||||
try {
|
||||
var xhr_good = new XMLHttpRequest();
|
||||
var xhr_good_uri ="http://localhost:8888/tests/content/base/test/file_CSP.sjs?testid=xhr_good";
|
||||
xhr_good.open("GET", xhr_good_uri, true);
|
||||
xhr_good.send(null);
|
||||
} catch(e) {}
|
||||
|
||||
try {
|
||||
var xhr_bad = new XMLHttpRequest();
|
||||
var xhr_bad_uri ="http://example.com/tests/content/base/test/file_CSP.sjs?testid=xhr_bad";
|
||||
xhr_bad.open("GET", xhr_bad_uri, true);
|
||||
xhr_bad.send(null);
|
||||
} catch(e) {}
|
@ -1,11 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title>Test for html serializer</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
</head><body>
|
||||
<p>Hello world</p> <p>
|
||||
|
||||
Lorem ipsum dolor sit amet, <strong>consectetuer</strong> adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti <span>sociosqu ad
|
||||
@ -45,6 +41,4 @@ ut gravida eros leo ut libero
|
||||
<p></p>
|
||||
<noscript>
|
||||
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
|
||||
</body>
|
||||
</html>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>
|
@ -44,5 +44,4 @@ ut gravida eros leo ut libero
|
||||
<noscript>
|
||||
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
|
||||
</body>
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body>
|
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
|
@ -1,8 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta http-equiv="content-type" content="text/html;
|
||||
charset=UTF-8">
|
||||
<title>Test for html serializer</title>
|
||||
|
||||
</head><body>
|
||||
@ -51,5 +49,4 @@ ut gravida eros leo ut libero
|
||||
<noscript>
|
||||
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
|
||||
</body></html>
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>
|
@ -1,8 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta http-equiv="content-type" content="text/html;
|
||||
charset=UTF-8">
|
||||
<title>Test for html serializer</title>
|
||||
|
||||
</head><body>
|
||||
@ -52,5 +50,4 @@ ut gravida eros leo ut libero
|
||||
<noscript>
|
||||
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
|
||||
</body></html>
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>
|
@ -1,8 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta http-equiv="content-type" content="text/html;
|
||||
charset=UTF-8">
|
||||
<title>Test for html serializer</title>
|
||||
|
||||
</head><body>
|
||||
@ -51,5 +49,5 @@ ut gravida eros leo ut libero
|
||||
<noscript>
|
||||
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
|
||||
<body><p>this is an other body element</p></body></body></html>
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p><body><p>this is
|
||||
an other body element</p></body></body></html>
|
@ -1,8 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta http-equiv="content-type" content="text/html;
|
||||
charset=UTF-8">
|
||||
<title>Test for html serializer</title>
|
||||
|
||||
</head></html>
|
@ -1,8 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta http-equiv="content-type" content="text/html;
|
||||
charset=UTF-8">
|
||||
<title>Test for html serializer</title>
|
||||
|
||||
</head><body>
|
||||
@ -51,5 +49,4 @@ ut gravida eros leo ut libero
|
||||
<noscript>
|
||||
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
|
||||
</body></html>
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>
|
@ -1,8 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta http-equiv="content-type" content="text/html;
|
||||
charset=UTF-8">
|
||||
<title>Test for html serializer</title>
|
||||
|
||||
</head><body>
|
||||
@ -55,5 +53,4 @@ ut gravida eros leo ut libero
|
||||
<noscript>
|
||||
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
|
||||
</body></html>
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>
|
@ -1,8 +1,5 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title>Test for html serializer</title>
|
||||
|
||||
</head><body>
|
||||
@ -45,5 +42,4 @@ ut gravida eros leo ut libero
|
||||
<p></p>
|
||||
<noscript>
|
||||
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
|
||||
</body></html>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>
|
@ -1,8 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta http-equiv="content-type" content="text/html;
|
||||
charset=UTF-8">
|
||||
<title>Test for html serializer</title>
|
||||
|
||||
</head><body><p>this is an other body element</p></body><body>
|
||||
@ -51,5 +49,4 @@ ut gravida eros leo ut libero
|
||||
<noscript>
|
||||
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
|
||||
</body></html>
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>
|
@ -44,5 +44,4 @@ ut gravida eros leo ut libero
|
||||
<noscript>
|
||||
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
|
||||
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
|
||||
</body>
|
||||
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body>
|
@ -1,9 +1,5 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for html serializer with entities</title>
|
||||
</head>
|
||||
<body>
|
||||
<!DOCTYPE html><html><head><title>Test for html serializer with entities</title>
|
||||
</head><body>
|
||||
|
||||
<p>The basic set is just & < > " for interoperability with older products that don't support α and friends.</p>
|
||||
|
||||
@ -18,12 +14,9 @@
|
||||
σ τ υ φ χ ψ ω ϑ ϒ ϖ • … ′ ″ ‾ ⁄ ℘ ℑ ℜ
|
||||
™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ ∈ ∉
|
||||
∋ ∏ ∑ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥
|
||||
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ ⟨ ⟩ ◊ ♠ ♣ ♥ ♦
|
||||
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ ◊ ♠ ♣ ♥ ♦
|
||||
</p>
|
||||
<p> others
|
||||
Œ œ Š š Ÿ ˆ ˜       ‌ ‍ ‎ ‏–— ‘ ’
|
||||
‚“ ” „ † ‡ ‰ ‹ › €
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</p></body></html>
|
@ -1,9 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!DOCTYPE html>
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=">
|
||||
|
||||
|
||||
<title>Test for html serializer with entities</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset="><title>Test
|
||||
for html serializer with entities</title>
|
||||
</head><body>
|
||||
|
||||
<p>The basic set is just & < > " for interoperability
|
||||
@ -20,11 +18,9 @@ with older products that don't support α and friends.</p>
|
||||
σ τ υ φ χ ψ ω ϑ ϒ ϖ • … ′ ″ ‾ ⁄ ℘ ℑ ℜ
|
||||
™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ ∈ ∉
|
||||
∋ ∏ ∑ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥
|
||||
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ 〈 〉 ◊ ♠ ♣ ♥ ♦
|
||||
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ ◊ ♠ ♣ ♥ ♦
|
||||
</p>
|
||||
<p> others
|
||||
Œ œ Š š Ÿ ˆ ˜ –— ‘ ’
|
||||
‚“ ” „ † ‡ ‰ ‹ › €
|
||||
</p>
|
||||
|
||||
</body></html>
|
||||
</p></body></html>
|
@ -1,9 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!DOCTYPE html>
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=">
|
||||
|
||||
|
||||
<title>Test for html serializer with entities</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset="><title>Test
|
||||
for html serializer with entities</title>
|
||||
</head><body>
|
||||
|
||||
<p>The basic set is just & < > " for interoperability
|
||||
@ -41,14 +39,11 @@ with older products that don't support α and friends.</p>
|
||||
∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤
|
||||
≥
|
||||
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈
|
||||
⌉ ⌊ ⌋ ⟨ ⟩ ◊ ♠ ♣ ♥
|
||||
♦
|
||||
⌉ ⌊ ⌋ ◊ ♠ ♣ ♥ ♦
|
||||
</p>
|
||||
<p> others
|
||||
Œ œ Š š Ÿ ˆ ˜    
|
||||
  ‌ ‍ ‎ ‏–— ‘ ’
|
||||
‚“ ” „ † ‡ ‰ ‹
|
||||
› €
|
||||
</p>
|
||||
|
||||
</body></html>
|
||||
</p></body></html>
|
@ -1,9 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!DOCTYPE html>
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=">
|
||||
|
||||
|
||||
<title>Test for html serializer with entities</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset="><title>Test
|
||||
for html serializer with entities</title>
|
||||
</head><body>
|
||||
|
||||
<p>The basic set is just & < > " for interoperability
|
||||
@ -41,14 +39,11 @@ with older products that don't support α and friends.</p>
|
||||
∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤
|
||||
≥
|
||||
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈
|
||||
⌉ ⌊ ⌋ ⟨ ⟩ ◊ ♠ ♣ ♥
|
||||
♦
|
||||
⌉ ⌊ ⌋ ◊ ♠ ♣ ♥ ♦
|
||||
</p>
|
||||
<p> others
|
||||
Œ œ Š š Ÿ ˆ ˜    
|
||||
  ‌ ‍ ‎ ‏–— ‘ ’
|
||||
‚“ ” „ † ‡ ‰ ‹
|
||||
› €
|
||||
</p>
|
||||
|
||||
</body></html>
|
||||
</p></body></html>
|
@ -1,9 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!DOCTYPE html>
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=">
|
||||
|
||||
|
||||
<title>Test for html serializer with entities</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset="><title>Test
|
||||
for html serializer with entities</title>
|
||||
</head><body>
|
||||
|
||||
<p>The basic set is just & < > " for interoperability
|
||||
@ -30,11 +28,9 @@ with older products that don't support α and friends.</p>
|
||||
σ τ υ φ χ ψ ω ϑ ϒ ϖ • … ′ ″ ‾ ⁄ ℘ ℑ ℜ
|
||||
™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ ∈ ∉
|
||||
∋ ∏ ∑ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥
|
||||
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ 〈 〉 ◊ ♠ ♣ ♥ ♦
|
||||
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ ◊ ♠ ♣ ♥ ♦
|
||||
</p>
|
||||
<p> others
|
||||
Œ œ Š š Ÿ ˆ ˜ –— ‘ ’
|
||||
‚“ ” „ † ‡ ‰ ‹ › €
|
||||
</p>
|
||||
|
||||
</body></html>
|
||||
</p></body></html>
|
@ -1,8 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html><html><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Testcase for IPv6 addresses</title>
|
||||
<body>
|
||||
<a href="http://[2001:4860:a003::68]/">Test</a>
|
||||
</body>
|
||||
</html>
|
||||
</body></html>
|
@ -1,7 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html><head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;
|
||||
charset=UTF-8">
|
||||
<title>Testcase for IPv6 addresses</title>
|
||||
</head><body>
|
||||
<a href="http://[2001:4860:a003::68]/">Test</a>
|
||||
|
127
content/base/test/test_CSP.html
Normal file
127
content/base/test/test_CSP.html
Normal file
@ -0,0 +1,127 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Content Security Policy Connections</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<iframe style="width:200px;height:200px;" id='cspframe'></iframe>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var path = "/tests/content/base/test/";
|
||||
|
||||
// These are test results: -1 means it hasn't run,
|
||||
// true/false is the pass/fail result.
|
||||
window.tests = {
|
||||
img_good: -1,
|
||||
img_bad: -1,
|
||||
style_good: -1,
|
||||
style_bad: -1,
|
||||
frame_good: -1,
|
||||
frame_bad: -1,
|
||||
script_good: -1,
|
||||
script_bad: -1,
|
||||
xhr_good: -1,
|
||||
xhr_bad: -1,
|
||||
media_good: -1,
|
||||
media_bad: -1,
|
||||
font_good: -1,
|
||||
font_bad: -1,
|
||||
object_good: -1,
|
||||
object_bad: -1,
|
||||
};
|
||||
|
||||
|
||||
// This is used to watch the blocked data bounce off CSP and allowed data
|
||||
// get sent out to the wire.
|
||||
function examiner() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var obsvc = Components.classes['@mozilla.org/observer-service;1']
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
obsvc.addObserver(this, "csp-on-violate-policy", false);
|
||||
obsvc.addObserver(this, "http-on-modify-request", false);
|
||||
}
|
||||
examiner.prototype = {
|
||||
observe: function(subject, topic, data) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
// subject should be an nsURI, and should be either allowed or blocked.
|
||||
if(!subject.QueryInterface)
|
||||
return;
|
||||
|
||||
var testpat = new RegExp("testid=([a-z0-9_]+)");
|
||||
|
||||
//_good things better be allowed!
|
||||
//_bad things better be stopped!
|
||||
|
||||
if (topic === "http-on-modify-request") {
|
||||
//these things were allowed by CSP
|
||||
var uri = subject.QueryInterface(Components.interfaces.nsIHttpChannel).URI;
|
||||
if (!testpat.test(uri.asciiSpec)) return;
|
||||
var testid = testpat.exec(uri.asciiSpec)[1];
|
||||
window.testResult(testid,
|
||||
/_good/.test(testid),
|
||||
uri.asciiSpec + " allowed by csp");
|
||||
|
||||
}
|
||||
|
||||
if(topic === "csp-on-violate-policy") {
|
||||
//these were blocked... record that they were blocked
|
||||
var uri = subject.QueryInterface(Components.interfaces.nsIURI);
|
||||
if (!testpat.test(uri.asciiSpec)) return;
|
||||
var testid = testpat.exec(uri.asciiSpec)[1];
|
||||
window.testResult(testid,
|
||||
/_bad/.test(testid),
|
||||
uri.asciiSpec + " blocked by \"" + data + "\"");
|
||||
}
|
||||
},
|
||||
|
||||
// must eventually call this to remove the listener,
|
||||
// or mochitests might get borked.
|
||||
remove: function() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var obsvc = Components.classes['@mozilla.org/observer-service;1']
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
obsvc.removeObserver(this, "csp-on-violate-policy");
|
||||
obsvc.removeObserver(this, "http-on-modify-request");
|
||||
}
|
||||
}
|
||||
|
||||
window.examiner = new examiner();
|
||||
|
||||
window.testResult = function(testname, result, msg) {
|
||||
|
||||
//test already complete.... forget it... remember the first result.
|
||||
if (window.tests[testname] != -1)
|
||||
return;
|
||||
|
||||
window.tests[testname] = result;
|
||||
is(result, true, testname + ' test: ' + msg);
|
||||
|
||||
// if any test is incomplete, keep waiting
|
||||
for (var v in window.tests)
|
||||
if(tests[v] == -1)
|
||||
return;
|
||||
|
||||
// ... otherwise, finish
|
||||
window.examiner.remove();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// save this for last so that our listeners are registered.
|
||||
// ... this loads the testbed of good and bad requests.
|
||||
document.getElementById('cspframe').src = 'file_CSP.sjs?main=1';
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -44,6 +44,11 @@ function loadFileContent(aFile, aCharset) {
|
||||
return content;
|
||||
}
|
||||
|
||||
function isRoughly(actual, expected, message) {
|
||||
return is(actual.replace("<!DOCTYPE HTML", "<!DOCTYPE html"),
|
||||
expected,
|
||||
message);
|
||||
}
|
||||
|
||||
function testHtmlSerializer_1 () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
@ -63,26 +68,26 @@ function testHtmlSerializer_1 () {
|
||||
encoder.setCharset("UTF-8");
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_noflag.html");
|
||||
is(out, expected, "test no flags");
|
||||
isRoughly(out, expected, "test no flags");
|
||||
|
||||
//------------- unsupported flags
|
||||
// since the following flags are not supported, we should
|
||||
// have a result like the one without flag
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputPreformatted);
|
||||
out = encoder.encodeToString();
|
||||
is(out, expected, "test OutputPreformatted");
|
||||
isRoughly(out, expected, "test OutputPreformatted");
|
||||
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputFormatFlowed);
|
||||
out = encoder.encodeToString();
|
||||
is(out, expected, "test OutputFormatFlowed");
|
||||
isRoughly(out, expected, "test OutputFormatFlowed");
|
||||
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputNoScriptContent);
|
||||
out = encoder.encodeToString();
|
||||
is(out, expected, "test OutputNoScriptContent");
|
||||
isRoughly(out, expected, "test OutputNoScriptContent");
|
||||
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputNoFramesContent);
|
||||
out = encoder.encodeToString();
|
||||
is(out, expected, "test OutputNoFramesContent");
|
||||
isRoughly(out, expected, "test OutputNoFramesContent");
|
||||
|
||||
|
||||
//------------ OutputWrap
|
||||
@ -90,25 +95,25 @@ function testHtmlSerializer_1 () {
|
||||
// when there are no flags.
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak |de.OutputWrap);
|
||||
out = encoder.encodeToString();
|
||||
is(out, expected, "test OutputWrap");
|
||||
isRoughly(out, expected, "test OutputWrap");
|
||||
|
||||
//------------ OutputFormatted
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputFormatted);
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_format.html");
|
||||
is(out, expected, "test OutputFormatted");
|
||||
isRoughly(out, expected, "test OutputFormatted");
|
||||
|
||||
//------------ OutputRaw
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputRaw);
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_raw.html");
|
||||
is(out, expected, "test OutputRaw");
|
||||
isRoughly(out, expected, "test OutputRaw");
|
||||
|
||||
//------------ OutputBodyOnly
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputBodyOnly);
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_bodyonly.html");
|
||||
is(out, expected, "test OutputBodyOnly");
|
||||
isRoughly(out, expected, "test OutputBodyOnly");
|
||||
|
||||
|
||||
|
||||
@ -116,31 +121,31 @@ function testHtmlSerializer_1 () {
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputAbsoluteLinks);
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_links.html");
|
||||
is(out, expected, "test OutputAbsoluteLinks");
|
||||
isRoughly(out, expected, "test OutputAbsoluteLinks");
|
||||
|
||||
//------------ OutputLFLineBreak
|
||||
encoder.init(doc, "text/html",de.OutputLFLineBreak);
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_linebreak.html");
|
||||
is(out, expected, "test OutputLFLineBreak");
|
||||
isRoughly(out, expected, "test OutputLFLineBreak");
|
||||
|
||||
//------------ OutputCRLineBreak
|
||||
encoder.init(doc, "text/html",de.OutputCRLineBreak);
|
||||
out = encoder.encodeToString();
|
||||
expected = expected.replace(/\n/mg, "\r");
|
||||
is(out, expected, "test OutputCRLineBreak");
|
||||
isRoughly(out, expected, "test OutputCRLineBreak");
|
||||
|
||||
//------------ OutputLFLineBreak + OutputCRLineBreak
|
||||
encoder.init(doc, "text/html",de.OutputLFLineBreak | de.OutputCRLineBreak);
|
||||
out = encoder.encodeToString();
|
||||
expected = expected.replace(/\r/mg, "\r\n");
|
||||
is(out, expected, "test OutputLFLineBreak + OutputCRLineBreak");
|
||||
isRoughly(out, expected, "test OutputLFLineBreak + OutputCRLineBreak");
|
||||
|
||||
//------------ OutputNoFormattingInPre
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputNoFormattingInPre);
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_noformatpre.html");
|
||||
is(out, expected, "test OutputNoFormattingInPre");
|
||||
isRoughly(out, expected, "test OutputNoFormattingInPre");
|
||||
|
||||
// ------------- nested body elements
|
||||
var body2 = doc.createElement('body');
|
||||
@ -156,7 +161,7 @@ function testHtmlSerializer_1 () {
|
||||
encoder.setCharset("UTF-8");
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_nested_body.html");
|
||||
is(out, expected, "test with two nested body elements");
|
||||
isRoughly(out, expected, "test with two nested body elements");
|
||||
|
||||
// ------------- two body elements
|
||||
body.parentNode.insertBefore(body2, body);
|
||||
@ -166,13 +171,13 @@ function testHtmlSerializer_1 () {
|
||||
encoder.setCharset("UTF-8");
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_sibling_body.html");
|
||||
is(out, expected, "test with two body elements");
|
||||
isRoughly(out, expected, "test with two body elements");
|
||||
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputBodyOnly);
|
||||
encoder.setCharset("UTF-8");
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_sibling_body_only_body.html");
|
||||
is(out, expected, "test with two body elements, and output body only");
|
||||
isRoughly(out, expected, "test with two body elements, and output body only");
|
||||
|
||||
// --------------- no body element
|
||||
doc.documentElement.removeChild(body);
|
||||
@ -182,7 +187,7 @@ function testHtmlSerializer_1 () {
|
||||
encoder.setCharset("UTF-8");
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_1_no_body.html");
|
||||
is(out, expected, "test with no body element");
|
||||
isRoughly(out, expected, "test with no body element");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -44,6 +44,11 @@ function loadFileContent(aFile, aCharset) {
|
||||
return content;
|
||||
}
|
||||
|
||||
function isRoughly(actual, expected, message) {
|
||||
return is(actual.replace("<!DOCTYPE HTML", "<!DOCTYPE html"),
|
||||
expected,
|
||||
message);
|
||||
}
|
||||
|
||||
function testHtmlSerializer_1 () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
@ -62,25 +67,25 @@ function testHtmlSerializer_1 () {
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeW3CEntities);
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_2_entw3c.html");
|
||||
is(out, expected, "test OutputEncodeW3CEntities");
|
||||
isRoughly(out, expected, "test OutputEncodeW3CEntities");
|
||||
|
||||
//------------ OutputEncodeBasicEntities
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeBasicEntities);
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_2_basic.html");
|
||||
is(out, expected, "test OutputEncodeBasicEntities");
|
||||
isRoughly(out, expected, "test OutputEncodeBasicEntities");
|
||||
|
||||
//------------ OutputEncodeLatin1Entities
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeLatin1Entities);
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_2_latin1.html");
|
||||
is(out, expected, "test OutputEncodeLatin1Entities");
|
||||
isRoughly(out, expected, "test OutputEncodeLatin1Entities");
|
||||
|
||||
//------------ OutputEncodeHTMLEntities
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeHTMLEntities);
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_2_enthtml.html");
|
||||
is(out, expected, "test OutputEncodeHTMLEntities");
|
||||
isRoughly(out, expected, "test OutputEncodeHTMLEntities");
|
||||
|
||||
|
||||
// tests on the serialization of selections
|
||||
|
@ -43,6 +43,11 @@ function loadFileContent(aFile, aCharset) {
|
||||
return content;
|
||||
}
|
||||
|
||||
function isRoughly(actual, expected, message) {
|
||||
return is(actual.replace("<!DOCTYPE HTML", "<!DOCTYPE html"),
|
||||
expected,
|
||||
message);
|
||||
}
|
||||
|
||||
function testHtmlSerializer_1 () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
@ -62,19 +67,19 @@ function testHtmlSerializer_1 () {
|
||||
encoder.setCharset("UTF-8");
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_ipv6_out.html");
|
||||
is(out, expected, "test no flags");
|
||||
isRoughly(out, expected, "test no flags");
|
||||
//------------ OutputAbsoluteLinks
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputAbsoluteLinks);
|
||||
encoder.setCharset("UTF-8");
|
||||
out = encoder.encodeToString();
|
||||
expected = loadFileContent("file_htmlserializer_ipv6_out.html");
|
||||
is(out, expected, "test OutputAbsoluteLinks");
|
||||
isRoughly(out, expected, "test OutputAbsoluteLinks");
|
||||
//------------ serializing a selection
|
||||
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputAbsoluteLinks);
|
||||
encoder.setNode(doc.links[0]);
|
||||
out = encoder.encodeToString();
|
||||
expected = "<a href=\"http://[2001:4860:a003::68]/\">Test</a>";
|
||||
is(out, expected, "test selection");
|
||||
isRoughly(out, expected, "test selection");
|
||||
|
||||
|
||||
SimpleTest.finish();
|
||||
|
1031
content/canvas/src/CustomQS_WebGL.h
Normal file
1031
content/canvas/src/CustomQS_WebGL.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,9 @@ MODULE = content
|
||||
LIBRARY_NAME = gkconcvs_s
|
||||
LIBXUL_LIBRARY = 1
|
||||
|
||||
|
||||
EXPORTS = \
|
||||
CustomQS_WebGL.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
CanvasUtils.cpp \
|
||||
@ -89,7 +91,6 @@ WEBGL_PLATFORM = CGL
|
||||
endif
|
||||
|
||||
CPPSRCS += \
|
||||
WebGLArrays.cpp \
|
||||
WebGLContext.cpp \
|
||||
WebGLContextGL.cpp \
|
||||
WebGLContextUtils.cpp \
|
||||
|
@ -15,8 +15,6 @@
|
||||
#include "CanvasUtils.h"
|
||||
#include "NativeJSContext.h"
|
||||
|
||||
#include "WebGLArray.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
nsresult NS_NewCanvasRenderingContextWebGL(nsICanvasRenderingContextWebGL** aResult);
|
||||
|
@ -58,13 +58,10 @@
|
||||
#include "SimpleBuffer.h"
|
||||
#include "nsGLPbuffer.h"
|
||||
|
||||
#include "WebGLArrays.h"
|
||||
|
||||
class nsIDocShell;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class WebGLArray;
|
||||
class WebGLTexture;
|
||||
class WebGLBuffer;
|
||||
class WebGLProgram;
|
||||
@ -265,9 +262,20 @@ protected:
|
||||
|
||||
void MakeContextCurrent() { mGLPbuffer->MakeContextCurrent(); }
|
||||
|
||||
nsresult TexImageElementBase(nsIDOMHTMLElement *imageOrCanvas,
|
||||
gfxImageSurface **imageOut,
|
||||
PRBool flipY, PRBool premultiplyAlpha);
|
||||
// helpers
|
||||
nsresult TexImage2D_base(GLenum target, GLint level, GLenum internalformat,
|
||||
GLsizei width, GLsizei height, GLint border,
|
||||
GLenum format, GLenum type,
|
||||
void *data, PRUint32 byteLength);
|
||||
nsresult TexSubImage2D_base(GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
void *pixels, PRUint32 byteLength);
|
||||
|
||||
nsresult DOMElementToImageSurface(nsIDOMElement *imageOrCanvas,
|
||||
gfxImageSurface **imageOut,
|
||||
PRBool flipY, PRBool premultiplyAlpha);
|
||||
|
||||
GLuint mActiveTexture;
|
||||
|
||||
@ -344,42 +352,32 @@ class WebGLBuffer :
|
||||
{
|
||||
public:
|
||||
WebGLBuffer(GLuint name)
|
||||
: mName(name), mDeleted(PR_FALSE), mGLType(0)
|
||||
: mName(name), mDeleted(PR_FALSE), mByteLength(0)
|
||||
{ }
|
||||
|
||||
void Delete() {
|
||||
if (mDeleted)
|
||||
return;
|
||||
ZeroOwners();
|
||||
|
||||
mDeleted = PR_TRUE;
|
||||
mByteLength = 0;
|
||||
}
|
||||
|
||||
PRBool Deleted() { return mDeleted; }
|
||||
GLuint GLName() { return mName; }
|
||||
PRUint32 ByteLength() { return mByteLength; }
|
||||
|
||||
void Set(nsIWebGLArray *na) {
|
||||
mGLType = na->NativeType();
|
||||
mElementSize = na->NativeElementSize();
|
||||
mCount = na->NativeCount();
|
||||
void SetByteLength(GLuint len) {
|
||||
mByteLength = len;
|
||||
}
|
||||
|
||||
void SetCount(GLuint count) {
|
||||
mCount = count;
|
||||
}
|
||||
|
||||
GLenum GLType() { return mGLType; }
|
||||
PRUint32 ByteCount() { return mElementSize * mCount; }
|
||||
PRUint32 Count() { return mCount; }
|
||||
PRUint32 ElementSize() { return mElementSize; }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBGLBUFFER
|
||||
protected:
|
||||
GLuint mName;
|
||||
PRBool mDeleted;
|
||||
|
||||
GLenum mGLType;
|
||||
PRUint32 mElementSize;
|
||||
PRUint32 mCount;
|
||||
PRUint32 mByteLength;
|
||||
};
|
||||
|
||||
class WebGLTexture :
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user