Merge mozilla-central into electrolysis

This commit is contained in:
Benjamin Smedberg 2010-02-09 11:39:28 -05:00
Родитель 45b95bf64a 55b5f2a328
Коммит a3abf70391
733 изменённых файлов: 100296 добавлений и 37704 удалений

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

@ -262,6 +262,8 @@ ACCESSIBILITY_ATOM(aria_valuetext, "aria-valuetext")
// a form property used to obtain the default label
// of an HTML button from the button frame
ACCESSIBILITY_ATOM(defaultLabel, "defaultLabel")
// the attribute specifying the editor's bogus br node
ACCESSIBILITY_ATOM(mozeditorbogusnode, "_moz_editor_bogus_node")
// Object attributes
ACCESSIBILITY_ATOM(tableCellIndex, "table-cell-index")

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

@ -1613,7 +1613,7 @@ nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
// correspond to the doc accessible and will be created in any case
if (!newAcc && content->Tag() != nsAccessibilityAtoms::body && content->GetParent() &&
((weakFrame.GetFrame() && weakFrame.GetFrame()->IsFocusable()) ||
(isHTML && nsCoreUtils::HasListener(content, NS_LITERAL_STRING("click"))) ||
(isHTML && nsCoreUtils::HasClickListener(content)) ||
HasUniversalAriaProperty(content, aWeakShell) || roleMapEntry ||
HasRelatedContent(content) || nsCoreUtils::IsXLink(content))) {
// This content is focusable or has an interesting dynamic content accessibility property.

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

@ -3012,7 +3012,7 @@ nsAccessible::CacheChildren()
void
nsAccessible::TestChildCache(nsAccessible *aCachedChild)
{
#ifdef DEBUG_A11Y
#ifdef DEBUG
// All cached accessible nodes should be in the parent
// It will assert if not all the children were created
// when they were first cached, and no invalidation
@ -3020,12 +3020,13 @@ nsAccessible::TestChildCache(nsAccessible *aCachedChild)
PRUint32 childCount = mChildren.Length();
if (childCount == 0) {
NS_ASSERTION(mAreChildrenInitialized,
"Children are stored but not initailzied!");
"Children are stored but not initialized!");
return;
}
nsAccessible *child;
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *child = GetChildAt(childIdx);
child = GetChildAt(childIdx);
if (child == aCachedChild)
break;
}
@ -3214,8 +3215,7 @@ nsAccessible::GetActionRule(PRUint32 aStates)
return eClickAction;
// Has registered 'click' event handler.
PRBool isOnclick = nsCoreUtils::HasListener(content,
NS_LITERAL_STRING("click"));
PRBool isOnclick = nsCoreUtils::HasClickListener(content);
if (isOnclick)
return eClickAction;

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

@ -301,6 +301,11 @@ public:
virtual nsresult AppendTextTo(nsAString& aText, PRUint32 aStartOffset,
PRUint32 aLength);
/**
* Assert if child not in parent's cache.
*/
void TestChildCache(nsAccessible *aCachedChild);
protected:
//////////////////////////////////////////////////////////////////////////////
@ -311,11 +316,6 @@ protected:
*/
virtual void CacheChildren();
/**
* Assert if child not in parent's cache.
*/
void TestChildCache(nsAccessible *aCachedChild);
/**
* Cache children if necessary. Return true if the accessible is defunct.
*/

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

