| OLD | NEW |
| 1 description("Tests that when a request is made on a Geolocation object, permissi
on is denied and its Frame is disconnected before a callback is made, no callbac
ks are made."); | 1 description("Tests that when a request is made on a Geolocation object, permissi
on is denied and its Frame is disconnected before a callback is made, no callbac
ks are made."); |
| 2 | 2 |
| 3 if (!window.testRunner || !window.internals) | 3 if (!window.testRunner || !window.internals) |
| 4 debug('This test can not run without testRunner or internals'); | 4 debug('This test can not run without testRunner or internals'); |
| 5 | 5 |
| 6 internals.setGeolocationClientMock(document); | |
| 7 | |
| 8 // Prime the Geolocation instance by denying permission. This makes sure that we
execute the | |
| 9 // same code path for both preemptive and non-preemptive permissions policies. | |
| 10 internals.setGeolocationPermission(document, false); | |
| 11 internals.setGeolocationPosition(document, 51.478, -0.166, 100); | |
| 12 | |
| 13 var error; | 6 var error; |
| 14 function onIframeLoaded() { | 7 function onIframeLoaded() { |
| 8 var iframeDocument = iframe.contentWindow.document; |
| 9 internals.setGeolocationClientMock(iframeDocument); |
| 10 |
| 11 // Prime the Geolocation instance by denying permission. This makes sure tha
t we execute the |
| 12 // same code path for both preemptive and non-preemptive permissions policie
s. |
| 13 internals.setGeolocationPermission(iframeDocument, false); |
| 14 internals.setGeolocationPosition(iframeDocument, 51.478, -0.166, 100); |
| 15 |
| 15 iframeGeolocation = iframe.contentWindow.navigator.geolocation; | 16 iframeGeolocation = iframe.contentWindow.navigator.geolocation; |
| 16 iframeGeolocation.getCurrentPosition(function() { | 17 iframeGeolocation.getCurrentPosition(function() { |
| 17 testFailed('Success callback invoked unexpectedly'); | 18 testFailed('Success callback invoked unexpectedly'); |
| 18 finishJSTest(); | 19 finishJSTest(); |
| 19 }, function(e) { | 20 }, function(e) { |
| 20 error = e; | 21 error = e; |
| 21 shouldBe('error.code', 'error.PERMISSION_DENIED'); | 22 shouldBe('error.code', 'error.PERMISSION_DENIED'); |
| 22 shouldBe('error.message', '"User denied Geolocation"'); | 23 shouldBe('error.message', '"User denied Geolocation"'); |
| 23 debug(''); | 24 debug(''); |
| 24 iframe.src = 'data:text/html,This frame should be visible when the test
completes'; | 25 iframe.src = 'data:text/html,This frame should be visible when the test
completes'; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 38 testPassed('No callbacks invoked'); | 39 testPassed('No callbacks invoked'); |
| 39 finishJSTest(); | 40 finishJSTest(); |
| 40 }, 100); | 41 }, 100); |
| 41 } | 42 } |
| 42 | 43 |
| 43 var iframe = document.createElement('iframe'); | 44 var iframe = document.createElement('iframe'); |
| 44 iframe.src = 'resources/disconnected-frame-inner.html'; | 45 iframe.src = 'resources/disconnected-frame-inner.html'; |
| 45 document.body.appendChild(iframe); | 46 document.body.appendChild(iframe); |
| 46 | 47 |
| 47 window.jsTestIsAsync = true; | 48 window.jsTestIsAsync = true; |
| OLD | NEW |