forked from web-platform-tests/wpt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create permissions test suite with IDL tests (web-platform-tests#9301)
- Loading branch information
Showing
3 changed files
with
94 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,53 @@ | ||
// GENERATED CONTENT - DO NOT EDIT | ||
// Content of this file was automatically extracted from the | ||
// "Permissions" spec. | ||
// See: https://w3c.github.io/permissions/ | ||
|
||
dictionary PermissionDescriptor { | ||
required PermissionName name; | ||
}; | ||
|
||
enum PermissionState { | ||
"granted", | ||
"denied", | ||
"prompt", | ||
}; | ||
|
||
[Exposed=(Window,Worker)] | ||
interface PermissionStatus : EventTarget { | ||
readonly attribute PermissionState state; | ||
attribute EventHandler onchange; | ||
}; | ||
|
||
[Exposed=(Window)] | ||
partial interface Navigator { | ||
readonly attribute Permissions permissions; | ||
}; | ||
|
||
[Exposed=(Worker)] | ||
partial interface WorkerNavigator { | ||
readonly attribute Permissions permissions; | ||
}; | ||
|
||
[Exposed=(Window,Worker)] | ||
interface Permissions { | ||
Promise<PermissionStatus> query(object permissionDesc); | ||
}; | ||
|
||
dictionary PushPermissionDescriptor : PermissionDescriptor { | ||
boolean userVisibleOnly = false; | ||
}; | ||
|
||
dictionary MidiPermissionDescriptor : PermissionDescriptor { | ||
boolean sysex = false; | ||
}; | ||
|
||
dictionary DevicePermissionDescriptor : PermissionDescriptor { | ||
DOMString deviceId; | ||
}; | ||
|
||
dictionary PermissionSetParameters { | ||
required PermissionDescriptor descriptor; | ||
required PermissionState state; | ||
boolean oneRealm = false; | ||
}; |
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,3 @@ | ||
@jyasskin | ||
@mounirlamouri | ||
@marcoscaceres |
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,38 @@ | ||
// META: script=/resources/WebIDLParser.js | ||
// META: script=/resources/idlharness.js | ||
|
||
"use strict"; | ||
|
||
if (self.importScripts) { | ||
importScripts("/resources/testharness.js"); | ||
importScripts("/resources/WebIDLParser.js", "/resources/idlharness.js"); | ||
} | ||
|
||
// https://w3c.github.io/permissions/#idl-index | ||
|
||
promise_test(async () => { | ||
|
||
const permissions_idl = await fetch("/interfaces/permissions.idl") | ||
.then(response => response.text()); | ||
const idl_array = new IdlArray(); | ||
|
||
idl_array.add_untested_idls('interface Navigator {};'); | ||
idl_array.add_untested_idls('[Exposed=(Window,Worker)] interface EventTarget {};'); | ||
idl_array.add_untested_idls('interface EventHandler {};'); | ||
idl_array.add_untested_idls('interface WorkerNavigator {};'); | ||
idl_array.add_idls(permissions_idl); | ||
|
||
self.permissionStatus = await navigator.permissions.query({ name: "geolocation" }); | ||
|
||
if (self.GLOBAL.isWorker()) { | ||
idl_array.add_objects({ WorkerNavigator: ['navigator'] }); | ||
} else { | ||
idl_array.add_objects({ Navigator: ['navigator'] }); | ||
} | ||
|
||
idl_array.add_objects({ | ||
Permissions: ['navigator.permissions'], | ||
PermissionStatus: ['permissionStatus'] | ||
}); | ||
idl_array.test(); | ||
}, "Test IDL implementation of Permissions API"); |