@ -251,8 +251,7 @@ void
nsLinkableAccessible::CacheActionContent()
{
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mDOMNode));
PRBool isOnclick = nsCoreUtils::HasListener(walkUpContent,
NS_LITERAL_STRING("click"));
PRBool isOnclick = nsCoreUtils::HasClickListener(walkUpContent);
if (isOnclick) {
mActionContent = walkUpContent;
@ -261,8 +260,7 @@ nsLinkableAccessible::CacheActionContent()
}
while ((walkUpContent = walkUpContent->GetParent())) {
isOnclick = nsCoreUtils::HasListener(walkUpContent,
NS_LITERAL_STRING("click"));
isOnclick = nsCoreUtils::HasClickListener(walkUpContent);
nsCOMPtr<nsIDOMNode> walkUpNode(do_QueryInterface(walkUpContent));

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

@ -75,13 +75,16 @@
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
PRBool
nsCoreUtils::HasListener(nsIContent *aContent, const nsAString& aEventType)
nsCoreUtils::HasClickListener(nsIContent *aContent)
{
NS_ENSURE_TRUE(aContent, PR_FALSE);
nsIEventListenerManager* listenerManager =
aContent->GetListenerManager(PR_FALSE);
return listenerManager && listenerManager->HasListenersFor(aEventType);
return listenerManager &&
(listenerManager->HasListenersFor(NS_LITERAL_STRING("click")) ||
listenerManager->HasListenersFor(NS_LITERAL_STRING("mousedown")) ||
listenerManager->HasListenersFor(NS_LITERAL_STRING("mouseup")));
}
void

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

@ -57,10 +57,10 @@ class nsCoreUtils
{
public:
/**
* Return true if the given node has registered event listener of the given
* type.
* Return true if the given node has registered click, mousedown or mouseup
* event listeners.
*/
static PRBool HasListener(nsIContent *aContent, const nsAString& aEventType);
static PRBool HasClickListener(nsIContent *aContent);
/**
* Dispatch click event to XUL tree cell.

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

@ -166,7 +166,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDocAccessible)
NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
NS_INTERFACE_MAP_ENTRY(nsIDocumentObserver)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY(nsIScrollPositionListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessibleDocument)
@ -543,7 +542,7 @@ NS_IMETHODIMP nsDocAccessible::GetAssociatedEditor(nsIEditor **aEditor)
NS_IMETHODIMP nsDocAccessible::GetCachedAccessNode(void *aUniqueID, nsIAccessNode **aAccessNode)
{
GetCacheEntry(mAccessNodeCache, aUniqueID, aAccessNode); // Addrefs for us
#ifdef DEBUG_A11Y
#ifdef DEBUG
// All cached accessible nodes should be in the parent
// It will assert if not all the children were created
// when they were first cached, and no invalidation
@ -955,12 +954,7 @@ void nsDocAccessible::RemoveScrollListener()
////////////////////////////////////////////////////////////////////////////////
// nsIScrollPositionListener
NS_IMETHODIMP nsDocAccessible::ScrollPositionWillChange(nscoord aX, nscoord aY)
{
return NS_OK;
}
NS_IMETHODIMP nsDocAccessible::ScrollPositionDidChange(nscoord aX, nscoord aY)
void nsDocAccessible::ScrollPositionDidChange(nscoord aX, nscoord aY)
{
// Start new timer, if the timer cycles at least 1 full cycle without more scroll position changes,
// then the ::Notify() method will fire the accessibility event for scroll position changes
@ -978,7 +972,6 @@ NS_IMETHODIMP nsDocAccessible::ScrollPositionDidChange(nscoord aX, nscoord aY)
}
}
mScrollPositionChangedTicks = 1;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
@ -1963,11 +1956,11 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
printf("[Show %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
else if (aChangeType == nsIAccessibilityService::FRAME_SIGNIFICANT_CHANGE)
printf("[Layout change %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
else if (aChangeType == nsIAccessibleEvent::NODE_APPEND)
else if (aChangeType == nsIAccessibilityService::NODE_APPEND)
printf("[Create %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
else if (aChangeType == nsIAccessibilityService::NODE_REMOVE)
printf("[Destroy %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
else if (aChangeEventType == nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE)
else if (aChangeType == nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE)
printf("[Type change %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
#endif

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

@ -90,9 +90,8 @@ public:
NS_IMETHOD TakeFocus(void);
// nsIScrollPositionListener
NS_IMETHOD ScrollPositionWillChange(nscoord aX, nscoord aY);
virtual void ViewPositionDidChange(nsTArray<nsIWidget::Configuration>* aConfigurations) {}
NS_IMETHOD ScrollPositionDidChange(nscoord aX, nscoord aY);
virtual void ScrollPositionWillChange(nscoord aX, nscoord aY) {}
virtual void ScrollPositionDidChange(nscoord aX, nscoord aY);
// nsIDocumentObserver
NS_DECL_NSIDOCUMENTOBSERVER

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

@ -87,8 +87,7 @@ nsHTMLLinkAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
// This is a either named anchor (a link with also a name attribute) or
// it doesn't have any attributes. Check if 'click' event handler is
// registered, otherwise bail out.
PRBool isOnclick = nsCoreUtils::HasListener(content,
NS_LITERAL_STRING("click"));
PRBool isOnclick = nsCoreUtils::HasClickListener(content);
if (!isOnclick)
return NS_OK;
}

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

@ -586,16 +586,14 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
if (findNode) {
nsCOMPtr<nsIContent> findContent = do_QueryInterface(findNode);
if (findContent->IsHTML() &&
findContent->NodeInfo()->Equals(nsAccessibilityAtoms::br)) {
nsIContent *parent = findContent->GetParent();
if (parent &&
parent->IsRootOfNativeAnonymousSubtree() &&
parent->GetChildCount() == 1) {
// This <br> is the only node in a text control, therefore it is the hacky
// "bogus node" used when there is no text in a control
*aHyperTextOffset = 0;
return NS_OK;
}
findContent->NodeInfo()->Equals(nsAccessibilityAtoms::br) &&
findContent->AttrValueIs(kNameSpaceID_None,
nsAccessibilityAtoms::mozeditorbogusnode,
nsAccessibilityAtoms::_true,
eIgnoreCase)) {
// This <br> is the hacky "bogus node" used when there is no text in a control
*aHyperTextOffset = 0;
return NS_OK;
}
descendantAccessible = GetFirstAvailableAccessible(findNode);
}

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

@ -179,16 +179,11 @@ NS_IMETHODIMP nsXULSelectableAccessible::RefSelection(PRInt32 aIndex, nsIAccessi
if (aIndex == 0)
mSelectControl->GetSelectedItem(getter_AddRefs(selectedItem));
if (selectedItem) {
if (selectedItem)
GetAccService()->GetAccessibleInWeakShell(selectedItem, mWeakShell,
aAccessible);
if (*aAccessible) {
NS_ADDREF(*aAccessible);
return NS_OK;
}
}
return NS_ERROR_FAILURE;
return (*aAccessible) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsXULSelectableAccessible::GetSelectionCount(PRInt32 *aSelectionCount)

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

@ -42,7 +42,7 @@ srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible
DIRS = attributes events selectable tree
DIRS = actions attributes events selectable states tree
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
@ -71,13 +71,6 @@ _TEST_FILES =\
states.js \
table.js \
value.js \
test_actions.html \
test_actions.xul \
test_actions_anchors.html \
test_actions_aria.html \
test_actions_inputs.html \
test_actions_tree.xul \
test_actions_treegrid.xul \
test_aria_activedescendant.html \
test_aria_role_article.html \
test_aria_role_equation.html \
@ -114,14 +107,6 @@ _TEST_FILES =\
test_relations.xul \
test_relations_tree.xul \
test_role_nsHyperTextAcc.html \
test_role_table_cells.html \
test_states.html \
test_states_doc.html \
test_states_docarticle.html \
test_states_editablebody.html \
test_states_frames.html \
test_states_popup.xul \
test_states_tree.xul \
test_table_1.html \
test_table_4.html \
test_table_headers.html \
@ -149,10 +134,6 @@ _TEST_FILES =\
testTextboxes.js \
treeview.css \
treeview.js \
z_states_frame.html \
z_states_framearticle.html \
z_states_framecheckbox.html \
z_states_frametextbox.html \
$(NULL)
libs:: $(_TEST_FILES)

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

@ -0,0 +1,59 @@
#
# ***** 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) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Alexander Surkov <surkov.alexander@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 *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible/actions
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
test_anchors.html \
test_aria.html \
test_general.html \
test_general.xul \
test_inputs.html \
test_tree.xul \
test_treegrid.xul \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)

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

@ -1,7 +1,8 @@
<html>
<head>
<title>nsIAccessible actions testing for anchors</title>
<title>nsIAccessible actions testing for HTML links that
scroll the page to named anchors</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />

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

@ -23,7 +23,17 @@
{
var actionsArray = [
{
ID: "li_clickable",
ID: "li_clickable1",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "li_clickable2",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "li_clickable3",
actionName: "click",
events: CLICK_EVENTS
}
@ -42,6 +52,11 @@
href="https://bugzilla.mozilla.org/show_bug.cgi?id=523789"
title="nsHTMLLiAccessible shouldn't be inherited from linkable accessible">
Mozilla Bug 523789
</a><br>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=423409"
title="Expose click action if mouseup and mousedown are registered">
Mozilla Bug 423409
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -49,7 +64,9 @@
</pre>
<ul>
<li id="li_clickable" onclick="">Clickable list item</li>
<li id="li_clickable1" onclick="">Clickable list item</li>
<li id="li_clickable2" onmousedown="">Clickable list item</li>
<li id="li_clickable3" onmouseup="">Clickable list item</li>
</ul>
</body>
</html>

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

@ -0,0 +1,99 @@
<html>
<head>
<title>nsIAccessible actions testing on HTML links (HTML:a)</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js"></script>
<script type="application/javascript">
function doTest()
{
var actionsArray = [
{
ID: "link1",
actionName: "jump",
events: CLICK_EVENTS
},
{
ID: "img1",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "link2",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "img2",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "link3",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "img3",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "link4",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "img4",
actionName: "click",
events: CLICK_EVENTS
}
];
testActions(actionsArray);
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=423409"
title="Expose click action if mouseup and mousedown are registered">
Mozilla Bug 423409
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<a href="http://mozilla.org" id="link1">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img1">
</a>
<a id="link2" onmousedown="">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img2">
</a>
<a id="link3" onclick="">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img3">
</a>
<a id="link4" onmouseup="">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img4">
</a>
</body>
</html>

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

@ -73,8 +73,6 @@ function waitForEvent(aEventType, aTarget, aFunc, aContext, aArg1, aArg2)
function registerA11yEventListener(aEventType, aEventHandler)
{
listenA11yEvents(true);
gA11yEventApplicantsCount++;
addA11yEventListener(aEventType, aEventHandler);
}
@ -86,8 +84,6 @@ function registerA11yEventListener(aEventType, aEventHandler)
function unregisterA11yEventListener(aEventType, aEventHandler)
{
removeA11yEventListener(aEventType, aEventHandler);
gA11yEventApplicantsCount--;
listenA11yEvents(false);
}
@ -173,7 +169,6 @@ function eventQueue(aEventType)
this.invoke = function eventQueue_invoke()
{
listenA11yEvents(true);
gA11yEventApplicantsCount++;
// XXX: Intermittent test_events_caretmove.html fails withouth timeout,
// see bug 474952.
@ -195,7 +190,7 @@ function eventQueue(aEventType)
*/
this.processNextInvoker = function eventQueue_processNextInvoker()
{
// Finish rocessing of the current invoker.
// Finish processing of the current invoker.
var testFailed = false;
var invoker = this.getInvoker();
@ -244,7 +239,6 @@ function eventQueue(aEventType)
// Check if need to stop the test.
if (testFailed || this.mIndex == this.mInvokers.length - 1) {
gA11yEventApplicantsCount--;
listenA11yEvents(false);
var res = this.onFinish();
@ -767,19 +761,32 @@ function invokerChecker(aEventType, aTarget)
////////////////////////////////////////////////////////////////////////////////
// General
var gObserverService = null;
var gA11yEventListeners = {};
var gA11yEventApplicantsCount = 0;
var gA11yEventObserver =
{
// The service reference needs to live in the observer, instead of as a global var,
// to be available in observe() catch case too.
observerService :
Components.classes["@mozilla.org/observer-service;1"]
.getService(nsIObserverService),
observe: function observe(aSubject, aTopic, aData)
{
if (aTopic != "accessible-event")
return;
var event = aSubject.QueryInterface(nsIAccessibleEvent);
var event;
try {
event = aSubject.QueryInterface(nsIAccessibleEvent);
} catch (ex) {
// After a test is aborted (i.e. timed out by the harness), this exception is soon triggered.
// Remove the leftover observer, otherwise it "leaks" to all the following tests.
this.observerService.removeObserver(this, "accessible-event");
// Forward the exception, with added explanation.
throw "[accessible/events.js, gA11yEventObserver.observe] This is expected if a previous test has been aborted... Initial exception was: [ " + ex + " ]";
}
var listenersArray = gA11yEventListeners[event.eventType];
if (gA11yEventDumpID) { // debug stuff
@ -812,16 +819,17 @@ var gA11yEventObserver =
function listenA11yEvents(aStartToListen)
{
if (aStartToListen && !gObserverService) {
gObserverService = Components.classes["@mozilla.org/observer-service;1"].
getService(nsIObserverService);
gObserverService.addObserver(gA11yEventObserver, "accessible-event",
false);
} else if (!gA11yEventApplicantsCount) {
gObserverService.removeObserver(gA11yEventObserver,
"accessible-event");
gObserverService = null;
if (aStartToListen) {
// Add observer when adding the first applicant only.
if (!(gA11yEventApplicantsCount++))
gA11yEventObserver.observerService
.addObserver(gA11yEventObserver, "accessible-event", false);
} else {
// Remove observer when there are no more applicants only.
// '< 0' case should not happen, but just in case: removeObserver() will throw.
if (--gA11yEventApplicantsCount <= 0)
gA11yEventObserver.observerService
.removeObserver(gA11yEventObserver, "accessible-event");
}
}

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

@ -0,0 +1,64 @@
#
# ***** 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) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Alexander Surkov <surkov.alexander@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 *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible/states
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
test_aria.html \
test_doc.html \
test_docarticle.html \
test_editablebody.html \
test_frames.html \
test_link.html \
test_popup.xul \
test_tree.xul \
z_frames.html \
z_frames_article.html \
z_frames_checkbox.html \
z_frames_textbox.html \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)

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

@ -1,7 +1,7 @@
<html>
<head>
<title>nsIAccessible states testing</title>
<title>ARIA based nsIAccessible states testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />

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

@ -61,9 +61,9 @@
<pre id="test">
</pre>
<iframe id="frame_doc" src="z_states_frame.html"></iframe>
<iframe id="frame_doc_article" src="z_states_framearticle.html"></iframe>
<iframe id="frame_doc_checkbox" src="z_states_framecheckbox.html"></iframe>
<iframe id="frame_doc_textbox" src="z_states_frametextbox.html"></iframe>
<iframe id="frame_doc" src="z_frames.html"></iframe>
<iframe id="frame_doc_article" src="z_frames_article.html"></iframe>
<iframe id="frame_doc_checkbox" src="z_frames_checkbox.html"></iframe>
<iframe id="frame_doc_textbox" src="z_frames_textbox.html"></iframe>
</body>
</html>

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

@ -0,0 +1,57 @@
<html>
<head>
<title>HTML link states testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js"></script>
<script type="application/javascript">
function doTest()
{
// strong roles
testStates("link1", STATE_LINKED);
testStates("link2", STATE_LINKED);
testStates("link3", STATE_LINKED);
testStates("link4", STATE_LINKED);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=423409"
title="Expose click action if mouseup and mousedown are registered">
Mozilla Bug 423409
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<a id="link1" href="http://mozilla.org">link</a>
<a id="link2" onclick="">link</a>
<a id="link3" onmousedown="">link</a>
<a id="link4" onmouseup="">link</a>
</body>
</html>

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

@ -1,10 +1,7 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=472326
-->
<head>
<title>test nsHyperTextAccessible roles</title>
<title>test nsHyperTextAccessible accesible objects creation and their roles</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
@ -51,6 +48,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=472326
testRole("definitionterm", ROLE_LISTITEM);
testRole("definitiondescription", ROLE_PARAGRAPH);
// Has click, mousedown or mouseup listeners.
testRole("span1", ROLE_TEXT_CONTAINER);
testRole("span2", ROLE_TEXT_CONTAINER);
testRole("span3", ROLE_TEXT_CONTAINER);
SimpleTest.finish();
}
@ -62,10 +64,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=472326
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=472326"
title="html:input of type "file" no longer rendered to screen readers">
Mozilla Bug 472326</a>
Mozilla Bug 472326
</a><br>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=474261"
title="Test remaining implementations in nsHypertextAccessible::GetRole">
bug 474261</a>
bug 474261
</a><br>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=423409"
title="Expose click action if mouseup and mousedown are registered">
Mozilla Bug 423409
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -89,5 +97,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=472326
<dt id="definitionterm">gecko</dt>
<dd id="definitiondescription">geckos have sticky toes</dd>
</dl>
<span id="span1" onclick="">clickable span</span>
<span id="span2" onmousedown="">clickable span</span>
<span id="span3" onmouseup="">clickable span</span>
</body>
</html>

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

@ -1,71 +0,0 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=474281
-->
<head>
<title>Name calculation for table and grid cells</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_name.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
<script type="application/javascript">
function doTests()
{
// Test table cell name and role
testRole("tc", ROLE_CELL);
// Test grid cell.
testRole("gc", ROLE_GRID_CELL);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=474281"
title="accessible name of html table cells is incorrectly including descendants">
Mozilla bug 474281</a>
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<table>
<tr>
<td id="tc">
<p>This is a paragraph</p>
<a href="#">This is a link</a>
<ul>
<li>This is a list</li>
</ul>
</td>
</tr>
</table>
<table>
<tr>
<td id="gc" role="gridcell">
<p>This is a paragraph</p>
<a href="#">This is a link</a>
<ul>
<li>This is a list</li>
</ul>
</td>
</tr>
</table>
</body>
</html>

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

@ -211,7 +211,7 @@ ifeq ($(OS_ARCH),OS2)
RESFILE=splashos2.res
RCFLAGS += -DMOZ_PHOENIX
ifdef BUILD_STATIC_LIBS
RCFLAGS += -DMOZ_STATIC_BUILD -i $(DIST)/include/widget
RCFLAGS += -DMOZ_STATIC_BUILD -i $(DIST)/include
endif
ifdef DEBUG
RCFLAGS += -DDEBUG

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

@ -208,9 +208,9 @@ var FullZoom = {
// nsIObserver
observe: function (aSubject, aTopic, aData) {
switch(aTopic) {
switch (aTopic) {
case "nsPref:changed":
switch(aData) {
switch (aData) {
case "browser.zoom.siteSpecific":
this._siteSpecificPref =
this._prefBranch.getBoolPref("browser.zoom.siteSpecific");

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

@ -576,7 +576,7 @@ var allTabs = {
if (this._initiated)
return;
this._initiated = true;
Array.forEach(gBrowser.mTabs, function (tab) {
this._addPreview(tab);
}, this);

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

@ -2636,12 +2636,23 @@ function FillInHTMLTooltip(tipElement)
var titleText = null;
var XLinkTitleText = null;
var SVGTitleText = null;
var direction = tipElement.ownerDocument.dir;
while (!titleText && !XLinkTitleText && tipElement) {
while (!titleText && !XLinkTitleText && !SVGTitleText && tipElement) {
if (tipElement.nodeType == Node.ELEMENT_NODE) {
titleText = tipElement.getAttribute("title");
XLinkTitleText = tipElement.getAttributeNS(XLinkNS, "title");
if (tipElement instanceof SVGElement) {
let length = tipElement.childNodes.length;
for (let i = 0; i < length; i++) {
let childNode = tipElement.childNodes[i];
if (childNode instanceof SVGTitleElement) {
SVGTitleText = childNode.textContent;
break;
}
}
}
var defView = tipElement.ownerDocument.defaultView;
// XXX Work around bug 350679:
// "Tooltips can be fired in documents with no view".
@ -2656,7 +2667,7 @@ function FillInHTMLTooltip(tipElement)
var tipNode = document.getElementById("aHTMLTooltip");
tipNode.style.direction = direction;
[titleText, XLinkTitleText].forEach(function (t) {
[titleText, XLinkTitleText, SVGTitleText].forEach(function (t) {
if (t && /\S/.test(t)) {
// Per HTML 4.01 6.2 (CDATA section), literal CRs and tabs should be

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

@ -2176,8 +2176,7 @@
// move the dropped tab
if (newIndex > draggedTab._tPos)
newIndex--;
if (newIndex != draggedTab._tPos)
this.moveTabTo(draggedTab, newIndex);
this.moveTabTo(draggedTab, newIndex);
}
}
else if (draggedTab) {
@ -2340,25 +2339,26 @@
<parameter name="aIndex"/>
<body>
<![CDATA[
var oldPosition = aTab._tPos;
if (oldPosition == aIndex)
return;
this._lastRelatedTab = null;
this._browsers = null; // invalidate cache
this.mTabFilters.splice(aIndex, 0, this.mTabFilters.splice(aTab._tPos, 1)[0]);
this.mTabListeners.splice(aIndex, 0, this.mTabListeners.splice(aTab._tPos, 1)[0]);
var oldPosition = aTab._tPos;
aIndex = aIndex < aTab._tPos ? aIndex: aIndex+1;
this.mCurrentTab._selected = false;
// use .item() instead of [] because dragging to the end of the strip goes out of
// bounds: .item() returns null (so it acts like appendChild), but [] throws
this.mTabContainer.insertBefore(aTab, this.mTabContainer.childNodes.item(aIndex));
this.mTabContainer.insertBefore(aTab, this.mTabs.item(aIndex));
// invalidate cache, because mTabContainer is about to change
this._browsers = null;
var i;
for (i = 0; i < this.mTabContainer.childNodes.length; i++) {
this.mTabContainer.childNodes[i]._tPos = i;
this.mTabContainer.childNodes[i]._selected = false;
for (let i = 0; i < this.mTabs.length; i++) {
this.mTabs[i]._tPos = i;
this.mTabs[i]._selected = false;
}
this.mCurrentTab._selected = true;
this.mTabContainer.mTabstrip.ensureElementIsVisible(this.mCurrentTab, false);
@ -2366,8 +2366,6 @@
var evt = document.createEvent("UIEvents");
evt.initUIEvent("TabMove", true, false, window, oldPosition);
aTab.dispatchEvent(evt);
return aTab;
]]>
</body>
</method>

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

@ -81,14 +81,23 @@ _TEST_FILES = \
# 480169)
_BROWSER_FILES = \
browser_NetworkPrioritizer.js \
browser_allTabsPanel.js \
browser_alltabslistener.js \
browser_bug304198.js \
browser_bug321000.js \
browser_sanitize-timespans.js \
title_test.svg \
browser_bug329212.js \
browser_bug356571.js \
browser_bug386835.js \
browser_bug405137.js \
browser_bug409481.js \
browser_bug413915.js \
browser_bug416661.js \
browser_bug417483.js \
browser_bug419612.js \
browser_bug420160.js \
browser_bug422590.js \
browser_bug424101.js \
browser_bug427559.js \
browser_bug432599.js \
@ -96,56 +105,50 @@ _BROWSER_FILES = \
browser_bug441778.js \
browser_bug455852.js \
browser_bug462673.js \
browser_bug477014.js \
browser_bug479408.js \
browser_bug479408_sample.html \
browser_bug481560.js \
browser_bug484315.js \
browser_bug477014.js \
browser_bug491431.js \
browser_bug495058.js \
browser_bug517902.js \
browser_bug520538.js \
browser_bug521216.js \
browser_bug537474.js \
browser_contextSearchTabPosition.js \
browser_ctrlTab.js \
browser_discovery.js \
browser_drag.js \
browser_gestureSupport.js \
browser_getshortcutoruri.js \
browser_overflowScroll.js \
browser_pageInfo.js \
browser_page_style_menu.js \
browser_plainTextLinks.js \
browser_pluginnotification.js \
browser_relatedTabs.js \
browser_sanitize-passwordDisabledHosts.js \
browser_sanitize-sitepermissions.js \
browser_sanitize-timespans.js \
browser_sanitizeDialog.js \
browser_scope.js \
browser_selectTabAtIndex.js \
browser_tabfocus.js \
browser_tabs_owner.js \
discovery.html \
moz.png \
test_bug435035.html \
test_bug462673.html \
browser_getshortcutoruri.js \
browser_page_style_menu.js \
page_style_sample.html \
browser_ctrlTab.js \
browser_selectTabAtIndex.js \
browser_gestureSupport.js \
browser_pageInfo.js \
feed_tab.html \
browser_pluginnotification.js \
plugin_unknown.html \
plugin_test.html \
plugin_both.html \
plugin_both2.html \
browser_alltabslistener.js \
alltabslistener.html \
zoom_test.html \
browser_bug416661.js \
browser_bug386835.js \
dummy_page.html \
browser_bug422590.js \
browser_sanitize-sitepermissions.js \
browser_bug356571.js \
browser_sanitize-passwordDisabledHosts.js \
browser_bug479408.js \
browser_bug479408_sample.html \
browser_scope.js \
browser_overflowScroll.js \
browser_sanitizeDialog.js \
browser_tabs_owner.js \
browser_bug491431.js \
browser_bug304198.js \
browser_drag.js \
browser_relatedTabs.js \
browser_plainTextLinks.js \
browser_contextSearchTabPosition.js \
browser_NetworkPrioritizer.js \
$(NULL)
ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))

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

@ -0,0 +1,154 @@
function test() {
waitForExplicitFinish();
allTabs.init();
nextSequence();
}
var sequences = 3;
var chars = "ABCDEFGHI";
var closedTabs;
var history;
var steps;
var whenOpen = [
startSearch,
clearSearch, clearSearch,
closeTab,
moveTab,
closePanel,
];
var whenClosed = [
openPanel, openPanel, openPanel, openPanel, openPanel, openPanel,
closeTab, closeTab, closeTab,
moveTab, moveTab, moveTab,
selectTab, selectTab,
undoCloseTab,
openTab,
];
function rand(min, max) {
return min + Math.floor(Math.random() * (max - min + 1));
}
function pickOne(array) {
return array[rand(0, array.length - 1)];
}
function pickOneTab() {
var tab = pickOne(gBrowser.tabContainer.childNodes);
return [tab, Array.indexOf(gBrowser.tabContainer.childNodes, tab)];
}
function nextSequence() {
while (gBrowser.browsers.length > 1)
gBrowser.removeCurrentTab();
if (sequences-- <= 0) {
allTabs.close();
gBrowser.addTab();
gBrowser.removeCurrentTab();
finish();
return;
}
closedTabs = 0;
steps = rand(10, 20);
var initialTabs = "";
while (gBrowser.browsers.length < rand(3, 20)) {
let tabChar = pickOne(chars);
initialTabs += tabChar;
gBrowser.addTab("data:text/plain," + tabChar);
}
history = [initialTabs];
gBrowser.removeCurrentTab();
next();
}
function next() {
executeSoon(function () {
is(allTabs.previews.length, gBrowser.browsers.length,
history.join(", "));
if (steps-- <= 0) {
nextSequence();
return;
}
var step;
var rv;
do {
step = pickOne(allTabs.isOpen ? whenOpen : whenClosed);
rv = step();
} while (rv === false);
history.push(step.name + (rv !== true && rv !== undefined ? " " + rv : ""));
});
}
function openPanel() {
if (allTabs.isOpen)
return false;
allTabs.panel.addEventListener("popupshown", function () {
allTabs.panel.removeEventListener("popupshown", arguments.callee, false);
next();
}, false);
allTabs.open();
return true;
}
function closePanel() {
allTabs.panel.addEventListener("popuphidden", function () {
allTabs.panel.removeEventListener("popuphidden", arguments.callee, false);
next();
}, false);
allTabs.close();
}
function closeTab() {
if (gBrowser.browsers.length == 1)
return false;
var [tab, index] = pickOneTab();
gBrowser.removeTab(tab);
closedTabs++;
next();
return index;
}
function startSearch() {
allTabs.filterField.value = pickOne(chars);
allTabs.filter();
next();
return allTabs.filterField.value;
}
function clearSearch() {
if (!allTabs.filterField.value)
return false;
allTabs.filterField.value = "";
allTabs.filter();
next();
return true;
}
function undoCloseTab() {
if (!closedTabs)
return false;
window.undoCloseTab(0);
closedTabs--;
next();
return true;
}
function selectTab() {
var [tab, index] = pickOneTab();
gBrowser.selectedTab = tab;
next();
return index;
}
function openTab() {
BrowserOpenTab();
next();
}
function moveTab() {
if (gBrowser.browsers.length == 1)
return false;
var [tab, currentIndex] = pickOneTab();
do {
var [, newIndex] = pickOneTab();
} while (newIndex == currentIndex);
gBrowser.moveTabTo(tab, newIndex);
next();
return currentIndex + "->" + newIndex;
}

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

@ -0,0 +1,36 @@
function test () {
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function () {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
let doc = gBrowser.contentDocument;
let tooltip = document.getElementById("aHTMLTooltip");
ok(FillInHTMLTooltip(doc.getElementById("text1"), "should get title"));
is(tooltip.getAttribute("label"), " This is a title ");
ok(!FillInHTMLTooltip(doc.getElementById("text2"), "should not get title"));
ok(!FillInHTMLTooltip(doc.getElementById("text3"), "should not get title"));
ok(FillInHTMLTooltip(doc.getElementById("link1"), "should get title"));
is(tooltip.getAttribute("label"), " This is a title ");
ok(FillInHTMLTooltip(doc.getElementById("text4"), "should get title"));
is(tooltip.getAttribute("label"), " This is a title ");
ok(!FillInHTMLTooltip(doc.getElementById("link2"), "should not get title"));
ok(FillInHTMLTooltip(doc.getElementById("link3"), "should get title"));
ok(tooltip.getAttribute("label") != "");
ok(FillInHTMLTooltip(doc.getElementById("link4"), "should get title"));
is(tooltip.getAttribute("label"), "This is an xlink:title attribute");
gBrowser.removeCurrentTab();
finish();
}, true);
content.location =
"http://localhost:8888/browser/browser/base/content/test/title_test.svg";
}

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

@ -1,18 +1,19 @@
function test()
{
// ---- Test dragging the proxy icon ---
var value = content.location.href;
var urlString = value + "\n" + content.document.title;
var htmlString = "<a href=\"" + value + "\">" + value + "</a>";
var expected = [ [
"text/x-moz-url: " + urlString,
"text/uri-list: " + value,
"text/plain: " + value,
"text/html: " + htmlString
{ type : "text/x-moz-url",
data : urlString },
{ type : "text/uri-list",
data : value },
{ type : "text/plain",
data : value },
{ type : "text/html",
data : htmlString }
] ];
// set the valid attribute so dropping is allowed
var proxyicon = document.getElementById("page-proxy-favicon")
var oldstate = proxyicon.getAttribute("pageproxystate");

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

@ -13,27 +13,25 @@ function test() {
content.location =
"https://example.com/browser/browser/base/content/test/feed_tab.html";
var observer = {
observe: function(win, topic, data) {
if (topic != "page-info-dialog-loaded")
return;
function observer(win, topic, data) {
if (topic != "page-info-dialog-loaded")
return;
switch (atTest) {
case 0:
atTest++;
handlePageInfo();
break;
case 1:
atTest++;
pageInfo = win;
testLockClick();
break;
case 2:
atTest++;
obs.removeObserver(observer, "page-info-dialog-loaded");
testLockDoubleClick();
break;
}
switch (atTest) {
case 0:
atTest++;
handlePageInfo();
break;
case 1:
atTest++;
pageInfo = win;
testLockClick();
break;
case 2:
atTest++;
obs.removeObserver(observer, "page-info-dialog-loaded");
testLockDoubleClick();
break;
}
}

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

@ -145,15 +145,14 @@ function test()
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
let win = ww.getWindowByName("Sanatize", null);
if (win && (win instanceof Ci.nsIDOMWindowInternal)) win.close();
if (win && (win instanceof Ci.nsIDOMWindowInternal))
win.close();
// Start the test when the sanitize window loads
ww.registerNotification({
observe: function(aSubject, aTopic, aData) {
ww.unregisterNotification(this);
aSubject.QueryInterface(Ci.nsIDOMEventTarget).
addEventListener("DOMContentLoaded", doTest, false);
}
ww.registerNotification(function (aSubject, aTopic, aData) {
ww.unregisterNotification(arguments.callee);
aSubject.QueryInterface(Ci.nsIDOMEventTarget)
.addEventListener("DOMContentLoaded", doTest, false);
});
// Let the methods that run onload finish before we test

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

@ -536,69 +536,67 @@ WindowHelper.prototype = {
open: function () {
let wh = this;
let windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic !== "domwindowopened")
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
winWatch.unregisterNotification(windowObserver);
var loaded = false;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onload(event) {
win.removeEventListener("load", onload, false);
if (win.name !== "SanitizeDialog")
return;
winWatch.unregisterNotification(this);
wh.win = win;
loaded = true;
var loaded = false;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onload(event) {
win.removeEventListener("load", onload, false);
if (win.name !== "SanitizeDialog")
return;
wh.win = win;
loaded = true;
executeSoon(function () {
// Some exceptions that reach here don't reach the test harness, but
// ok()/is() do...
try {
wh.onload();
}
catch (exc) {
win.close();
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
finish();
}
});
}, false);
win.addEventListener("unload", function onunload(event) {
if (win.name !== "SanitizeDialog") {
win.removeEventListener("unload", onunload, false);
return;
executeSoon(function () {
// Some exceptions that reach here don't reach the test harness, but
// ok()/is() do...
try {
wh.onload();
}
catch (exc) {
win.close();
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
finish();
}
});
}, false);
// Why is unload fired before load?
if (!loaded)
return;
win.addEventListener("unload", function onunload(event) {
if (win.name !== "SanitizeDialog") {
win.removeEventListener("unload", onunload, false);
wh.win = win;
return;
}
executeSoon(function () {
// Some exceptions that reach here don't reach the test harness, but
// ok()/is() do...
try {
if (wh.onunload)
wh.onunload();
doNextTest();
}
catch (exc) {
win.close();
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
finish();
}
});
}, false);
}
};
// Why is unload fired before load?
if (!loaded)
return;
win.removeEventListener("unload", onunload, false);
wh.win = win;
executeSoon(function () {
// Some exceptions that reach here don't reach the test harness, but
// ok()/is() do...
try {
if (wh.onunload)
wh.onunload();
doNextTest();
}
catch (exc) {
win.close();
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
finish();
}
});
}, false);
}
winWatch.registerNotification(windowObserver);
winWatch.openWindow(null,
"chrome://browser/content/sanitize.xul",

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

@ -618,30 +618,29 @@ function ensureHistoryClearedState(aURIs, aShouldBeCleared) {
* A function that will be called once the dialog has loaded
*/
function openWindow(aOnloadCallback) {
let windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
winWatch.unregisterNotification(this);
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onload(event) {
win.removeEventListener("load", onload, false);
executeSoon(function () {
// Some exceptions that reach here don't reach the test harness, but
// ok()/is() do...
try {
aOnloadCallback(win);
doNextTest();
}
catch (exc) {
win.close();
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
finish();
}
});
}, false);
}
}
};
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
winWatch.unregisterNotification(windowObserver);
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onload(event) {
win.removeEventListener("load", onload, false);
executeSoon(function () {
// Some exceptions that reach here don't reach the test harness, but
// ok()/is() do...
try {
aOnloadCallback(win);
doNextTest();
}
catch (exc) {
win.close();
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
finish();
}
});
}, false);
}
winWatch.registerNotification(windowObserver);
winWatch.openWindow(null,
"chrome://browser/content/sanitize.xul",

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

@ -139,7 +139,7 @@ function runTest(testNum) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
ok(true, "Starting test #" + testNum);
switch(testNum) {
switch (testNum) {
case 1:
// Invoke context menu for next test.
openContextMenuFor(text);

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

@ -0,0 +1,45 @@
<svg width="640px" height="480px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0">
<text id="text1" x="10px" y="32px" font-size="24px">
This contains only &lt;title&gt;
<title>
This is a title
</title>
</text>
<text id="text2" x="10px" y="96px" font-size="24px">
This contains only &lt;desc&gt;
<desc>This is a desc</desc>
</text>
<text id="text3" x="10px" y="128px" font-size="24px">
This contains nothing.
</text>
<a id="link1" xlink:href="#">
This link contains &lt;title&gt;
<title>
This is a title
</title>
<text id="text4" x="10px" y="192px" font-size="24px">
</text>
</a>
<a id="link2" xlink:href="#">
<text x="10px" y="192px" font-size="24px">
This text contains &lt;title&gt;
<title>
This is a title
</title>
</text>
</a>
<a id="link3" xlink:href="#" xlink:title="This is an xlink:title attribute">
<text x="10px" y="224px" font-size="24px">
This link contains &lt;title&gt; &amp; xlink:title attr.
<title>This is a title</title>
</text>
</a>
<a id="link4" xlink:href="#" xlink:title="This is an xlink:title attribute">
<text x="10px" y="256px" font-size="24px">
This link contains xlink:title attr.
</text>
</a>
</svg>

После

Ширина:  |  Высота:  |  Размер: 1.3 KiB

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

@ -351,7 +351,7 @@
<parameter name="aData"/>
<body><![CDATA[
if (aTopic == "nsPref:changed") {
switch(aData) {
switch (aData) {
case "clickSelectsAll":
case "doubleClickSelectsAll":
this[aData] = this._prefs.getBoolPref(aData);

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

@ -40,7 +40,7 @@
# BrandFullNameInternal is used for some registry and file system values
# instead of BrandFullName and typically should not be modified.
!define BrandFullNameInternal "Namoroka"
!define BrandFullNameInternal "Mozilla Developer Preview"
!define CompanyName "mozilla.org"
!define URLInfoAbout "http://www.mozilla.org"
!define URLUpdateInfo "http://www.mozilla.org/projects/firefox"

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

@ -1 +1 @@
MOZ_APP_DISPLAYNAME="Namoroka"
MOZ_APP_DISPLAYNAME="MozillaDeveloperPreview"

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

@ -1,3 +1,3 @@
# Do NOT localize or otherwise change these values
browser.startup.homepage=http://www.mozilla.org/projects/namoroka/
browser.startup.homepage=http://www.mozilla.org/projects/devpreview/

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

@ -1,7 +1,7 @@
<!ENTITY brandShortName "Namoroka">
<!ENTITY brandFullName "Namoroka">
<!ENTITY brandShortName "Mozilla Developer Preview">
<!ENTITY brandFullName "Mozilla Developer Preview">
<!ENTITY vendorShortName "mozilla.org">
<!ENTITY logoTrademark " ">
<!-- LOCALIZATION NOTE (releaseBaseURL): The about: page appends __MOZ_APP_VERSION__.html, e.g. 2.0.html -->
<!ENTITY releaseBaseURL "http://www.mozilla.org/projects/namoroka/releases/">
<!ENTITY releaseBaseURL "http://www.mozilla.org/projects/devpreview/releases/">

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

@ -1,3 +1,3 @@
brandShortName=Namoroka
brandFullName=Namoroka
brandShortName=Mozilla Developer Preview
brandFullName=Mozilla Developer Preview
vendorShortName=mozilla.org

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

@ -138,6 +138,7 @@ DistributionCustomizer.prototype = {
let m = /^item\.(\d+)\.(\w+)\.?(\w*)/.exec(keys[i]);
if (m) {
let [foo, iid, iprop, ilocale] = m;
iid = parseInt(iid);
if (ilocale)
continue;

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

@ -1724,7 +1724,7 @@ MicrosummaryResource.prototype = {
// nsIAuthPrompt and nsIPrompt need separate implementations because
// their method signatures conflict. The other interfaces we implement
// within MicrosummaryResource itself.
switch(iid) {
switch (iid) {
case Ci.nsIAuthPrompt:
return this.authPrompt;
case Ci.nsIPrompt:

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

@ -137,7 +137,7 @@ BrowserGlue.prototype = {
// nsIObserver implementation
observe: function BG_observe(subject, topic, data) {
switch(topic) {
switch (topic) {
case "xpcom-shutdown":
this._dispose();
break;

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

@ -196,7 +196,7 @@ var BookmarkPropertiesPanel = {
PlacesUtils.bookmarks.DEFAULT_INDEX,
Ci.nsITreeView.DROP_ON);
switch(dialogInfo.type) {
switch (dialogInfo.type) {
case "bookmark":
this._itemType = BOOKMARK_ITEM;
if ("uri" in dialogInfo) {

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

@ -459,7 +459,7 @@ PlacesController.prototype = {
// We don't use the nodeIs* methods here to avoid going through the type
// property way too often
switch(nodeType) {
switch (nodeType) {
case Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY:
nodeData["query"] = true;
if (node.parent) {

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

@ -47,47 +47,45 @@ const TEST_URI = "http://www.mozilla.org/";
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
var organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Check left pane.
ok(PlacesUIUtils.leftPaneFolderId > 0,
"Left pane folder correctly created");
var leftPaneItems =
PlacesUtils.annotations
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
is(leftPaneItems.length, 1,
"We correctly have only 1 left pane folder");
var leftPaneRoot = leftPaneItems[0];
is(leftPaneRoot, PlacesUIUtils.leftPaneFolderId,
"leftPaneFolderId getter has correct value");
// Check version has been upgraded.
var version =
PlacesUtils.annotations.getItemAnnotation(leftPaneRoot,
ORGANIZER_FOLDER_ANNO);
is(version, ORGANIZER_LEFTPANE_VERSION,
"Left pane version has been correctly upgraded");
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
var organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Check left pane.
ok(PlacesUIUtils.leftPaneFolderId > 0,
"Left pane folder correctly created");
var leftPaneItems =
PlacesUtils.annotations
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
is(leftPaneItems.length, 1,
"We correctly have only 1 left pane folder");
var leftPaneRoot = leftPaneItems[0];
is(leftPaneRoot, PlacesUIUtils.leftPaneFolderId,
"leftPaneFolderId getter has correct value");
// Check version has been upgraded.
var version =
PlacesUtils.annotations.getItemAnnotation(leftPaneRoot,
ORGANIZER_FOLDER_ANNO);
is(version, ORGANIZER_LEFTPANE_VERSION,
"Left pane version has been correctly upgraded");
// Check left pane is populated.
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
is(organizer.PlacesOrganizer._places.selectedNode.itemId,
PlacesUIUtils.leftPaneQueries["History"],
"Library left pane is populated and working");
// Check left pane is populated.
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
is(organizer.PlacesOrganizer._places.selectedNode.itemId,
PlacesUIUtils.leftPaneQueries["History"],
"Library left pane is populated and working");
// Close Library window.
organizer.close();
// No need to cleanup anything, we have a correct left pane now.
finish();
});
}, false);
}
}
};
// Close Library window.
organizer.close();
// No need to cleanup anything, we have a correct left pane now.
finish();
});
}, false);
}
function test() {
waitForExplicitFinish();

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

@ -225,17 +225,15 @@ gTests.push({
var tagsField = this.window.document.getElementById("editBMPanel_tagsField");
var self = this;
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowclosed" &&
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
ww.unregisterNotification(this);
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
ok(false, "Dialog window should not be closed by pressing Enter on the autocomplete popup");
self.finish();
}
function windowObserver(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed" &&
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
ww.unregisterNotification(windowObserver);
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
ok(false, "Dialog window should not be closed by pressing Enter on the autocomplete popup");
self.finish();
}
};
}
var popupListener = {
handleEvent: function(aEvent) {
@ -384,17 +382,15 @@ gTests.push({
var tagsField = this.window.document.getElementById("editBMPanel_tagsField");
var self = this;
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowclosed" &&
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
ww.unregisterNotification(this);
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
ok(false, "Dialog window should not be closed by pressing Escape on the autocomplete popup");
self.finish();
}
function windowObserver(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed" &&
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
ww.unregisterNotification(windowObserver);
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
ok(false, "Dialog window should not be closed by pressing Escape on the autocomplete popup");
self.finish();
}
};
}
var popupListener = {
handleEvent: function(aEvent) {
@ -486,17 +482,15 @@ gTests.push({
var folderTree = this.window.document.getElementById("editBMPanel_folderTree");
var self = this;
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowclosed" &&
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL_MINIMAL_UI) {
ww.unregisterNotification(this);
ok(self._cleanShutdown,
"Dialog window should not be closed by pressing ESC in folder name textbox");
self.finish();
}
function windowObserver(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed" &&
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL_MINIMAL_UI) {
ww.unregisterNotification(windowObserver);
ok(self._cleanShutdown,
"Dialog window should not be closed by pressing ESC in folder name textbox");
self.finish();
}
};
}
ww.registerNotification(windowObserver);
folderTree.addEventListener("DOMAttrModified", function onDOMAttrModified(event) {
@ -601,32 +595,30 @@ function open_properties_dialog() {
"We have a places node selected: " + tree.selectedNode.title);
// Wait for the Properties dialog.
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
var win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("focus", function(event) {
win.removeEventListener("focus", arguments.callee, false);
// Windows has been loaded, execute our test now.
executeSoon(function () {
// Ensure overlay is loaded
ok(win.gEditItemOverlay._initialized, "EditItemOverlay is initialized");
gCurrentTest.window = win;
try {
gCurrentTest.run();
} catch (ex) {
ok(false, "An error occured during test run: " + ex.message);
}
});
}, false);
}
}
};
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
var win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("focus", function (event) {
win.removeEventListener("focus", arguments.callee, false);
// Windows has been loaded, execute our test now.
executeSoon(function () {
// Ensure overlay is loaded
ok(win.gEditItemOverlay._initialized, "EditItemOverlay is initialized");
gCurrentTest.window = win;
try {
gCurrentTest.run();
} catch (ex) {
ok(false, "An error occured during test run: " + ex.message);
}
});
}, false);
}
ww.registerNotification(windowObserver);
var command = null;
switch(gCurrentTest.action) {
switch (gCurrentTest.action) {
case ACTION_EDIT:
command = "placesCmd_show:info";
break;

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

@ -55,54 +55,52 @@ function test() {
});
function testForgetThisSiteVisibility(selectionCount, funcNext) {
let observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Select History in the left pane.
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
let PO = organizer.PlacesOrganizer;
let histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
histContainer.containerOpen = true;
PO._places.selectNode(histContainer.getChild(0));
// Select the first history entry.
let doc = organizer.document;
let tree = PO._content;
let selection = tree.view.selection;
selection.clearSelection();
selection.rangedSelect(0, selectionCount - 1, true);
is(selection.count, selectionCount,
"The selected range is as big as expected");
// Open the context menu
let contextmenu = doc.getElementById("placesContext");
contextmenu.addEventListener("popupshown", function() {
contextmenu.removeEventListener("popupshown", arguments.callee, false);
let forgetThisSite = doc.getElementById("placesContext_deleteHost");
let hideForgetThisSite = (selectionCount != 1);
is(forgetThisSite.hidden, hideForgetThisSite,
"The Forget this site menu item should " + (hideForgetThisSite ? "" : "not ") +
"be hidden with " + selectionCount + " items selected");
// Close the context menu
contextmenu.hidePopup();
// Close Library window.
organizer.close();
// Proceed
funcNext();
}, false);
let event = document.createEvent("MouseEvents");
event.initMouseEvent("contextmenu", true, true, organizer, 0,
0, 0, 0, 0, false, false, false, false,
0, null);
tree.dispatchEvent(event);
});
function observer(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(observer);
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Select History in the left pane.
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
let PO = organizer.PlacesOrganizer;
let histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
histContainer.containerOpen = true;
PO._places.selectNode(histContainer.getChild(0));
// Select the first history entry.
let doc = organizer.document;
let tree = PO._content;
let selection = tree.view.selection;
selection.clearSelection();
selection.rangedSelect(0, selectionCount - 1, true);
is(selection.count, selectionCount,
"The selected range is as big as expected");
// Open the context menu
let contextmenu = doc.getElementById("placesContext");
contextmenu.addEventListener("popupshown", function() {
contextmenu.removeEventListener("popupshown", arguments.callee, false);
let forgetThisSite = doc.getElementById("placesContext_deleteHost");
let hideForgetThisSite = (selectionCount != 1);
is(forgetThisSite.hidden, hideForgetThisSite,
"The Forget this site menu item should " + (hideForgetThisSite ? "" : "not ") +
"be hidden with " + selectionCount + " items selected");
// Close the context menu
contextmenu.hidePopup();
// Close Library window.
organizer.close();
// Proceed
funcNext();
}, false);
}
}
};
let event = document.createEvent("MouseEvents");
event.initMouseEvent("contextmenu", true, true, organizer, 0,
0, 0, 0, 0, false, false, false, false,
0, null);
tree.dispatchEvent(event);
});
}, false);
}
ww.registerNotification(observer);
ww.openWindow(null,

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

@ -219,21 +219,16 @@ function nextTest() {
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
gLibrary.addEventListener("load", function onLoad(event) {
gLibrary.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Execute tests.
nextTest();
});
}, false);
}
}
};
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
gLibrary.addEventListener("load", function onLoad(event) {
gLibrary.removeEventListener("load", onLoad, false);
executeSoon(nextTest);
}, false);
}
function test() {
dump("Starting test browser_library_infoBox.js\n");

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

@ -176,21 +176,16 @@ function nextTest() {
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
gLibrary.addEventListener("load", function onLoad(event) {
gLibrary.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Execute tests.
nextTest();
});
}, false);
}
}
};
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
gLibrary.addEventListener("load", function onLoad(event) {
gLibrary.removeEventListener("load", onLoad, false);
executeSoon(nextTest);
}, false);
}
function test() {
waitForExplicitFinish();

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

@ -49,34 +49,32 @@ var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
// correctTitle: original and correct query's title.
var leftPaneQueries = [];
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
var organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Check titles have been fixed.
for (var i = 0; i < leftPaneQueries.length; i++) {
var query = leftPaneQueries[i];
is(PlacesUtils.bookmarks.getItemTitle(query.itemId),
query.correctTitle, "Title is correct for query " + query.name);
if ("concreteId" in query) {
is(PlacesUtils.bookmarks.getItemTitle(query.concreteId),
query.concreteTitle, "Concrete title is correct for query " + query.name);
}
}
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
var organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Check titles have been fixed.
for (var i = 0; i < leftPaneQueries.length; i++) {
var query = leftPaneQueries[i];
is(PlacesUtils.bookmarks.getItemTitle(query.itemId),
query.correctTitle, "Title is correct for query " + query.name);
if ("concreteId" in query) {
is(PlacesUtils.bookmarks.getItemTitle(query.concreteId),
query.concreteTitle, "Concrete title is correct for query " + query.name);
}
}
// Close Library window.
organizer.close();
// No need to cleanup anything, we have a correct left pane now.
finish();
});
}, false);
}
}
};
// Close Library window.
organizer.close();
// No need to cleanup anything, we have a correct left pane now.
finish();
});
}, false);
}
function test() {
waitForExplicitFinish();

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

@ -267,19 +267,17 @@ function test() {
// Window watcher for Library window.
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
gLibrary.addEventListener("load", function onLoad(event) {
gLibrary.removeEventListener("load", onLoad, false);
// Kick off tests.
setTimeout(runNextTest, 0);
}, false);
}
}
};
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
gLibrary.addEventListener("load", function onLoad(event) {
gLibrary.removeEventListener("load", onLoad, false);
// Kick off tests.
setTimeout(runNextTest, 0);
}, false);
}
// Open Library window.
ww.registerNotification(windowObserver);

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

@ -48,22 +48,20 @@
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
let windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onLoad(event) {
win.removeEventListener("load", onLoad, false);
executeSoon(function () {
ok(true, "Library has been correctly opened");
win.close();
finish();
});
}, false);
}
}
};
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onLoad(event) {
win.removeEventListener("load", onLoad, false);
executeSoon(function () {
ok(true, "Library has been correctly opened");
win.close();
finish();
});
}, false);
}
function test() {
waitForExplicitFinish();

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

@ -53,37 +53,35 @@ const TEST_URI = "http://www.mozilla.org/";
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
let windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
let contentTree = organizer.document.getElementById("placeContent");
isnot(contentTree, null, "Sanity check: placeContent tree should exist");
isnot(organizer.PlacesOrganizer, null, "Sanity check: PlacesOrganizer should exist");
isnot(organizer.gEditItemOverlay, null, "Sanity check: gEditItemOverlay should exist");
isnot(organizer.gEditItemOverlay.itemId, -1, "Editing a bookmark");
// Select History in the left pane.
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
// Select the first history entry.
let selection = contentTree.view.selection;
selection.clearSelection();
selection.rangedSelect(0, 0, true);
// Check the panel is editing the history entry.
is(organizer.gEditItemOverlay.itemId, -1, "Editing an history entry");
// Close Library window.
organizer.close();
// Clean up history.
PlacesUtils.history.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
finish();
});
}, false);
}
}
};
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
let contentTree = organizer.document.getElementById("placeContent");
isnot(contentTree, null, "Sanity check: placeContent tree should exist");
isnot(organizer.PlacesOrganizer, null, "Sanity check: PlacesOrganizer should exist");
isnot(organizer.gEditItemOverlay, null, "Sanity check: gEditItemOverlay should exist");
isnot(organizer.gEditItemOverlay.itemId, -1, "Editing a bookmark");
// Select History in the left pane.
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
// Select the first history entry.
let selection = contentTree.view.selection;
selection.clearSelection();
selection.rangedSelect(0, 0, true);
// Check the panel is editing the history entry.
is(organizer.gEditItemOverlay.itemId, -1, "Editing an history entry");
// Close Library window.
organizer.close();
// Clean up history.
PlacesUtils.history.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
finish();
});
}, false);
}
function test() {
waitForExplicitFinish();

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

@ -300,18 +300,16 @@ function test() {
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
var win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onLoad(event) {
win.removeEventListener("load", onLoad, false);
executeSoon(function () testHelper(win));
}, false);
}
}
};
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
var win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onLoad(event) {
win.removeEventListener("load", onLoad, false);
executeSoon(function () testHelper(win));
}, false);
}
ww.registerNotification(windowObserver);
ww.openWindow(null,

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

@ -58,18 +58,16 @@ function test() {
// Open Library, we will check the left pane.
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
gLibrary.addEventListener("load", function onLoad(event) {
gLibrary.removeEventListener("load", onLoad, false);
executeSoon(startTest);
}, false);
}
}
};
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
gLibrary.addEventListener("load", function onLoad(event) {
gLibrary.removeEventListener("load", onLoad, false);
executeSoon(startTest);
}, false);
}
ww.registerNotification(windowObserver);
ww.openWindow(null,
"chrome://browser/content/places/places.xul",

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

@ -124,24 +124,22 @@ function test() {
if (preFunc)
preFunc();
let observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
let alertDialog = aSubject.QueryInterface(Ci.nsIDOMWindow);
alertDialog.addEventListener("load", function() {
alertDialog.removeEventListener("load", arguments.callee, false);
info("alert dialog observed as expected");
executeSoon(function() {
alertDialog.close();
toggleSidebar(currentTest.sidebarName);
currentTest.cleanup();
postFunc();
});
}, false);
}
}
};
function observer(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(observer);
let alertDialog = aSubject.QueryInterface(Ci.nsIDOMWindow);
alertDialog.addEventListener("load", function () {
alertDialog.removeEventListener("load", arguments.callee, false);
info("alert dialog observed as expected");
executeSoon(function () {
alertDialog.close();
toggleSidebar(currentTest.sidebarName);
currentTest.cleanup();
postFunc();
});
}, false);
}
ww.registerNotification(observer);
// Select the inserted places item.

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

