diff options
Diffstat (limited to 'toolkit/components/places/tests/unit/test_PlacesUtils_unwrapNodes_place.js')
-rw-r--r-- | toolkit/components/places/tests/unit/test_PlacesUtils_unwrapNodes_place.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/unit/test_PlacesUtils_unwrapNodes_place.js b/toolkit/components/places/tests/unit/test_PlacesUtils_unwrapNodes_place.js new file mode 100644 index 0000000000..8944dc22f4 --- /dev/null +++ b/toolkit/components/places/tests/unit/test_PlacesUtils_unwrapNodes_place.js @@ -0,0 +1,34 @@ +/* Any copyright is dedicated to the Public Domain. + * https://creativecommons.org/publicdomain/zero/1.0/ */ + +// Tests that unwrapNodes properly filters out place: uris from text flavors. + +add_task(function () { + let tests = [ + // Single url. + ["place:type=0&sort=1:", PlacesUtils.TYPE_X_MOZ_URL], + // Multiple urls. + [ + "place:type=0&sort=1:\nfirst\nplace:type=0&sort=1\nsecond", + PlacesUtils.TYPE_X_MOZ_URL, + ], + // Url == title. + ["place:type=0&sort=1:\nplace:type=0&sort=1", PlacesUtils.TYPE_X_MOZ_URL], + // Malformed. + [ + "place:type=0&sort=1:\nplace:type=0&sort=1\nmalformed", + PlacesUtils.TYPE_X_MOZ_URL, + ], + // Single url. + ["place:type=0&sort=1:", PlacesUtils.TYPE_PLAINTEXT], + // Multiple urls. + ["place:type=0&sort=1:\nplace:type=0&sort=1", PlacesUtils.TYPE_PLAINTEXT], + ]; + for (let [blob, type] of tests) { + Assert.deepEqual( + PlacesUtils.unwrapNodes(blob, type), + [], + "No valid entries should be found" + ); + } +}); |