gpu: fix CopyTextureCHROMIUM for GL_ARB_texture_rectangle
[chromium-blink-merge.git] / chrome / test / data / push_messaging / test.html
blob6ee954e112e7714f579e0418b610f92aaa2b822f
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Push API Test</title>
5 <link rel="manifest" href="manifest.json">
6 <script>
7 var pushData = new FutureData();
9 // Sends data back to the test. This must be in response to an earlier
10 // request, but it's ok to respond asynchronously. The request blocks until
11 // the response is sent.
12 function sendResultToTest(result) {
13 console.log('sendResultToTest: ' + result);
14 if (window.domAutomationController) {
15 domAutomationController.send('' + result);
19 function sendErrorToTest(error) {
20 sendResultToTest(error.name + ' - ' + error.message);
23 // A container for a single piece of data. The data does not have to be
24 // available yet when the getter is called, as all responses to the test are
25 // asynchronous.
26 function FutureData() {
27 this.data = null;
28 this.waiting = false;
31 // Sends the data to the test if it is available. Otherwise sets the
32 // |waiting| flag.
33 FutureData.prototype.get = function() {
34 if (this.data) {
35 sendResultToTest(this.data);
36 } else {
37 this.waiting = true;
41 // Sets a new data value. If the |waiting| flag is on, it is turned off and
42 // the data is sent to the test.
43 FutureData.prototype.set = function(data) {
44 this.data = data;
45 if (this.waiting) {
46 sendResultToTest(data);
47 this.waiting = false;
51 function requestNotificationPermission() {
52 Notification.requestPermission(function(permission) {
53 sendResultToTest('permission status - ' + permission);
54 });
57 function registerServiceWorker() {
58 navigator.serviceWorker.register('service_worker.js', {scope: './'}).then(
59 function(swRegistration) {
60 sendResultToTest('ok - service worker registered');
61 }, sendErrorToTest);
64 function removeManifest() {
65 var element = document.querySelector('link[rel="manifest"]');
66 if (element) {
67 element.parentNode.removeChild(element);
68 sendResultToTest('manifest removed');
69 } else
70 sendResultToTest('unable to find manifest element');
73 function registerPush() {
74 navigator.serviceWorker.ready.then(function() {
75 navigator.push.register().then(function(pushRegistration) {
76 sendResultToTest(pushRegistration.pushEndpoint + ' - ' +
77 pushRegistration.pushRegistrationId);
78 }, sendErrorToTest);
79 }, sendErrorToTest);
82 function isControlled() {
83 if (navigator.serviceWorker.controller) {
84 sendResultToTest('true - is controlled');
85 } else {
86 sendResultToTest('false - is not controlled');
90 addEventListener('message', function(event) {
91 var message = JSON.parse(event.data);
92 if (message.type == 'push') {
93 pushData.set(message.data);
95 }, false);
96 </script>
97 </head>
98 <body>
99 <h1>Push API Test</h1>
100 </body>
101 </html>