Skip to content

Commit c4eb5af

Browse files
author
Daisuke Akatsuka
committed
Bug 1915774: Use PlacesTestUtils.setFaviconForPage() helper in places test r=places-reviewers,mak
Differential Revision: https://phabricator.services.mozilla.com/D241888
1 parent bfd05ae commit c4eb5af

File tree

7 files changed

+16
-23
lines changed

7 files changed

+16
-23
lines changed

toolkit/components/places/tests/PlacesTestUtils.sys.mjs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,9 @@ export var PlacesTestUtils = Object.freeze({
168168
isRichIcon = false
169169
) {
170170
return lazy.PlacesUtils.favicons.setFaviconForPage(
171-
pageURI instanceof Ci.nsIURI ? pageURI : Services.io.newURI(pageURI),
172-
faviconURI instanceof Ci.nsIURI
173-
? faviconURI
174-
: Services.io.newURI(faviconURI),
175-
faviconDataURL instanceof Ci.nsIURI
176-
? faviconDataURL
177-
: Services.io.newURI(faviconDataURL),
171+
lazy.PlacesUtils.toURI(pageURI),
172+
lazy.PlacesUtils.toURI(faviconURI),
173+
lazy.PlacesUtils.toURI(faviconDataURL),
178174
expiration,
179175
isRichIcon
180176
);

toolkit/components/places/tests/bookmarks/test_async_observers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ add_task(async function test_add_icon() {
4141
)
4242
);
4343

44-
PlacesUtils.favicons.setFaviconForPage(
45-
NetUtil.newURI("http://book.ma.rk/"),
44+
PlacesTestUtils.setFaviconForPage(
45+
"http://book.ma.rk/",
4646
SMALLPNG_DATA_URI,
4747
SMALLPNG_DATA_URI
4848
);

toolkit/components/places/tests/chrome/test_cached_favicon.xhtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ function test()
104104
// icon with a page explicitly in order for it to be visible through
105105
// the protocol.
106106
info("Replace favicon data");
107-
PlacesUtils.favicons.setFaviconForPage(
108-
Services.io.newURI("https://example.com/favicon_annotations"),
109-
Services.io.newURI(tests[1].url),
110-
Services.io.newURI(tests[1].expectedIcon),
107+
PlacesTestUtils.setFaviconForPage(
108+
"https://example.com/favicon_annotations",
109+
tests[1].url,
110+
tests[1].expectedIcon,
111111
(Date.now() + 86400) * 1000,
112112
);
113113

toolkit/components/places/tests/favicons/test_expire_migrated_icons.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ add_setup(() => {
1616
add_task(async function test_storing_a_normal_16x16_icon() {
1717
const PAGE_URL = Services.io.newURI("http://places.test");
1818
await PlacesTestUtils.addVisits(PAGE_URL);
19-
await PlacesUtils.favicons.setFaviconForPage(
19+
await PlacesTestUtils.setFaviconForPage(
2020
PAGE_URL,
2121
SMALLPNG_DATA_URI,
2222
SMALLPNG_DATA_URI
@@ -36,7 +36,7 @@ add_task(async function test_storing_a_normal_16x16_icon() {
3636
);
3737

3838
info("Refresh favicon");
39-
await PlacesUtils.favicons.setFaviconForPage(
39+
await PlacesTestUtils.setFaviconForPage(
4040
PAGE_URL,
4141
SMALLPNG_DATA_URI,
4242
SMALLPNG_DATA_URI

toolkit/components/places/tests/favicons/test_query_result_favicon_changed_on_child.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ add_task(async function test_query_result_favicon_changed_on_child() {
3535
// favicon for the page must have data associated with it in order for
3636
// the icon changed notifications to be sent, so we use a valid image
3737
// data URI.
38-
PlacesUtils.favicons.setFaviconForPage(
38+
PlacesTestUtils.setFaviconForPage(
3939
PAGE_URI,
4040
SMALLPNG_DATA_URI,
4141
SMALLPNG_DATA_URI
@@ -107,7 +107,7 @@ add_task(
107107
);
108108

109109
let promise = promiseFaviconChanged(PAGE_URI2, SMALLPNG_DATA_URI);
110-
PlacesUtils.favicons.setFaviconForPage(
110+
PlacesTestUtils.setFaviconForPage(
111111
PAGE_URI2,
112112
SMALLPNG_DATA_URI,
113113
SMALLPNG_DATA_URI

toolkit/components/places/tests/maintenance/test_preventive_maintenance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,7 @@ tests.push({
26102610
});
26112611

26122612
PlacesUtils.tagging.tagURI(this._uri1, ["testtag"]);
2613-
await PlacesUtils.favicons.setFaviconForPage(
2613+
await PlacesTestUtils.setFaviconForPage(
26142614
this._uri2,
26152615
SMALLPNG_DATA_URI,
26162616
SMALLPNG_DATA_URI

widget/tests/unit/test_JumpListBuilder_obtainAndCacheFaviconAsync.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ https://creativecommons.org/publicdomain/zero/1.0/ */
66
const { AppConstants } = ChromeUtils.importESModule(
77
"resource://gre/modules/AppConstants.sys.mjs"
88
);
9-
const { PlacesUtils } = ChromeUtils.importESModule(
10-
"resource://gre/modules/PlacesUtils.sys.mjs"
11-
);
129
const { PlacesTestUtils } = ChromeUtils.importESModule(
1310
"resource://testing-common/PlacesTestUtils.sys.mjs"
1411
);
@@ -68,10 +65,10 @@ add_setup(async () => {
6865
reader.readAsDataURL(blob);
6966
});
7067

71-
await PlacesUtils.favicons.setFaviconForPage(
68+
await PlacesTestUtils.setFaviconForPage(
7269
TEST_PAGE_URI,
7370
TEST_FAVICON_URI,
74-
Services.io.newURI(dataURL)
71+
dataURL
7572
);
7673
});
7774

0 commit comments

Comments
 (0)