michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const charset = "UTF-8"; michael@0: const CHARSET_ANNO = "URIProperties/characterSet"; michael@0: michael@0: const TEST_URI = uri("http://foo.com"); michael@0: const TEST_BOOKMARKED_URI = uri("http://bar.com"); michael@0: michael@0: function run_test() michael@0: { michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_task(function test_execute() michael@0: { michael@0: // add pages to history michael@0: yield promiseAddVisits(TEST_URI); michael@0: yield promiseAddVisits(TEST_BOOKMARKED_URI); michael@0: michael@0: // create bookmarks on TEST_BOOKMARKED_URI michael@0: var bm1 = PlacesUtils.bookmarks.insertBookmark( michael@0: PlacesUtils.unfiledBookmarksFolderId, michael@0: TEST_BOOKMARKED_URI, PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: TEST_BOOKMARKED_URI.spec); michael@0: var bm2 = PlacesUtils.bookmarks.insertBookmark( michael@0: PlacesUtils.toolbarFolderId, michael@0: TEST_BOOKMARKED_URI, PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: TEST_BOOKMARKED_URI.spec); michael@0: michael@0: // set charset on not-bookmarked page michael@0: yield PlacesUtils.setCharsetForURI(TEST_URI, charset); michael@0: // set charset on bookmarked page michael@0: yield PlacesUtils.setCharsetForURI(TEST_BOOKMARKED_URI, charset); michael@0: michael@0: // check that we have created a page annotation michael@0: do_check_eq(PlacesUtils.annotations.getPageAnnotation(TEST_URI, CHARSET_ANNO), charset); michael@0: michael@0: // get charset from not-bookmarked page michael@0: do_check_eq((yield PlacesUtils.getCharsetForURI(TEST_URI)), charset); michael@0: michael@0: // get charset from bookmarked page michael@0: do_check_eq((yield PlacesUtils.getCharsetForURI(TEST_BOOKMARKED_URI)), charset); michael@0: michael@0: yield promiseClearHistory(); michael@0: michael@0: // ensure that charset has gone for not-bookmarked page michael@0: do_check_neq((yield PlacesUtils.getCharsetForURI(TEST_URI)), charset); michael@0: michael@0: // check that page annotation has been removed michael@0: try { michael@0: PlacesUtils.annotations.getPageAnnotation(TEST_URI, CHARSET_ANNO); michael@0: do_throw("Charset page annotation has not been removed correctly"); michael@0: } catch (e) {} michael@0: michael@0: // ensure that charset still exists for bookmarked page michael@0: do_check_eq((yield PlacesUtils.getCharsetForURI(TEST_BOOKMARKED_URI)), charset); michael@0: michael@0: // remove charset from bookmark and check that has gone michael@0: yield PlacesUtils.setCharsetForURI(TEST_BOOKMARKED_URI, ""); michael@0: do_check_neq((yield PlacesUtils.getCharsetForURI(TEST_BOOKMARKED_URI)), charset); michael@0: });