Skip to content

Commit

Permalink
Add interfaces/content-index.idl and test (#24211)
Browse files Browse the repository at this point in the history
Closes #24203
  • Loading branch information
stephenmcgruer authored Jun 24, 2020
1 parent 57dde86 commit 7ef4aae
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
33 changes: 33 additions & 0 deletions content-index/idlharness.https.any.js
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"})'],
});
}
}
);
45 changes: 45 additions & 0 deletions interfaces/content-index.idl
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;
};

0 comments on commit 7ef4aae

Please sign in to comment.