Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/disconnected-frame.js

Issue 1948033003: Convert most geolocation layout tests to use a JS mock implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-disconnect
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 description("Tests that when a request is made on a Geolocation object and its F rame is disconnected before a callback is made, no callbacks are made."); 1 description("Tests that when a request is made on a Geolocation object and its F rame is disconnected before a callback is made, no callbacks are made.");
2 2
3 if (!window.testRunner || !window.internals) 3 if (!window.testRunner || !window.mojo)
4 debug('This test can not run without testRunner or internals'); 4 debug('This test can not run without testRunner or mojo');
5 5
6 internals.setGeolocationClientMock(document); 6 var error;
7 internals.setGeolocationPermission(document, true); 7 var iframe = document.createElement('iframe');
8 internals.setGeolocationPosition(document, 51.478, -0.166, 100);
9 8
10 function onIframeLoaded() { 9 function onIframeLoaded() {
11 iframeGeolocation = iframe.contentWindow.navigator.geolocation; 10 iframeGeolocation = iframe.contentWindow.navigator.geolocation;
12 iframe.src = 'data:text/html,This frame should be visible when the test comp letes'; 11 iframe.src = 'data:text/html,This frame should be visible when the test comp letes';
13 } 12 }
14 13
15 var error;
16 function onIframeUnloaded() { 14 function onIframeUnloaded() {
17 iframeGeolocation.getCurrentPosition(function () { 15 iframeGeolocation.getCurrentPosition(function () {
18 testFailed('Success callback invoked unexpectedly'); 16 testFailed('Success callback invoked unexpectedly');
19 finishJSTest(); 17 finishJSTest();
20 }, function(e) { 18 }, function(e) {
21 testFailed('Error callback invoked unexpectedly'); 19 testFailed('Error callback invoked unexpectedly');
22 finishJSTest(); 20 finishJSTest();
23 }); 21 });
24 setTimeout(function() { 22 setTimeout(function() {
25 testPassed('No callbacks invoked'); 23 testPassed('No callbacks invoked');
26 finishJSTest(); 24 finishJSTest();
27 }, 100); 25 }, 100);
28 } 26 }
29 27
30 var iframe = document.createElement('iframe'); 28 geolocationServiceMock.then(mock => {
31 iframe.src = 'resources/disconnected-frame-inner.html'; 29 mock.setGeolocationPermission(true);
32 document.body.appendChild(iframe); 30 mock.setGeolocationPosition(51.478, -0.166, 100);
31
32 iframe.src = 'resources/disconnected-frame-inner.html';
33 document.body.appendChild(iframe);
34 });
33 35
34 window.jsTestIsAsync = true; 36 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698