Bug 372750. Demo test for asynchronous places tests. r=mano
git-svn-id: svn://10.0.0.236/trunk@221407 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
0b6f189411
commit
f7ca9b2ac1
@ -51,4 +51,8 @@ ifdef MOZ_PLACES_BOOKMARKS
|
||||
XPCSHELL_TESTS += bookmarks
|
||||
endif
|
||||
|
||||
ifdef MOZ_MOCHITEST
|
||||
DIRS = chrome
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
60
mozilla/browser/components/places/tests/chrome/Makefile.in
Normal file
60
mozilla/browser/components/places/tests/chrome/Makefile.in
Normal file
@ -0,0 +1,60 @@
|
||||
#
|
||||
# ***** 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.org.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = browser/components/places/tests/chrome
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_HTTP_FILES = \
|
||||
sample_feed.atom \
|
||||
$(NULL)
|
||||
|
||||
_CHROME_FILES = \
|
||||
test_add_livemark.xul \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_HTTP_FILES)
|
||||
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
||||
|
||||
libs:: $(_CHROME_FILES)
|
||||
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
|
||||
<title>Example Feed</title>
|
||||
<link href="http://example.org/"/>
|
||||
<updated>2003-12-13T18:30:02Z</updated>
|
||||
|
||||
<author>
|
||||
<name>John Doe</name>
|
||||
</author>
|
||||
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
||||
|
||||
<entry>
|
||||
|
||||
<title>Atom-Powered Robots Run Amok</title>
|
||||
<link href="http://example.org/2003/12/13/atom03"/>
|
||||
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
||||
<updated>2003-12-13T18:30:02Z</updated>
|
||||
|
||||
<summary>Some text.</summary>
|
||||
</entry>
|
||||
|
||||
</feed>
|
||||
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
<window title="Add Livemarks"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<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>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" />
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
// Test the asynchronous downloading of a feed to the livemarks service
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
var iosvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
function uri(spec) {
|
||||
return iosvc.newURI(spec, null, null);
|
||||
}
|
||||
|
||||
var lmsvc = Cc["@mozilla.org/browser/livemark-service;2"].
|
||||
getService(Ci.nsILivemarkService);
|
||||
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
|
||||
getService(Ci.nsINavBookmarksService);
|
||||
var gLivemarkId;
|
||||
|
||||
var navObserver =
|
||||
{
|
||||
onBeginUpdateBatch: function(){},
|
||||
onEndUpdateBatch: function(){},
|
||||
onItemAdded: function(bookmarkId, bookmark, folder, index) {
|
||||
if (bookmark.spec == "http://example.org/2003/12/13/atom03") {
|
||||
is(folder, gLivemarkId, "Livemark added to correct folder");
|
||||
bmsvc.removeObserver(navObserver);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
},
|
||||
onItemRemoved: function(bookmarkId, bookmark, folder, index){},
|
||||
onItemChanged: function(bookmarkId, bookmark, property, value){},
|
||||
onItemVisited: function(bookmarkId, bookmark, aVisitID, time){},
|
||||
onFolderAdded: function(folder, parent, index){},
|
||||
onFolderRemoved: function(folder, parent, index){},
|
||||
onFolderMoved: function(folder, oldParent, oldIndex, newParent, newIndex){},
|
||||
onFolderChanged: function(folder, property){},
|
||||
onSeparatorAdded: function(parent, index){},
|
||||
onSeparatorRemoved: function(parent, index){}
|
||||
};
|
||||
|
||||
var root = bmsvc.bookmarksRoot;
|
||||
const FEEDSPEC = "http://localhost:8888/tests/browser/components/places/tests/chrome/sample_feed.atom";
|
||||
|
||||
gLivemarkId = lmsvc.createLivemarkFolderOnly(bmsvc, root, "foo",
|
||||
uri("http:/localhost/"),
|
||||
uri(FEEDSPEC), -1);
|
||||
bmsvc.addObserver(navObserver, false);
|
||||
lmsvc.reloadLivemarkFolder(gLivemarkId);
|
||||
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
</window>
|
||||
Loading…
x
Reference in New Issue
Block a user