timeout-clear-watch.js revision e78cbe89e6f337f2f1fe40315be88f742b547151
1cfb0617749a64f2e177386b030d46007b8c4b179Steve Blockdescription("Tests that when a watch times out and is cleared from the error callback, there is no crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=32111.");
2cfb0617749a64f2e177386b030d46007b8c4b179Steve Block
3cfb0617749a64f2e177386b030d46007b8c4b179Steve Blockwindow.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100.0);
4cfb0617749a64f2e177386b030d46007b8c4b179Steve Block
5cfb0617749a64f2e177386b030d46007b8c4b179Steve Blockvar error;
6cfb0617749a64f2e177386b030d46007b8c4b179Steve Blockvar watchId = navigator.geolocation.watchPosition(function() {
7cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    testFailed('Success callback invoked unexpectedly');
8e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block    finishJSTest();
9cfb0617749a64f2e177386b030d46007b8c4b179Steve Block}, function(e) {
10cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    error = e
11cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    shouldBe('error.code', 'error.TIMEOUT');
12cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    shouldBe('error.message', '"Timeout expired"');
13cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    navigator.geolocation.clearWatch(watchId);
14e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block    window.setTimeout(finishJSTest, 0);
15cfb0617749a64f2e177386b030d46007b8c4b179Steve Block}, {
16cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    timeout: 0
17cfb0617749a64f2e177386b030d46007b8c4b179Steve Block});
18cfb0617749a64f2e177386b030d46007b8c4b179Steve Block
19cfb0617749a64f2e177386b030d46007b8c4b179Steve Blockwindow.layoutTestController.waitUntilDone();
20cfb0617749a64f2e177386b030d46007b8c4b179Steve Block
21e78cbe89e6f337f2f1fe40315be88f742b547151Steve Blockwindow.jsTestIsAsync = true;
22e78cbe89e6f337f2f1fe40315be88f742b547151Steve Blockwindow.successfullyParsed = true;
23