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
3545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochif (window.layoutTestController)
4545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch    layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100.0);
5cfb0617749a64f2e177386b030d46007b8c4b179Steve Block
6cfb0617749a64f2e177386b030d46007b8c4b179Steve Blockvar error;
7cfb0617749a64f2e177386b030d46007b8c4b179Steve Blockvar watchId = navigator.geolocation.watchPosition(function() {
8cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    testFailed('Success callback invoked unexpectedly');
9e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block    finishJSTest();
10cfb0617749a64f2e177386b030d46007b8c4b179Steve Block}, function(e) {
11545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch    error = e;
12cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    shouldBe('error.code', 'error.TIMEOUT');
13cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    shouldBe('error.message', '"Timeout expired"');
14cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    navigator.geolocation.clearWatch(watchId);
15e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block    window.setTimeout(finishJSTest, 0);
16cfb0617749a64f2e177386b030d46007b8c4b179Steve Block}, {
17cfb0617749a64f2e177386b030d46007b8c4b179Steve Block    timeout: 0
18cfb0617749a64f2e177386b030d46007b8c4b179Steve Block});
19cfb0617749a64f2e177386b030d46007b8c4b179Steve Block
20cfb0617749a64f2e177386b030d46007b8c4b179Steve Block
21e78cbe89e6f337f2f1fe40315be88f742b547151Steve Blockwindow.jsTestIsAsync = true;
22e78cbe89e6f337f2f1fe40315be88f742b547151Steve Blockwindow.successfullyParsed = true;
23