-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interfaces/content-index.idl and test (#24211)
Closes #24203
- Loading branch information
1 parent
57dde86
commit 7ef4aae
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// META: global=window,worker | ||
// META: script=/resources/WebIDLParser.js | ||
// META: script=/resources/idlharness.js | ||
// META: script=/service-workers/service-worker/resources/test-helpers.sub.js | ||
|
||
'use strict'; | ||
|
||
// https://wicg.github.io/content-index/spec/ | ||
|
||
idl_test( | ||
['content-index'], | ||
['service-workers', 'html', 'dom'], | ||
async (idl_array, t) => { | ||
// TODO: Handle other worker types. | ||
if (self.GLOBAL.isWindow()) { | ||
idl_array.add_objects({ | ||
ServiceWorkerRegistration: ['registration'], | ||
ContentIndex: ['registration.index'], | ||
}); | ||
self.registration = await service_worker_unregister_and_register( | ||
t, 'resources/sw.js', 'resources/does/not/exist'); | ||
t.add_cleanup(() => registration.unregister()); | ||
} | ||
else if (self.ServiceWorkerGlobalScope) { | ||
idl_array.add_objects({ | ||
ServiceWorkerGlobalScope: ['self'], | ||
ServiceWorkerRegistration: ['registration'], | ||
ContentIndex: ['registration.index'], | ||
ContentIndexEvent: ['new ContentIndexEvent("type", {id: "foo"})'], | ||
}); | ||
} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// GENERATED CONTENT - DO NOT EDIT | ||
// Content was automatically extracted by Reffy into reffy-reports | ||
// (https://github.com/tidoust/reffy-reports) | ||
// Source: Content Index (https://wicg.github.io/content-index/spec/) | ||
|
||
partial interface ServiceWorkerGlobalScope { | ||
attribute EventHandler oncontentdelete; | ||
}; | ||
|
||
partial interface ServiceWorkerRegistration { | ||
[SameObject] readonly attribute ContentIndex index; | ||
}; | ||
|
||
enum ContentCategory { | ||
"", | ||
"homepage", | ||
"article", | ||
"video", | ||
"audio", | ||
}; | ||
|
||
dictionary ContentDescription { | ||
required DOMString id; | ||
required DOMString title; | ||
required DOMString description; | ||
ContentCategory category = ""; | ||
sequence<ImageResource> icons = []; | ||
required USVString url; | ||
}; | ||
|
||
[Exposed=(Window,Worker)] | ||
interface ContentIndex { | ||
Promise<void> add(ContentDescription description); | ||
Promise<void> delete(DOMString id); | ||
Promise<sequence<ContentDescription>> getAll(); | ||
}; | ||
|
||
dictionary ContentIndexEventInit : ExtendableEventInit { | ||
required DOMString id; | ||
}; | ||
|
||
[Constructor(DOMString type, ContentIndexEventInit init), Exposed=ServiceWorker] | ||
interface ContentIndexEvent : ExtendableEvent { | ||
readonly attribute DOMString id; | ||
}; |