Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 const charset = "UTF-8";
8 const CHARSET_ANNO = "URIProperties/characterSet";
10 const TEST_URI = uri("http://foo.com");
11 const TEST_BOOKMARKED_URI = uri("http://bar.com");
13 function run_test()
14 {
15 run_next_test();
16 }
18 add_task(function test_execute()
19 {
20 // add pages to history
21 yield promiseAddVisits(TEST_URI);
22 yield promiseAddVisits(TEST_BOOKMARKED_URI);
24 // create bookmarks on TEST_BOOKMARKED_URI
25 var bm1 = PlacesUtils.bookmarks.insertBookmark(
26 PlacesUtils.unfiledBookmarksFolderId,
27 TEST_BOOKMARKED_URI, PlacesUtils.bookmarks.DEFAULT_INDEX,
28 TEST_BOOKMARKED_URI.spec);
29 var bm2 = PlacesUtils.bookmarks.insertBookmark(
30 PlacesUtils.toolbarFolderId,
31 TEST_BOOKMARKED_URI, PlacesUtils.bookmarks.DEFAULT_INDEX,
32 TEST_BOOKMARKED_URI.spec);
34 // set charset on not-bookmarked page
35 yield PlacesUtils.setCharsetForURI(TEST_URI, charset);
36 // set charset on bookmarked page
37 yield PlacesUtils.setCharsetForURI(TEST_BOOKMARKED_URI, charset);
39 // check that we have created a page annotation
40 do_check_eq(PlacesUtils.annotations.getPageAnnotation(TEST_URI, CHARSET_ANNO), charset);
42 // get charset from not-bookmarked page
43 do_check_eq((yield PlacesUtils.getCharsetForURI(TEST_URI)), charset);
45 // get charset from bookmarked page
46 do_check_eq((yield PlacesUtils.getCharsetForURI(TEST_BOOKMARKED_URI)), charset);
48 yield promiseClearHistory();
50 // ensure that charset has gone for not-bookmarked page
51 do_check_neq((yield PlacesUtils.getCharsetForURI(TEST_URI)), charset);
53 // check that page annotation has been removed
54 try {
55 PlacesUtils.annotations.getPageAnnotation(TEST_URI, CHARSET_ANNO);
56 do_throw("Charset page annotation has not been removed correctly");
57 } catch (e) {}
59 // ensure that charset still exists for bookmarked page
60 do_check_eq((yield PlacesUtils.getCharsetForURI(TEST_BOOKMARKED_URI)), charset);
62 // remove charset from bookmark and check that has gone
63 yield PlacesUtils.setCharsetForURI(TEST_BOOKMARKED_URI, "");
64 do_check_neq((yield PlacesUtils.getCharsetForURI(TEST_BOOKMARKED_URI)), charset);
65 });