michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * This test checks that we properly set the frozen, sealed, and non-extensbile michael@0: * attributes on variables so that the F/S/N is shown in the variables view. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: michael@0: prepareTest(); michael@0: }); michael@0: } michael@0: michael@0: function prepareTest() { michael@0: gDebugger.once(gDebugger.EVENTS.FETCHED_SCOPES, runTest); michael@0: michael@0: gDebuggee.eval("(" + function() { michael@0: var frozen = Object.freeze({}); michael@0: var sealed = Object.seal({}); michael@0: var nonExtensible = Object.preventExtensions({}); michael@0: var extensible = {}; michael@0: var string = "foo bar baz"; michael@0: michael@0: debugger; michael@0: } + "())"); michael@0: } michael@0: michael@0: function runTest() { michael@0: let hasNoneTester = function(aVariable) { michael@0: ok(!aVariable.hasAttribute("frozen"), michael@0: "The variable should not be frozen."); michael@0: ok(!aVariable.hasAttribute("sealed"), michael@0: "The variable should not be sealed."); michael@0: ok(!aVariable.hasAttribute("non-extensible"), michael@0: "The variable should be extensible."); michael@0: }; michael@0: michael@0: let testers = { michael@0: frozen: function (aVariable) { michael@0: ok(aVariable.hasAttribute("frozen"), michael@0: "The variable should be frozen."); michael@0: }, michael@0: sealed: function (aVariable) { michael@0: ok(aVariable.hasAttribute("sealed"), michael@0: "The variable should be sealed."); michael@0: }, michael@0: nonExtensible: function (aVariable) { michael@0: ok(aVariable.hasAttribute("non-extensible"), michael@0: "The variable should be non-extensible."); michael@0: }, michael@0: extensible: hasNoneTester, michael@0: string: hasNoneTester, michael@0: arguments: hasNoneTester, michael@0: this: hasNoneTester michael@0: }; michael@0: michael@0: let variables = gDebugger.document.querySelectorAll(".variable-or-property"); michael@0: michael@0: for (let variable of variables) { michael@0: let name = variable.querySelector(".name").getAttribute("value"); michael@0: let tester = testers[name]; michael@0: delete testers[name]; michael@0: michael@0: ok(tester, "We should have a tester for the '" + name + "' variable."); michael@0: tester(variable); michael@0: } michael@0: michael@0: is(Object.keys(testers).length, 0, michael@0: "We should have run and removed all the testers."); michael@0: michael@0: resumeDebuggerThenCloseAndFinish(gPanel); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: });