Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * This test checks that we properly set the frozen, sealed, and non-extensbile |
michael@0 | 6 | * attributes on variables so that the F/S/N is shown in the variables view. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; |
michael@0 | 10 | |
michael@0 | 11 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 12 | |
michael@0 | 13 | function test() { |
michael@0 | 14 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 15 | gTab = aTab; |
michael@0 | 16 | gDebuggee = aDebuggee; |
michael@0 | 17 | gPanel = aPanel; |
michael@0 | 18 | gDebugger = gPanel.panelWin; |
michael@0 | 19 | |
michael@0 | 20 | prepareTest(); |
michael@0 | 21 | }); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | function prepareTest() { |
michael@0 | 25 | gDebugger.once(gDebugger.EVENTS.FETCHED_SCOPES, runTest); |
michael@0 | 26 | |
michael@0 | 27 | gDebuggee.eval("(" + function() { |
michael@0 | 28 | var frozen = Object.freeze({}); |
michael@0 | 29 | var sealed = Object.seal({}); |
michael@0 | 30 | var nonExtensible = Object.preventExtensions({}); |
michael@0 | 31 | var extensible = {}; |
michael@0 | 32 | var string = "foo bar baz"; |
michael@0 | 33 | |
michael@0 | 34 | debugger; |
michael@0 | 35 | } + "())"); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function runTest() { |
michael@0 | 39 | let hasNoneTester = function(aVariable) { |
michael@0 | 40 | ok(!aVariable.hasAttribute("frozen"), |
michael@0 | 41 | "The variable should not be frozen."); |
michael@0 | 42 | ok(!aVariable.hasAttribute("sealed"), |
michael@0 | 43 | "The variable should not be sealed."); |
michael@0 | 44 | ok(!aVariable.hasAttribute("non-extensible"), |
michael@0 | 45 | "The variable should be extensible."); |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | let testers = { |
michael@0 | 49 | frozen: function (aVariable) { |
michael@0 | 50 | ok(aVariable.hasAttribute("frozen"), |
michael@0 | 51 | "The variable should be frozen."); |
michael@0 | 52 | }, |
michael@0 | 53 | sealed: function (aVariable) { |
michael@0 | 54 | ok(aVariable.hasAttribute("sealed"), |
michael@0 | 55 | "The variable should be sealed."); |
michael@0 | 56 | }, |
michael@0 | 57 | nonExtensible: function (aVariable) { |
michael@0 | 58 | ok(aVariable.hasAttribute("non-extensible"), |
michael@0 | 59 | "The variable should be non-extensible."); |
michael@0 | 60 | }, |
michael@0 | 61 | extensible: hasNoneTester, |
michael@0 | 62 | string: hasNoneTester, |
michael@0 | 63 | arguments: hasNoneTester, |
michael@0 | 64 | this: hasNoneTester |
michael@0 | 65 | }; |
michael@0 | 66 | |
michael@0 | 67 | let variables = gDebugger.document.querySelectorAll(".variable-or-property"); |
michael@0 | 68 | |
michael@0 | 69 | for (let variable of variables) { |
michael@0 | 70 | let name = variable.querySelector(".name").getAttribute("value"); |
michael@0 | 71 | let tester = testers[name]; |
michael@0 | 72 | delete testers[name]; |
michael@0 | 73 | |
michael@0 | 74 | ok(tester, "We should have a tester for the '" + name + "' variable."); |
michael@0 | 75 | tester(variable); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | is(Object.keys(testers).length, 0, |
michael@0 | 79 | "We should have run and removed all the testers."); |
michael@0 | 80 | |
michael@0 | 81 | resumeDebuggerThenCloseAndFinish(gPanel); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | registerCleanupFunction(function() { |
michael@0 | 85 | gTab = null; |
michael@0 | 86 | gDebuggee = null; |
michael@0 | 87 | gPanel = null; |
michael@0 | 88 | gDebugger = null; |
michael@0 | 89 | }); |