1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_687710.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Test that sessionrestore handles cycles in the shentry graph properly. 1.8 +// 1.9 +// These cycles shouldn't be there in the first place, but they cause hangs 1.10 +// when they mysteriously appear (bug 687710). Docshell code assumes this 1.11 +// graph is a tree and tires to walk to the root. But if there's a cycle, 1.12 +// there is no root, and we loop forever. 1.13 + 1.14 +let stateBackup = ss.getBrowserState(); 1.15 + 1.16 +let state = {windows:[{tabs:[{entries:[ 1.17 + { 1.18 + docIdentifier: 1, 1.19 + url: "http://example.com", 1.20 + children: [ 1.21 + { 1.22 + docIdentifier: 2, 1.23 + url: "http://example.com" 1.24 + } 1.25 + ] 1.26 + }, 1.27 + { 1.28 + docIdentifier: 2, 1.29 + url: "http://example.com", 1.30 + children: [ 1.31 + { 1.32 + docIdentifier: 1, 1.33 + url: "http://example.com" 1.34 + } 1.35 + ] 1.36 + } 1.37 +]}]}]} 1.38 + 1.39 +function test() { 1.40 + registerCleanupFunction(function () { 1.41 + ss.setBrowserState(stateBackup); 1.42 + }); 1.43 + 1.44 + /* This test fails by hanging. */ 1.45 + ss.setBrowserState(JSON.stringify(state)); 1.46 + ok(true, "Didn't hang!"); 1.47 +}