@ -271,32 +271,30 @@ function test() {
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
let windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onLoad(event) {
win.removeEventListener("load", onLoad, false);
executeSoon(function () {
let tree = win.document.getElementById("placeContent");
isnot(tree, null, "sanity check: placeContent tree should exist");
// Run the tests.
testSortByColAndDir(win, tree, true);
testSortByColAndDir(win, tree, false);
testSortByDir(win, tree, true);
testSortByDir(win, tree, false);
testInvalid(win, tree);
// Reset the sort to SORT_BY_NONE.
setSort(win, tree, false, false);
// Close the window and finish.
win.close();
finish();
});
}, false);
}
}
};
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onLoad(event) {
win.removeEventListener("load", onLoad, false);
executeSoon(function () {
let tree = win.document.getElementById("placeContent");
isnot(tree, null, "sanity check: placeContent tree should exist");
// Run the tests.
testSortByColAndDir(win, tree, true);
testSortByColAndDir(win, tree, false);
testSortByDir(win, tree, true);
testSortByDir(win, tree, false);
testInvalid(win, tree);
// Reset the sort to SORT_BY_NONE.
setSort(win, tree, false, false);
// Close the window and finish.
win.close();
finish();
});
}, false);
}
ww.registerNotification(windowObserver);
ww.openWindow(null,

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

@ -15,7 +15,7 @@
*
* The Original Code is Places Unit Test code.
*
* The Initial Developer of the Original Code is Mozilla Corp.
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
@ -42,12 +42,13 @@
*/
function run_test() {
do_test_pending();
// Create our bookmarks.html copying bookmarks.glue.html to the profile
// folder. It will be ignored.
// folder. It should be ignored.
create_bookmarks_html("bookmarks.glue.html");
// Create our JSON backup copying bookmarks.glue.json to the profile
// folder. It will be ignored.
// Create our JSON backup copying bookmarks.glue.json to the profile folder.
create_JSON_backup("bookmarks.glue.json");
// Remove current database file.
@ -73,25 +74,34 @@ function run_test() {
// nsBrowserGlue uses databaseStatus to manage initialization.
do_check_eq(hs.databaseStatus, hs.DATABASE_STATUS_CORRUPT);
// Restore could take some time, usually less than 1s.
// We will poll later in continue_test to be sure restore has finished.
do_test_pending();
do_timeout(1000, continue_test);
// Wait for restore to finish.
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let observer = {
observe: function(aSubject, aTopic, aData) {
os.removeObserver(observer, "bookmarks-restore-success");
os.removeObserver(observer, "bookmarks-restore-failed");
do_check_eq(aTopic, "bookmarks-restore-success");
do_check_eq(aData, "json");
continue_test();
}
}
os.addObserver(observer, "bookmarks-restore-success", false);
os.addObserver(observer, "bookmarks-restore-failed", false);
}
function continue_test() {
let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
if (bs.getIdForItemAt(bs.toolbarFolder, 0) == -1) {
// Not enough time to complete restore, poll again later.
do_timeout(1000, continue_test);
return;
}
// Check that JSON backup has been restored.
let itemId = bs.getIdForItemAt(bs.toolbarFolder, SMART_BOOKMARKS_ON_TOOLBAR);
// Notice restore from JSON notification is fired before smart bookmarks creation.
let itemId = bs.getIdForItemAt(bs.toolbarFolder, 0);
do_check_neq(itemId, -1);
do_check_eq(bs.getItemTitle(itemId), "examplejson");
remove_bookmarks_html();
remove_all_JSON_backups();
do_test_finished();
}

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

@ -15,7 +15,7 @@
*
* The Original Code is Places Unit Test code.
*
* The Initial Developer of the Original Code is Mozilla Corp.
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
@ -41,49 +41,23 @@
* is corrupt but a JSON backup is not available.
*/
const NS_PLACES_INIT_COMPLETE_TOPIC = "places-init-complete";
// Create an observer for the Places notifications
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
var observer = {
observe: function thn_observe(aSubject, aTopic, aData) {
if (aTopic == NS_PLACES_INIT_COMPLETE_TOPIC) {
os.removeObserver(this, NS_PLACES_INIT_COMPLETE_TOPIC);
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
// Check the database was corrupt.
// nsBrowserGlue uses databaseStatus to manage initialization.
do_check_eq(hs.databaseStatus, hs.DATABASE_STATUS_CORRUPT);
// Enqueue next part of the test.
var tm = Cc["@mozilla.org/thread-manager;1"].
getService(Ci.nsIThreadManager);
tm.mainThread.dispatch({
run: function() {
continue_test();
}
}, Ci.nsIThread.DISPATCH_NORMAL);
}
}
};
os.addObserver(observer, NS_PLACES_INIT_COMPLETE_TOPIC, false);
function run_test() {
do_test_pending();
// Create bookmarks.html in the profile.
create_bookmarks_html("bookmarks.glue.html");
// Remove JSON backup from profile.
remove_all_JSON_backups();
// Remove current database file.
var db = gProfD.clone();
let db = gProfD.clone();
db.append("places.sqlite");
if (db.exists()) {
db.remove(false);
do_check_false(db.exists());
}
// Create a corrupt database.
var corruptDB = gTestDir.clone();
let corruptDB = gTestDir.clone();
corruptDB.append("corruptDB.sqlite");
corruptDB.copyTo(gProfD, "places.sqlite");
do_check_true(db.exists());
@ -92,20 +66,39 @@ function run_test() {
Cc["@mozilla.org/browser/browserglue;1"].getService(Ci.nsIBrowserGlue);
// Initialize Places through the History Service.
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
// Check the database was corrupt.
// nsBrowserGlue uses databaseStatus to manage initialization.
do_check_eq(hs.databaseStatus, hs.DATABASE_STATUS_CORRUPT);
// Wait for init-complete notification before going on.
do_test_pending();
// Wait for restore to finish.
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let observer = {
observe: function(aSubject, aTopic, aData) {
os.removeObserver(observer, "bookmarks-restore-success");
os.removeObserver(observer, "bookmarks-restore-failed");
do_check_eq(aTopic, "bookmarks-restore-success");
do_check_eq(aData, "html-initial");
continue_test();
}
}
os.addObserver(observer, "bookmarks-restore-success", false);
os.addObserver(observer, "bookmarks-restore-failed", false);
}
function continue_test() {
var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
var itemId = bs.getIdForItemAt(bs.toolbarFolder, SMART_BOOKMARKS_ON_TOOLBAR);
// Check that bookmarks html has been restored.
// Notice restore from HTML notification is fired after smart bookmarks creation.
let itemId = bs.getIdForItemAt(bs.toolbarFolder, SMART_BOOKMARKS_ON_TOOLBAR);
do_check_neq(itemId, -1);
do_check_eq(bs.getItemTitle(itemId), "example");
remove_bookmarks_html();
do_test_finished();
}

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

@ -15,7 +15,7 @@
*
* The Original Code is Places Unit Test code.
*
* The Initial Developer of the Original Code is Mozilla Corp.
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
@ -41,49 +41,23 @@
* corrupt, nor a JSON backup nor bookmarks.html are available.
*/
const NS_PLACES_INIT_COMPLETE_TOPIC = "places-init-complete";
// Create an observer for the Places notifications
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
var observer = {
observe: function thn_observe(aSubject, aTopic, aData) {
if (aTopic == NS_PLACES_INIT_COMPLETE_TOPIC) {
os.removeObserver(this, NS_PLACES_INIT_COMPLETE_TOPIC);
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
// Check the database was corrupt.
// nsBrowserGlue uses databaseStatus to manage initialization.
do_check_eq(hs.databaseStatus, hs.DATABASE_STATUS_CORRUPT);
// Enqueue next part of the test.
var tm = Cc["@mozilla.org/thread-manager;1"].
getService(Ci.nsIThreadManager);
tm.mainThread.dispatch({
run: function() {
continue_test();
}
}, Ci.nsIThread.DISPATCH_NORMAL);
}
}
};
os.addObserver(observer, NS_PLACES_INIT_COMPLETE_TOPIC, false);
function run_test() {
do_test_pending();
// Remove bookmarks.html from profile.
remove_bookmarks_html();
// Remove JSON backup from profile.
remove_all_JSON_backups();
// Remove current database file.
var db = gProfD.clone();
let db = gProfD.clone();
db.append("places.sqlite");
if (db.exists()) {
db.remove(false);
do_check_false(db.exists());
}
// Create a corrupt database.
var corruptDB = gTestDir.clone();
let corruptDB = gTestDir.clone();
corruptDB.append("corruptDB.sqlite");
corruptDB.copyTo(gProfD, "places.sqlite");
do_check_true(db.exists());
@ -92,20 +66,36 @@ function run_test() {
Cc["@mozilla.org/browser/browserglue;1"].getService(Ci.nsIBrowserGlue);
// Initialize Places through the History Service.
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
// Check the database was corrupt.
// nsBrowserGlue uses databaseStatus to manage initialization.
do_check_eq(hs.databaseStatus, hs.DATABASE_STATUS_CORRUPT);
// Wait for init-complete notification before going on.
do_test_pending();
// Wait for restore to finish.
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let observer = {
observe: function(aSubject, aTopic, aData) {
os.removeObserver(observer, "bookmarks-restore-success");
os.removeObserver(observer, "bookmarks-restore-failed");
do_check_eq(aTopic, "bookmarks-restore-success");
do_check_eq(aData, "html-initial");
continue_test();
}
}
os.addObserver(observer, "bookmarks-restore-success", false);
os.addObserver(observer, "bookmarks-restore-failed", false);
}
function continue_test() {
var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
// Check that default bookmarks have been restored.
var itemId = bs.getIdForItemAt(bs.toolbarFolder, SMART_BOOKMARKS_ON_TOOLBAR + 1);
let itemId = bs.getIdForItemAt(bs.toolbarFolder, SMART_BOOKMARKS_ON_TOOLBAR);
do_check_true(itemId > 0);
do_check_eq(bs.getItemTitle(itemId), "Getting Started");
do_test_finished();
}

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

@ -47,22 +47,12 @@ const PREF_BMPROCESSED = "distribution.516444.bookmarksProcessed";
const PREF_DISTRIBUTION_ID = "distribution.id";
const TOPIC_FINAL_UI_STARTUP = "final-ui-startup";
const TOPIC_PLACES_INIT_COMPLETE = "places-init-complete";
const TOPIC_CUSTOMIZATION_COMPLETE = "distribution-customization-complete";
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic == TOPIC_CUSTOMIZATION_COMPLETE) {
os.removeObserver(this, TOPIC_CUSTOMIZATION_COMPLETE);
do_timeout(0, continue_test);
}
}
}
os.addObserver(observer, TOPIC_CUSTOMIZATION_COMPLETE, false);
function run_test() {
do_test_pending();
// Copy distribution.ini file to our app dir.
let distroDir = dirSvc.get("XCurProcD", Ci.nsIFile);
distroDir.append("distribution");
@ -82,9 +72,10 @@ function run_test() {
let ps = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
ps.setIntPref(PREF_SMART_BOOKMARKS_VERSION, -1);
// Avoid migrateUI, we are just simulating a partial startup.
ps.setIntPref("browser.migration.version", 1);
// Initialize Places through the History Service, so it won't trigger
// browserGlue::_initPlaces since browserGlue is not yet in context.
// Initialize Places through the History Service.
let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
// Check a new database has been created.
@ -92,14 +83,30 @@ function run_test() {
do_check_eq(hs.databaseStatus, hs.DATABASE_STATUS_CREATE);
// Initialize nsBrowserGlue.
Cc["@mozilla.org/browser/browserglue;1"].getService(Ci.nsIBrowserGlue);
let bg = Cc["@mozilla.org/browser/browserglue;1"].
getService(Ci.nsIBrowserGlue);
os.notifyObservers(null, TOPIC_FINAL_UI_STARTUP, null);
// places-init-complete is an enqueued notification so it will be notified
// when exiting from this scope.
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let observer = {
observe: function(aSubject, aTopic, aData) {
os.removeObserver(this, TOPIC_PLACES_INIT_COMPLETE);
do_test_pending();
// Test will continue on customization complete notification.
// Simulate browser startup.
bg.QueryInterface(Ci.nsIObserver).observe(null,
TOPIC_FINAL_UI_STARTUP,
null);
// Test will continue on customization complete notification.
let observer = {
observe: function(aSubject, aTopic, aData) {
os.removeObserver(this, TOPIC_CUSTOMIZATION_COMPLETE);
continue_test();
}
}
os.addObserver(observer, TOPIC_CUSTOMIZATION_COMPLETE, false);
}
}
os.addObserver(observer, TOPIC_PLACES_INIT_COMPLETE, false);
}
function continue_test() {

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

@ -15,7 +15,7 @@
*
* The Original Code is Places Unit Test code.
*
* The Initial Developer of the Original Code is Mozilla Corp.
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
@ -44,8 +44,6 @@
const PREF_SMART_BOOKMARKS_VERSION = "browser.places.smartBookmarksVersion";
const TOPIC_PLACES_INIT_COMPLETE = "places-init-complete";
function run_test() {
// Create our bookmarks.html copying bookmarks.glue.html to the profile
// folder. It will be ignored.
@ -79,13 +77,8 @@ function run_test() {
bs.DEFAULT_INDEX, "migrated");
// Initialize nsBrowserGlue.
Cc["@mozilla.org/browser/browserglue;1"].getService(Ci.nsIBrowserGlue);
// Places initialization has already happened, so we need to simulate
// it. This will force browserGlue::_initPlaces().
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.notifyObservers(null, TOPIC_PLACES_INIT_COMPLETE, null);
let bg = Cc["@mozilla.org/browser/browserglue;1"].
getService(Ci.nsIBrowserGlue);
// Import could take some time, usually less than 1s, but to be sure we will
// check after 3s.
@ -105,5 +98,7 @@ function continue_test() {
do_check_eq(bs.getIdForItemAt(bs.bookmarksMenuFolder, 1), -1);
do_check_eq(bs.getIdForItemAt(bs.toolbarFolder, 0), -1);
remove_bookmarks_html();
do_test_finished();
}

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

@ -15,7 +15,7 @@
*
* The Original Code is Places Unit Test code.
*
* The Initial Developer of the Original Code is Mozilla Corp.
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
@ -42,6 +42,8 @@
*/
function run_test() {
do_test_pending();
// Create our bookmarks.html copying bookmarks.glue.html to the profile
// folder. It will be ignored.
create_bookmarks_html("bookmarks.glue.html");
@ -68,25 +70,33 @@ function run_test() {
// nsBrowserGlue uses databaseStatus to manage initialization.
do_check_eq(hs.databaseStatus, hs.DATABASE_STATUS_CREATE);
// Restore could take some time, usually less than 1s.
// We will poll later in continue_test() to be sure restore has finished.
do_test_pending();
do_timeout(1000, continue_test);
// Wait for restore to finish.
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let observer = {
observe: function(aSubject, aTopic, aData) {
os.removeObserver(observer, "bookmarks-restore-success");
os.removeObserver(observer, "bookmarks-restore-failed");
do_check_eq(aTopic, "bookmarks-restore-success");
do_check_eq(aData, "json");
continue_test();
}
}
os.addObserver(observer, "bookmarks-restore-success", false);
os.addObserver(observer, "bookmarks-restore-failed", false);
}
function continue_test() {
let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
if (bs.getIdForItemAt(bs.toolbarFolder, 0) == -1) {
// Not enough time to complete restore, poll again later.
do_timeout(1000, continue_test);
return;
}
// Check that JSON backup has been restored.
let itemId = bs.getIdForItemAt(bs.toolbarFolder, SMART_BOOKMARKS_ON_TOOLBAR);
// Notice restore from JSON notification is fired before smart bookmarks creation.
let itemId = bs.getIdForItemAt(bs.toolbarFolder, 0);
do_check_eq(bs.getItemTitle(itemId), "examplejson");
remove_bookmarks_html();
remove_all_JSON_backups();
do_test_finished();
}

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

@ -15,7 +15,7 @@
*
* The Original Code is Places Unit Test code.
*
* The Initial Developer of the Original Code is Mozilla Corp.
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
@ -41,7 +41,7 @@
* and creating bookmarks backup if one does not exist for today.
*/
// Initialize nsBrowserGlue.
// Initialize nsBrowserGlue after Places.
let bg = Cc["@mozilla.org/browser/browserglue;1"].
getService(Ci.nsIBrowserGlue);
@ -68,10 +68,19 @@ tests.push({
exec: function() {
// Sanity check: we should have bookmarks on the toolbar.
do_check_true(bs.getIdForItemAt(bs.toolbarFolder, 0) > 0);
// Set preferences.
ps.setBoolPref(PREF_AUTO_EXPORT_HTML, true);
// Force nsBrowserGlue::_shutdownPlaces().
os.notifyObservers(null, TOPIC_QUIT_APPLICATION_GRANTED, null);
try {
bg.QueryInterface(Ci.nsIObserver).observe(null,
TOPIC_QUIT_APPLICATION_GRANTED,
null);
}
catch(ex) {
// This throws due to idle observer, we can ignore that.
}
// Check bookmarks.html has been created.
check_bookmarks_html();
@ -94,15 +103,25 @@ tests.push({
exec: function() {
// Sanity check: we should have bookmarks on the toolbar.
do_check_true(bs.getIdForItemAt(bs.toolbarFolder, 0) > 0);
// Setpreferences.
// Set preferences.
ps.setBoolPref(PREF_AUTO_EXPORT_HTML, true);
// Create a bookmarks.html in the profile.
let profileBookmarksHTMLFile = create_bookmarks_html("bookmarks.glue.html");
// Get file lastModified and size.
let lastMod = profileBookmarksHTMLFile.lastModifiedTime;
let fileSize = profileBookmarksHTMLFile.fileSize;
// Force nsBrowserGlue::_shutdownPlaces().
os.notifyObservers(null, TOPIC_QUIT_APPLICATION_GRANTED, null);
try {
bg.QueryInterface(Ci.nsIObserver).observe(null,
TOPIC_QUIT_APPLICATION_GRANTED,
null);
}
catch(ex) {
// This throws due to idle observer, we can ignore that.
}
// Check a new bookmarks.html has been created.
let profileBookmarksHTMLFile = check_bookmarks_html();
@ -126,13 +145,22 @@ tests.push({
exec: function() {
// Sanity check: we should have bookmarks on the toolbar.
do_check_true(bs.getIdForItemAt(bs.toolbarFolder, 0) > 0);
// Create a JSON backup in the profile.
let profileBookmarksJSONFile = create_JSON_backup("bookmarks.glue.json");
// Get file lastModified and size.
let lastMod = profileBookmarksJSONFile.lastModifiedTime;
let fileSize = profileBookmarksJSONFile.fileSize;
// Force nsBrowserGlue::_shutdownPlaces().
os.notifyObservers(null, TOPIC_QUIT_APPLICATION_GRANTED, null);
try {
bg.QueryInterface(Ci.nsIObserver).observe(null,
TOPIC_QUIT_APPLICATION_GRANTED,
null);
}
catch(ex) {
// This throws due to idle observer, we can ignore that.
}
// Check a new JSON backup has not been created.
do_check_true(profileBookmarksJSONFile.exists());
@ -163,6 +191,8 @@ function next_test() {
}
function run_test() {
do_test_pending();
// Clean up bookmarks.
remove_all_bookmarks();
@ -173,6 +203,5 @@ function run_test() {
bs.DEFAULT_INDEX, "bookmark-on-toolbar");
// Kick-off tests.
do_test_pending();
next_test();
}

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

@ -378,8 +378,7 @@ var gMainPane = {
*/
_getDownloadsFolder: function (aFolder)
{
switch(aFolder)
{
switch (aFolder) {
case "Desktop":
var fileLoc = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
@ -440,7 +439,7 @@ var gMainPane = {
getFolderListPref: function ()
{
var folderListPref = document.getElementById("browser.download.folderList");
switch(folderListPref.value) {
switch (folderListPref.value) {
case 0: // Desktop
case 1: // Downloads
return folderListPref.value;

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

@ -19,15 +19,13 @@ function test() {
var obs = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
var observer = {
observe: function(win, topic, data) {
if (topic != "app-handler-pane-loaded")
return;
function observer(win, topic, data) {
if (topic != "app-handler-pane-loaded")
return;
obs.removeObserver(observer, "app-handler-pane-loaded");
runTest(win);
}
};
obs.removeObserver(observer, "app-handler-pane-loaded");
runTest(win);
}
obs.addObserver(observer, "app-handler-pane-loaded", false);
openDialog("chrome://browser/content/preferences/preferences.xul", "Preferences",

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

@ -45,17 +45,17 @@ function test() {
getService(Ci.nsIPrivateBrowsingService);
let consoleService = Cc["@mozilla.org/consoleservice;1"].
getService(Ci.nsIConsoleService);
const kExitMessage = "Message to signal the end of the test";
const EXIT_MESSAGE = "Message to signal the end of the test";
waitForExplicitFinish();
let consoleObserver = {
observe: function (aMessage) {
if (!aMessage.message)
this.gotNull = true;
else if (aMessage.message == kExitMessage) {
else if (aMessage.message == EXIT_MESSAGE) {
// make sure that the null message was received
ok(this.gotNull, "Console should be cleared after leaving the private mode");
// make sure the console does not contain kTestMessage
// make sure the console does not contain TEST_MESSAGE
ok(!messageExists(), "Message should not exist after leaving the private mode");
consoleService.unregisterListener(consoleObserver);
@ -72,15 +72,15 @@ function test() {
consoleService.getMessageArray(out, {});
let messages = out.value || [];
for (let i = 0; i < messages.length; ++i) {
if (messages[i].message == kTestMessage)
if (messages[i].message == TEST_MESSAGE)
return true;
}
return false;
}
const kTestMessage = "Test message from the private browsing test";
const TEST_MESSAGE = "Test message from the private browsing test";
// make sure that the console is not empty
consoleService.logStringMessage(kTestMessage);
consoleService.logStringMessage(TEST_MESSAGE);
ok(!consoleObserver.gotNull, "Console shouldn't be cleared yet");
ok(messageExists(), "Message should exist before leaving the private mode");
@ -90,5 +90,5 @@ function test() {
pb.privateBrowsingEnabled = false;
// signal the end of the test
consoleService.logStringMessage(kExitMessage);
consoleService.logStringMessage(EXIT_MESSAGE);
}

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

@ -40,30 +40,26 @@
// handler prevents the private browsing mode transition.
function test() {
const kTestPage1 = "data:text/html,<body%20onbeforeunload='return%20false;'>first</body>";
const kTestPage2 = "data:text/html,<body%20onbeforeunload='return%20false;'>second</body>";
const TEST_PAGE_1 = "data:text/html,<body%20onbeforeunload='return%20false;'>first</body>";
const TEST_PAGE_2 = "data:text/html,<body%20onbeforeunload='return%20false;'>second</body>";
let pb = Cc["@mozilla.org/privatebrowsing;1"]
.getService(Ci.nsIPrivateBrowsingService);
let promptHelper = {
rejectDialog: 0,
acceptDialog: 0,
confirmCalls: 0,
observe: function(aSubject, aTopic, aData) {
let dialogWin = aSubject.QueryInterface(Ci.nsIDOMWindow);
this.confirmCalls++;
let button;
if (this.acceptDialog-- > 0)
button = dialogWin.document.documentElement.getButton("accept").click();
else if (this.rejectDialog-- > 0)
button = dialogWin.document.documentElement.getButton("cancel").click();
}
};
let rejectDialog = 0;
let acceptDialog = 0;
let confirmCalls = 0;
function promptObserver(aSubject, aTopic, aData) {
let dialogWin = aSubject.QueryInterface(Ci.nsIDOMWindow);
confirmCalls++;
if (acceptDialog-- > 0)
dialogWin.document.documentElement.getButton("accept").click();
else if (rejectDialog-- > 0)
dialogWin.document.documentElement.getButton("cancel").click();
}
Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService)
.addObserver(promptHelper, "common-dialog-loaded", false);
.addObserver(promptObserver, "common-dialog-loaded", false);
waitForExplicitFinish();
let browser1 = gBrowser.getBrowserForTab(gBrowser.addTab());
@ -74,35 +70,35 @@ function test() {
browser2.addEventListener("load", function() {
browser2.removeEventListener("load", arguments.callee, true);
promptHelper.rejectDialog = 1;
rejectDialog = 1;
pb.privateBrowsingEnabled = true;
ok(!pb.privateBrowsingEnabled, "Private browsing mode should not have been activated");
is(promptHelper.confirmCalls, 1, "Only one confirm box should be shown");
is(confirmCalls, 1, "Only one confirm box should be shown");
is(gBrowser.tabContainer.childNodes.length, 3,
"No tabs should be closed because private browsing mode transition was canceled");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, "about:blank",
"The first tab should be a blank tab");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild.nextSibling).currentURI.spec, kTestPage1,
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild.nextSibling).currentURI.spec, TEST_PAGE_1,
"The middle tab should be the same one we opened");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, kTestPage2,
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, TEST_PAGE_2,
"The last tab should be the same one we opened");
is(promptHelper.rejectDialog, 0, "Only one confirm dialog should have been rejected");
is(rejectDialog, 0, "Only one confirm dialog should have been rejected");
promptHelper.confirmCalls = 0;
promptHelper.acceptDialog = 2;
confirmCalls = 0;
acceptDialog = 2;
pb.privateBrowsingEnabled = true;
ok(pb.privateBrowsingEnabled, "Private browsing mode should have been activated");
is(promptHelper.confirmCalls, 2, "Only two confirm boxes should be shown");
is(confirmCalls, 2, "Only two confirm boxes should be shown");
is(gBrowser.tabContainer.childNodes.length, 1,
"Incorrect number of tabs after transition into private browsing");
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
is(gBrowser.selectedBrowser.currentURI.spec, "about:privatebrowsing",
is(gBrowser.currentURI.spec, "about:privatebrowsing",
"Incorrect page displayed after private browsing transition");
is(promptHelper.acceptDialog, 0, "Two confirm dialogs should have been accepted");
is(acceptDialog, 0, "Two confirm dialogs should have been accepted");
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
@ -111,26 +107,26 @@ function test() {
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
promptHelper.confirmCalls = 0;
promptHelper.rejectDialog = 1;
confirmCalls = 0;
rejectDialog = 1;
pb.privateBrowsingEnabled = false;
ok(pb.privateBrowsingEnabled, "Private browsing mode should not have been deactivated");
is(promptHelper.confirmCalls, 1, "Only one confirm box should be shown");
is(confirmCalls, 1, "Only one confirm box should be shown");
is(gBrowser.tabContainer.childNodes.length, 2,
"No tabs should be closed because private browsing mode transition was canceled");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, kTestPage1,
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, TEST_PAGE_1,
"The first tab should be the same one we opened");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, kTestPage2,
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, TEST_PAGE_2,
"The last tab should be the same one we opened");
is(promptHelper.rejectDialog, 0, "Only one confirm dialog should have been rejected");
is(rejectDialog, 0, "Only one confirm dialog should have been rejected");
promptHelper.confirmCalls = 0;
promptHelper.acceptDialog = 2;
confirmCalls = 0;
acceptDialog = 2;
pb.privateBrowsingEnabled = false;
ok(!pb.privateBrowsingEnabled, "Private browsing mode should have been deactivated");
is(promptHelper.confirmCalls, 2, "Only two confirm boxes should be shown");
is(confirmCalls, 2, "Only two confirm boxes should be shown");
is(gBrowser.tabContainer.childNodes.length, 3,
"Incorrect number of tabs after transition into private browsing");
@ -143,28 +139,31 @@ function test() {
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, "about:blank",
"The first tab should be a blank tab");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild.nextSibling).currentURI.spec, kTestPage1,
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild.nextSibling).currentURI.spec, TEST_PAGE_1,
"The middle tab should be the same one we opened");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, kTestPage2,
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, TEST_PAGE_2,
"The last tab should be the same one we opened");
is(promptHelper.acceptDialog, 0, "Two confirm dialogs should have been accepted");
is(promptHelper.acceptDialog, 0, "Two prompts should have been raised");
is(acceptDialog, 0, "Two confirm dialogs should have been accepted");
is(acceptDialog, 0, "Two prompts should have been raised");
promptHelper.acceptDialog = 2;
acceptDialog = 2;
gBrowser.removeTab(gBrowser.tabContainer.lastChild);
gBrowser.removeTab(gBrowser.tabContainer.lastChild);
Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService)
.removeObserver(promptObserver, "common-dialog-loaded", false);
finish();
}
for (let i = 0; i < gBrowser.browsers.length; ++i)
gBrowser.browsers[i].addEventListener("load", waitForLoad, true);
}, true);
gBrowser.selectedBrowser.loadURI(kTestPage2);
gBrowser.selectedBrowser.loadURI(TEST_PAGE_2);
}, true);
gBrowser.selectedBrowser.loadURI(kTestPage1);
gBrowser.selectedBrowser.loadURI(TEST_PAGE_1);
}, true);
}, true);
browser2.loadURI(kTestPage2);
browser2.loadURI(TEST_PAGE_2);
}, true);
browser1.loadURI(kTestPage1);
browser1.loadURI(TEST_PAGE_1);
}

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

@ -65,19 +65,17 @@ function test() {
function testCheckbox() {
let obsSvc = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
obsSvc.addObserver({
observe: function(aSubject, aTopic, aData) {
obsSvc.removeObserver(this, "cert-exception-ui-ready", false);
ok(win.gCert, "The certificate information should be available now");
obsSvc.addObserver(function (aSubject, aTopic, aData) {
obsSvc.removeObserver(arguments.callee, "cert-exception-ui-ready", false);
ok(win.gCert, "The certificate information should be available now");
let checkbox = win.document.getElementById("permanent");
ok(checkbox.hasAttribute("disabled"),
"the permanent checkbox should be disabled when handling the private browsing mode");
ok(!checkbox.hasAttribute("checked"),
"the permanent checkbox should not be checked when handling the private browsing mode");
win.close();
step2();
}
let checkbox = win.document.getElementById("permanent");
ok(checkbox.hasAttribute("disabled"),
"the permanent checkbox should be disabled when handling the private browsing mode");
ok(!checkbox.hasAttribute("checked"),
"the permanent checkbox should not be checked when handling the private browsing mode");
win.close();
step2();
}, "cert-exception-ui-ready", false);
}
var win = openDialog(EXCEPTIONS_DLG_URL, "", EXCEPTIONS_DLG_FEATURES, params);
@ -94,19 +92,17 @@ function test() {
function testCheckbox() {
let obsSvc = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
obsSvc.addObserver({
observe: function(aSubject, aTopic, aData) {
obsSvc.removeObserver(this, "cert-exception-ui-ready", false);
ok(win.gCert, "The certificate information should be available now");
obsSvc.addObserver(function (aSubject, aTopic, aData) {
obsSvc.removeObserver(arguments.callee, "cert-exception-ui-ready", false);
ok(win.gCert, "The certificate information should be available now");
let checkbox = win.document.getElementById("permanent");
ok(!checkbox.hasAttribute("disabled"),
"the permanent checkbox should not be disabled when not handling the private browsing mode");
ok(checkbox.hasAttribute("checked"),
"the permanent checkbox should be checked when not handling the private browsing mode");
win.close();
cleanup();
}
let checkbox = win.document.getElementById("permanent");
ok(!checkbox.hasAttribute("disabled"),
"the permanent checkbox should not be disabled when not handling the private browsing mode");
ok(checkbox.hasAttribute("checked"),
"the permanent checkbox should be checked when not handling the private browsing mode");
win.close();
cleanup();
}, "cert-exception-ui-ready", false);
}
var win = openDialog(EXCEPTIONS_DLG_URL, "", EXCEPTIONS_DLG_FEATURES, params);

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

@ -117,11 +117,9 @@ function test() {
}
}
let observer = {
observe: function (aSubject, aTopic, aData) {
isnot(aTopic, "domwindowopened", "The -private-toggle argument should be silent");
}
};
function observer(aSubject, aTopic, aData) {
isnot(aTopic, "domwindowopened", "The -private-toggle argument should be silent");
}
ww.registerNotification(observer);
let tab = gBrowser.selectedTab;

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

@ -50,33 +50,32 @@ function test() {
waitForExplicitFinish();
function checkRememberOption(expectedDisabled, callback) {
let observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onLoad(event) {
win.removeEventListener("load", onLoad, false);
function observer(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
executeSoon(function() {
let doc = win.document;
let remember = doc.getElementById("persistDomainAcceptance");
ok(remember, "The remember checkbox should exist");
ww.unregisterNotification(observer);
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onLoad(event) {
win.removeEventListener("load", onLoad, false);
if (expectedDisabled)
is(remember.getAttribute("disabled"), "true",
"The checkbox should be disabled");
else
ok(!remember.hasAttribute("disabled"),
"The checkbox should not be disabled");
executeSoon(function () {
let doc = win.document;
let remember = doc.getElementById("persistDomainAcceptance");
ok(remember, "The remember checkbox should exist");
win.close();
callback();
});
}, false);
}
}
};
if (expectedDisabled)
is(remember.getAttribute("disabled"), "true",
"The checkbox should be disabled");
else
ok(!remember.hasAttribute("disabled"),
"The checkbox should not be disabled");
win.close();
callback();
});
}, false);
}
ww.registerNotification(observer);
let remember = {};

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

@ -44,45 +44,41 @@ function test() {
getService(Ci.nsIPrivateBrowsingService);
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let ss = Cc["@mozilla.org/browser/sessionstore;1"].
getService(Ci.nsISessionStore);
let pbCmd = document.getElementById("Tools:PrivateBrowsing");
waitForExplicitFinish();
let observer = {
pass: 1,
observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
case "private-browsing":
setTimeout(function() {
ok(document.getElementById("Tools:PrivateBrowsing").hasAttribute("disabled"),
"The private browsing command should be disabled immediately after the mode switch");
}, 0);
break;
let pass = 1;
function observer(aSubject, aTopic, aData) {
switch (aTopic) {
case "private-browsing":
setTimeout(function () {
ok(document.getElementById("Tools:PrivateBrowsing").hasAttribute("disabled"),
"The private browsing command should be disabled immediately after the mode switch");
}, 0);
break;
case "private-browsing-transition-complete":
if (this.pass++ == 1) {
setTimeout(function() {
ok(!pbCmd.hasAttribute("disabled"),
"The private browsing command should be re-enabled after entering the private browsing mode");
case "private-browsing-transition-complete":
if (pass++ == 1) {
setTimeout(function () {
ok(!pbCmd.hasAttribute("disabled"),
"The private browsing command should be re-enabled after entering the private browsing mode");
pb.privateBrowsingEnabled = false;
}, 100);
}
else {
setTimeout(function() {
ok(!pbCmd.hasAttribute("disabled"),
"The private browsing command should be re-enabled after exiting the private browsing mode");
pb.privateBrowsingEnabled = false;
}, 100);
}
else {
setTimeout(function () {
ok(!pbCmd.hasAttribute("disabled"),
"The private browsing command should be re-enabled after exiting the private browsing mode");
os.removeObserver(observer, "private-browsing");
os.removeObserver(observer, "private-browsing-transition-complete");
finish();
}, 100);
}
break;
}
os.removeObserver(observer, "private-browsing");
os.removeObserver(observer, "private-browsing-transition-complete");
finish();
}, 100);
}
break;
}
};
}
os.addObserver(observer, "private-browsing", false);
os.addObserver(observer, "private-browsing-transition-complete", false);

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

@ -55,54 +55,53 @@ function test() {
ok(visitId > 0, TEST_URI + " successfully marked visited");
function testForgetThisSiteVisibility(expected, funcNext) {
let observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Select History in the left pane.
let PO = organizer.PlacesOrganizer;
PO.selectLeftPaneQuery('History');
let histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
histContainer.containerOpen = true;
PO._places.selectNode(histContainer.getChild(0));
// Select the first history entry.
let doc = organizer.document;
let tree = PO._content;
let selection = tree.view.selection;
selection.clearSelection();
selection.rangedSelect(0, 0, true);
is(tree.selectedNode.uri, TEST_URI, "The correct history item has been selected");
// Open the context menu
let contextmenu = doc.getElementById("placesContext");
contextmenu.addEventListener("popupshown", function() {
contextmenu.removeEventListener("popupshown", arguments.callee, false);
let forgetThisSite = doc.getElementById("placesContext_deleteHost");
is(forgetThisSite.hidden, !expected,
"The Forget This Site menu item should " + (expected ? "not " : "") + "be hidden");
let forgetThisSiteCmd = doc.getElementById("placesCmd_deleteDataHost");
if (forgetThisSiteCmd.disabled, !expected,
"The Forget This Site command should " + (expected ? "not " : "") + "be disabled");
// Close the context menu
contextmenu.hidePopup();
// Close Library window.
organizer.close();
// Proceed
funcNext();
}, false);
let event = document.createEvent("MouseEvents");
event.initMouseEvent("contextmenu", true, true, organizer, 0,
0, 0, 0, 0, false, false, false, false,
0, null);
tree.dispatchEvent(event);
});
function observer(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(observer);
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Select History in the left pane.
let PO = organizer.PlacesOrganizer;
PO.selectLeftPaneQuery('History');
let histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
histContainer.containerOpen = true;
PO._places.selectNode(histContainer.getChild(0));
// Select the first history entry.
let doc = organizer.document;
let tree = PO._content;
let selection = tree.view.selection;
selection.clearSelection();
selection.rangedSelect(0, 0, true);
is(tree.selectedNode.uri, TEST_URI, "The correct history item has been selected");
// Open the context menu
let contextmenu = doc.getElementById("placesContext");
contextmenu.addEventListener("popupshown", function() {
contextmenu.removeEventListener("popupshown", arguments.callee, false);
let forgetThisSite = doc.getElementById("placesContext_deleteHost");
is(forgetThisSite.hidden, !expected,
"The Forget This Site menu item should " + (expected ? "not " : "") + "be hidden");
let forgetThisSiteCmd = doc.getElementById("placesCmd_deleteDataHost");
if (forgetThisSiteCmd.disabled, !expected,
"The Forget This Site command should " + (expected ? "not " : "") + "be disabled");
// Close the context menu
contextmenu.hidePopup();
// Close Library window.
organizer.close();
// Proceed
funcNext();
}, false);
}
}
};
let event = document.createEvent("MouseEvents");
event.initMouseEvent("contextmenu", true, true, organizer, 0,
0, 0, 0, 0, false, false, false, false,
0, null);
tree.dispatchEvent(event);
});
}, false);
}
ww.registerNotification(observer);
ww.openWindow(null,

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

@ -47,9 +47,8 @@ function test() {
waitForExplicitFinish();
function openLocation(url, autofilled, callback) {
let observer = {
observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
function observer(aSubject, aTopic, aData) {
switch (aTopic) {
case "domwindowopened":
let dialog = aSubject.QueryInterface(Ci.nsIDOMWindow);
dialog.addEventListener("load", function () {
@ -76,11 +75,10 @@ function test() {
break;
case "domwindowclosed":
ww.unregisterNotification(this);
ww.unregisterNotification(arguments.callee);
break;
}
}
};
}
ww.registerNotification(observer);
gPrefService.setIntPref("general.open_location.last_window_choice", 0);

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

@ -44,57 +44,56 @@ let pb = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
let _obs = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let observerNotified = 0, firstUnloadFired = 0, secondUnloadFired = 0;
let observerNotified = 0, firstUnloadFired = 0, secondUnloadFired = 0;
let pbObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic == "private-browsing") {
switch(aData) {
case "enter":
observerNotified++;
is(observerNotified, 1, "This should be the first notification");
is(firstUnloadFired, 1, "The first unload event should have been processed by now");
break;
case "exit":
_obs.removeObserver(this, "private-browsing");
observerNotified++;
is(observerNotified, 2, "This should be the second notification");
is(secondUnloadFired, 1, "The second unload event should have been processed by now");
break;
}
}
function pbObserver(aSubject, aTopic, aData) {
if (aTopic != "private-browsing")
return;
switch (aData) {
case "enter":
observerNotified++;
is(observerNotified, 1, "This should be the first notification");
is(firstUnloadFired, 1, "The first unload event should have been processed by now");
break;
case "exit":
_obs.removeObserver(pbObserver, "private-browsing");
observerNotified++;
is(observerNotified, 2, "This should be the second notification");
is(secondUnloadFired, 1, "The second unload event should have been processed by now");
break;
}
}
function test() {
waitForExplicitFinish();
_obs.addObserver(pbObserver, "private-browsing", false);
is(gBrowser.tabContainer.childNodes.length, 1, "There should only be one tab");
let testTab = gBrowser.addTab();
gBrowser.selectedTab = testTab;
testTab.linkedBrowser.addEventListener("unload", (function() {
testTab.linkedBrowser.addEventListener("unload", function () {
testTab.linkedBrowser.removeEventListener("unload", arguments.callee, true);
firstUnloadFired++;
is(observerNotified, 0, "The notification shouldn't have been sent yet");
}), true);
}, true);
pb.privateBrowsingEnabled = true;
let testTab = gBrowser.addTab();
gBrowser.selectedTab = testTab;
testTab.linkedBrowser.addEventListener("unload", (function() {
testTab.linkedBrowser.addEventListener("unload", function () {
testTab.linkedBrowser.removeEventListener("unload", arguments.callee, true);
secondUnloadFired++;
is(observerNotified, 1, "The notification shouldn't have been sent yet");
cookieManager.add("example.com", "test/", "PB", "1", false, false, false, 1000000000000);
}), true);
}, true);
pb.privateBrowsingEnabled = false;
gBrowser.tabContainer.lastChild.linkedBrowser.addEventListener("unload", (function() {
gBrowser.tabContainer.lastChild.linkedBrowser.addEventListener("unload", function () {
gBrowser.tabContainer.lastChild.linkedBrowser.removeEventListener("unload", arguments.callee, true);
let count = cookieManager.countCookiesFromHost("example.com");
is(count, 0, "There shouldn't be any cookies once pb mode has exited");
cookieManager.QueryInterface(Ci.nsICookieManager);
cookieManager.remove("example.com", "PB", "test/", false);
}), true);
}, true);
gBrowser.removeCurrentTab();
finish();
}

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

@ -43,13 +43,11 @@ function test() {
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
let pb = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
let observer = {
observe: function (aSubject, aTopic, aData) {
if (aTopic == "private-browsing")
this.data = aData;
},
data: null
};
let observerData;
function observer(aSubject, aTopic, aData) {
if (aTopic == "private-browsing")
observerData = aData;
}
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.addObserver(observer, "private-browsing", false);
@ -68,13 +66,13 @@ function test() {
is(pb.privateBrowsingEnabled, true, "The private browsing mode should be started");
is(gPrivateBrowsingUI.privateBrowsingEnabled, true, "gPrivateBrowsingUI should expose the correct private browsing status");
// check to see if the Private Browsing mode was activated successfully
is(observer.data, "enter", "Private Browsing mode was activated using the gPrivateBrowsingUI object");
is(observerData, "enter", "Private Browsing mode was activated using the gPrivateBrowsingUI object");
is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("stoplabel"), "The Private Browsing menu item should read \"Stop Private Browsing\"");
gPrivateBrowsingUI.toggleMode()
is(pb.privateBrowsingEnabled, false, "The private browsing mode should not be started");
is(gPrivateBrowsingUI.privateBrowsingEnabled, false, "gPrivateBrowsingUI should expose the correct private browsing status");
// check to see if the Private Browsing mode was deactivated successfully
is(observer.data, "exit", "Private Browsing mode was deactivated using the gPrivateBrowsingUI object");
is(observerData, "exit", "Private Browsing mode was deactivated using the gPrivateBrowsingUI object");
is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("startlabel"), "The Private Browsing menu item should read \"Start Private Browsing\"");
// now, test using the <command> object
@ -83,12 +81,12 @@ function test() {
var func = new Function("", cmd.getAttribute("oncommand"));
func.call(cmd);
// check to see if the Private Browsing mode was activated successfully
is(observer.data, "enter", "Private Browsing mode was activated using the command object");
is(observerData, "enter", "Private Browsing mode was activated using the command object");
// check to see that the window title has been changed correctly
isnot(document.title, originalTitle, "Private browsing mode has correctly changed the title");
func.call(cmd);
// check to see if the Private Browsing mode was deactivated successfully
is(observer.data, "exit", "Private Browsing mode was deactivated using the command object");
is(observerData, "exit", "Private Browsing mode was deactivated using the command object");
// check to see that the window title has been restored correctly
is(document.title, originalTitle, "Private browsing mode has correctly restored the title");

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

@ -52,26 +52,25 @@ function test() {
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
let observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
ww.unregisterNotification(this);
function observer(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
win.addEventListener("load", function() {
win.removeEventListener("load", arguments.callee, false);
ww.unregisterNotification(observer);
let browser = win.gBrowser;
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
// view source window is loaded, proceed with the rest of the test
step1();
}, true);
}, false);
}
}
};
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
win.addEventListener("load", function () {
win.removeEventListener("load", arguments.callee, false);
let browser = win.gBrowser;
browser.addEventListener("load", function () {
browser.removeEventListener("load", arguments.callee, true);
// view source window is loaded, proceed with the rest of the test
step1();
}, true);
}, false);
}
ww.registerNotification(observer);
openViewSource();
@ -82,18 +81,16 @@ function test() {
}
function step1() {
observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed") {
ok(true, "Entering the private browsing mode should close the view source window");
ww.unregisterNotification(observer);
function observer(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed") {
ok(true, "Entering the private browsing mode should close the view source window");
ww.unregisterNotification(observer);
step2();
}
else if (aTopic == "domwindowopened")
ok(false, "Entering the private browsing mode should not open any view source window");
step2();
}
};
else if (aTopic == "domwindowopened")
ok(false, "Entering the private browsing mode should not open any view source window");
}
ww.registerNotification(observer);
gBrowser.addTabsProgressListener({
@ -123,26 +120,25 @@ function test() {
}
function step4() {
observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
ww.unregisterNotification(this);
function observer(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
win.addEventListener("load", function() {
win.removeEventListener("load", arguments.callee, false);
ww.unregisterNotification(observer);
let browser = win.gBrowser;
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
// view source window inside private browsing mode opened
step5();
}, true);
}, false);
}
}
};
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
win.addEventListener("load", function () {
win.removeEventListener("load", arguments.callee, false);
let browser = win.gBrowser;
browser.addEventListener("load", function () {
browser.removeEventListener("load", arguments.callee, true);
// view source window inside private browsing mode opened
step5();
}, true);
}, false);
}
ww.registerNotification(observer);
openViewSource();
@ -151,38 +147,36 @@ function test() {
function step5() {
let events = 0;
observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed") {
ok(true, "Leaving the private browsing mode should close the existing view source window");
if (++events == 2)
ww.unregisterNotification(observer);
}
else if (aTopic == "domwindowopened") {
ok(true, "Leaving the private browsing mode should restore the previous view source window");
if (++events == 2)
ww.unregisterNotification(observer);
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
win.addEventListener("load", function() {
win.removeEventListener("load", arguments.callee, false);
let browser = win.gBrowser;
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
is(win.content.location.href, "view-source:about:",
"The correct view source window should be restored");
// cleanup
win.close();
gBrowser.removeCurrentTab();
finish();
}, true);
}, false);
}
function observer(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed") {
ok(true, "Leaving the private browsing mode should close the existing view source window");
if (++events == 2)
ww.unregisterNotification(observer);
}
};
else if (aTopic == "domwindowopened") {
ok(true, "Leaving the private browsing mode should restore the previous view source window");
if (++events == 2)
ww.unregisterNotification(observer);
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
win.addEventListener("load", function () {
win.removeEventListener("load", arguments.callee, false);
let browser = win.gBrowser;
browser.addEventListener("load", function () {
browser.removeEventListener("load", arguments.callee, true);
is(win.content.location.href, "view-source:about:",
"The correct view source window should be restored");
// cleanup
win.close();
gBrowser.removeCurrentTab();
finish();
}, true);
}, false);
}
}
ww.registerNotification(observer);
// exit private browsing mode

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

