summaryrefslogtreecommitdiffstats
path: root/browser/components/places/tests/chrome/test_bug485100-change-case-loses-tag.xul
blob: afad950cb420e3f4dcfe33bdbe39bfd394819a5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?xml version="1.0"?>

<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                 type="text/css"?>

<?xml-stylesheet href="chrome://browser/skin/places/editBookmarkOverlay.css"?>
<?xml-stylesheet href="chrome://browser/content/places/places.css"?>
<?xml-stylesheet href="chrome://browser/skin/places/places.css"?>

<?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
<?xul-overlay href="chrome://browser/content/places/editBookmarkOverlay.xul"?>

<!DOCTYPE window [
  <!ENTITY % editBookmarkOverlayDTD SYSTEM "chrome://browser/locale/places/editBookmarkOverlay.dtd">
  %editBookmarkOverlayDTD;
]>

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        title="485100: Exchanging a letter of a tag name with its big/small equivalent removes tag from bookmark"
        onload="runTest();">

  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
  <script type="application/javascript"
          src="chrome://browser/content/places/editBookmarkOverlay.js"/>

  <body xmlns="http://www.w3.org/1999/xhtml" />

  <vbox id="editBookmarkPanelContent"/>

  <script type="application/javascript">
  <![CDATA[

    function runTest() {
      SimpleTest.waitForExplicitFinish();

      Task.spawn(function* () {
        let testTag = "foo";
        let testTagUpper = "Foo";
        let testURI = Services.io.newURI("http://www.example.com/", null, null);

        // Add a bookmark.
        let bm = yield PlacesUtils.bookmarks.insert({
          parentGuid: PlacesUtils.bookmarks.toolbarGuid,
          index: PlacesUtils.bookmarks.DEFAULT_INDEX,
          type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
          title: "mozilla",
          url: testURI
        });

        // Init panel
        ok(gEditItemOverlay, "gEditItemOverlay is in context");
        let node = yield PlacesUIUtils.promiseNodeLikeFromFetchInfo(bm);
        gEditItemOverlay.initPanel({ node });

        // add a tag
        document.getElementById("editBMPanel_tagsField").value = testTag;
        gEditItemOverlay.onTagsFieldChange();

        // test that the tag has been added in the backend
        is(PlacesUtils.tagging.getTagsForURI(testURI)[0], testTag, "tags match");

        // change the tag
        document.getElementById("editBMPanel_tagsField").value = testTagUpper;
        gEditItemOverlay.onTagsFieldChange();

        // test that the tag has been added in the backend
        is(PlacesUtils.tagging.getTagsForURI(testURI)[0], testTagUpper, "tags match");

        // Cleanup.
        PlacesUtils.tagging.untagURI(testURI, [testTag]);
        yield PlacesUtils.bookmarks.remove(bm.guid);
      }).then(() => SimpleTest.finish());
    }
  ]]>
  </script>

</window>