mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-05-03 14:27:00 +02:00
Expand permissions test cases
Include support for host permissions and data permissions.
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Permissions Example (MV3)</title>
|
||||
<link rel="stylesheet" href="bootstrap.min.css"/>
|
||||
<link rel="stylesheet" href="page.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h3>Permissions Example</h3>
|
||||
<p><strong>Current grants</strong></p>
|
||||
<table id="grants">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>permissions</th>
|
||||
<td><span id="permissions"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>origins</th>
|
||||
<td><span id="host-permissions"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>data_collection</th>
|
||||
<td><span id="data-permissions"></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><br>
|
||||
<p style="display: none" id="result"></p>
|
||||
|
||||
<h4>Permissions</h4>
|
||||
<ul>
|
||||
<li>The <code>tabs</code> permission has been <b>granted</b> on install.</li>
|
||||
<li>The <code>history</code> permission is an optional permission that can be
|
||||
<a href="#" class="permission" data-permission-type="permissions" data-permission="history" data-action="grant">granted</a> or
|
||||
<a href="#" class="permission" data-permission-type="permissions" data-permission="history" data-action="revoke">revoked</a>.
|
||||
</li>
|
||||
<li>The <code>cookies</code> permission cannot be
|
||||
<a href="#" class="permission" data-permission-type="permissions" data-permission="cookies" data-action="grant">granted</a>,
|
||||
because it was not included in the <code>optional_permissions</code> manifest key.
|
||||
</li>
|
||||
<li>The <code>foo</code> permission cannot be
|
||||
<a href="#" class="permission" data-permission-type="permissions" data-permission="foo" data-action="grant">granted</a>,
|
||||
because it is not a valid permission name.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Host permissions</h4>
|
||||
<ul>
|
||||
<li>The <code>*://*.example.com/*</code> host permission is required, so it was <b>granted</b> on install. It can be
|
||||
<a href="#" class="permission" data-permission-type="origins" data-permission="*://*.example.com/*" data-action="grant">granted</a> or
|
||||
<a href="#" class="permission" data-permission-type="origins" data-permission="*://*.example.com/*" data-action="revoke">revoked</a> after installation.
|
||||
</li>
|
||||
<li>The <code>*://*.example.org/*</code> host permission is optional and can be
|
||||
<a href="#" class="permission" data-permission-type="origins" data-permission="*://*.example.org/*" data-action="grant">granted</a> or
|
||||
<a href="#" class="permission" data-permission-type="origins" data-permission="*://*.example.org/*" data-action="revoke">revoked</a>.
|
||||
</li>
|
||||
<li>The <code>https://www.example.org/*</code> host permission can be
|
||||
<a href="#" class="permission" data-permission-type="origins" data-permission="https://www.example.org/*" data-action="grant">granted</a> or
|
||||
<a href="#" class="permission" data-permission-type="origins" data-permission="https://www.example.org/*" data-action="revoke">revoked</a>,
|
||||
because it is matched by the <code>*://*.example.org/*</code> optional host permission,
|
||||
</li>
|
||||
<li>The <code>https://mozilla.org/*</code> host permission cannot be
|
||||
<a href="#" class="permission" data-permission-type="origins" data-permission="https://mozilla.org/*" data-action="grant">granted</a>,
|
||||
because it (or a broader pattern) was not declared in the manifest.
|
||||
</li>
|
||||
<li>The <code>bar</code> host permission cannot be
|
||||
<a href="#" class="permission" data-permission-type="origins" data-permission="bar" data-action="grant">granted</a>,
|
||||
because it is not a valid host permission.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Data permissions</h4>
|
||||
<ul>
|
||||
<li>The <code>browsingActivity</code> data permission is required, so it was <b>granted</b> on install. It cannot be
|
||||
<a href="#" class="permission" data-permission-type="data_collection" data-permission="browsingActivity" data-action="revoke">revoked</a> (the call succeeds, but the grant does not change).
|
||||
</li>
|
||||
<li>The <code>technicalAndInteraction</code> data permission is special. It must be declared as optional, but it is granted by default when installed normally (not as a temporary add-on). It can be
|
||||
<a href="#" class="permission" data-permission-type="data_collection" data-permission="technicalAndInteraction" data-action="grant">granted</a> or
|
||||
<a href="#" class="permission" data-permission-type="data_collection" data-permission="technicalAndInteraction" data-action="revoke">revoked</a> after installation.
|
||||
</li>
|
||||
<li>The <code>locationInfo</code> data permission is optional, so it can be
|
||||
<a href="#" class="permission" data-permission-type="data_collection" data-permission="locationInfo" data-action="grant">granted</a> or
|
||||
<a href="#" class="permission" data-permission-type="data_collection" data-permission="locationInfo" data-action="revoke">revoked</a> after installation.
|
||||
</li>
|
||||
<li>The <code>baz</code> data permission cannot be
|
||||
<a href="#" class="permission" data-permission-type="data_collection" data-permission="baz" data-action="grant">granted</a>,
|
||||
because it is not a valid data permission name.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<script src="page.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user