@ -109,7 +109,7 @@
function initPage()
{
// Handoff to the appropriate initializer, based on error code
switch(getErrorCode()) {
switch (getErrorCode()) {
case "malwareBlocked" :
initPage_malware();
break;

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

@ -38,21 +38,19 @@ var gSS = Cc["@mozilla.org/browser/search-service;1"].
var gObs = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
var observers = {
observe: function(aSubject, aTopic, aData) {
switch (aData) {
case "engine-added":
test2();
break;
case "engine-current":
test3();
break;
case "engine-removed":
test4();
break;
}
function observers(aSubject, aTopic, aData) {
switch (aData) {
case "engine-added":
test2();
break;
case "engine-current":
test3();
break;
case "engine-removed":
test4();
break;
}
};
}
function test() {
waitForExplicitFinish();

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

@ -13,26 +13,24 @@ function test() {
var ss = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
var observer = {
observe: function(aSub, aTopic, aData) {
switch (aData) {
case "engine-added":
var engine = ss.getEngineByName("Bug 426329");
ok(engine, "Engine was added.");
//XXX Bug 493051
//ss.currentEngine = engine;
break;
case "engine-current":
ok(ss.currentEngine.name == "Bug 426329", "currentEngine set");
testReturn();
break;
case "engine-removed":
obs.removeObserver(this, "browser-search-engine-modified");
finish();
break;
}
function observer(aSub, aTopic, aData) {
switch (aData) {
case "engine-added":
var engine = ss.getEngineByName("Bug 426329");
ok(engine, "Engine was added.");
//XXX Bug 493051
//ss.currentEngine = engine;
break;
case "engine-current":
ok(ss.currentEngine.name == "Bug 426329", "currentEngine set");
testReturn();
break;
case "engine-removed":
obs.removeObserver(observer, "browser-search-engine-modified");
finish();
break;
}
};
}
obs.addObserver(observer, "browser-search-engine-modified", false);
ss.addEngine("http://localhost:8888/browser/browser/components/search/test/426329.xml",

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