Closed
Bug 938119
Opened 12 years ago
Closed 7 years ago
False and Erroneous results of javascript 'delete' in web console
Categories
(DevTools :: Console, defect)
Tracking
(Not tracked)
RESOLVED
WORKSFORME
People
(Reporter: g.sravan4u, Unassigned)
References
Details
Attachments
(1 file)
|
34.07 KB,
image/jpeg
|
Details |
User Agent: Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0 (Beta/Release)
Build ID: 20131025151332
Steps to reproduce:
1.Open webconsole in Windows Firefox 25.0
2.Enter var x=2;delete x;
3.Return "true" in console (where as Expected return value of false.)
References:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#delete
Actual results:
var x=2;delete x;
true;
Expected results:
var x=2;delete x;
false;
| Reporter | ||
Updated•12 years ago
|
Severity: normal → major
Component: Untriaged → Developer Tools: Console
Not sure if it's a valid regression.
Regression range:
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=b1fb34b07c17&tochange=9db46ddfb517
Suspected bug:
Mihai Sucan — Bug 808370 - Use the VariablesView in webconsole; r=past,vporof,paul
Flags: needinfo?(mihai.sucan)
Version: 25 Branch → 23 Branch
Comment 2•12 years ago
|
||
|var x=2| puts |x| on the window object. |delete x| deletes the variable from the window object, hence delete returns true. This is working as expected.
Flags: needinfo?(mihai.sucan)
| Reporter | ||
Comment 3•12 years ago
|
||
Its a False result i guess.Because i tested the same javascript on firefox 16.0.2 and chrome.
Both returned false which is just as explained in
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#delete
| Reporter | ||
Comment 4•12 years ago
|
||
(In reply to Mihai Sucan [:msucan] from comment #2)
> |var x=2| puts |x| on the window object. |delete x| deletes the variable
> from the window object, hence delete returns true. This is working as
> expected.
Its a False result i guess.Because i tested the same javascript on firefox 16.0.2 and chrome.
Both returned false which is just as explained in
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#delete
Comment 5•12 years ago
|
||
this is bubbling up from the JS engine. Not a webconsole bug.
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → WONTFIX
| Reporter | ||
Comment 6•12 years ago
|
||
(In reply to Rob Campbell [:rc] (:robcee) from comment #5)
> this is bubbling up from the JS engine. Not a webconsole bug.
This works fine in a web page, so this is console-specific bustage.
//code used for test
/*
<html><head><script>function a(){var x=2;alert(delete x);}
</script></head><body><input type="button" onclick="a()"
value="check"</body></html>
*/
Status: RESOLVED → UNCONFIRMED
Resolution: WONTFIX → ---
Updated•12 years ago
|
Summary: False and Erroneous results of javascript 'delete' → False and Erroneous results of javascript 'delete' in web console
Comment 8•12 years ago
|
||
This may well be a bug in whatever APIs the console uses to evaluate script, of course.
Comment 9•12 years ago
|
||
| Reporter | ||
Comment 10•12 years ago
|
||
(In reply to Panos Astithas [:past] from comment #9)
> Comment 6 uses a different pattern than comment 0, since it deletes a
> variable local to a function. Did you try running it in the web console? It
> returns false:
>
> function a(){var x=2;console.log(delete x);}; a()
Yes in console the code in comment6 returning true
//code in comment6
function a(){var x=2;console.log(delete x);}; a()
| Reporter | ||
Comment 11•12 years ago
|
||
(In reply to g.sravan4u from comment #10)
> (In reply to Panos Astithas [:past] from comment #9)
> > Comment 6 uses a different pattern than comment 0, since it deletes a
> > variable local to a function. Did you try running it in the web console? It
> > returns false:
> >
> > function a(){var x=2;console.log(delete x);}; a()
>
> Yes in console the code in comment6 returning true
> //code in comment6
> function a(){var x=2;console.log(delete x);}; a()
//sorry mistake
UPDATE:RETURNING false
| Reporter | ||
Comment 12•12 years ago
|
||
(In reply to g.sravan4u from comment #10)
> (In reply to Panos Astithas [:past] from comment #9)
> > Comment 6 uses a different pattern than comment 0, since it deletes a
> > variable local to a function. Did you try running it in the web console? It
> > returns false:
> >
> > function a(){var x=2;console.log(delete x);}; a()
>
> Yes in console the code in comment6 returning true
> //code in comment6
> function a(){var x=2;console.log(delete x);}; a()
//sorry mistake
UPDATE:RETURNING false in console
Comment 13•12 years ago
|
||
OK, so here is a page that demonstrates the difference between content and console:
http://htmlpad.org/delete-var/
Open the web console on it and then execute the following in the console:
var y = 1;
console.dir(Object.getOwnPropertyDescriptor(window, "y"));
console.log("delete y: " + (delete y));
It appears that the window property created using the console is configurable, whereas the one created in content is not. The same thing happens when running the code above as a watch expression in the debugger, so it seems that both Debugger.Frame.prototype.eval and Debugger.Object.prototype.evalInGlobalWithBindings behave the same.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 7 → All
Hardware: x86 → All
Comment 14•12 years ago
|
||
OK, so I stepped down into where the property is defined.
We come in via DebuggerGenericEval which lands us in js::EvaluateInEnv, which eventually lands us in Interpret. And then when we get to the JSOP_DEFVAR case, REGS.fp()->isEvalFrame() is true.
Now if that's true, the interpreter figures we're doing eval("var y"). And the spec says that in that case the property will be configurable (see ES 5 section 10.5 step 2 or ES6 section 18.2.1 where it passes "true" as the deletableBindings argument to "Script Evaluation").
So I guess the only question here is whether these debugger APIs want this eval behavior (as opposed to the behavior of running a new toplevel script?) and if so whether the console wants to be using these APIs.
Comment 15•12 years ago
|
||
Debugger.Frame.prototype.eval probably wants to behave like a direct eval in whatever kind of frame 'this' is.
Debugger.Object.prototype.evalInGlobal probably wants to behave like a top-level script.
The console uses one or the other, depending on whether the JS debugger has the debuggee paused or not.
I those (and their 'WithBindings' variants) are the only two ways to get to DebuggerGenericEval.
Comment 16•12 years ago
|
||
OK.
So right now js::EvaluateInEnv always calls setForEval(true) on the compile options. Should we just pass through booleans from its callers indicating whether it should set true or false?
Comment 19•11 years ago
|
||
Wow, would that really work? If it's that easy, then it's definitely worth a try.
Flags: needinfo?(jimb)
Updated•7 years ago
|
Product: Firefox → DevTools
Comment 20•7 years ago
|
||
Executing `var x=2;delete x;` does return false now in the Web Console, not sure when this was fixed as the last comments are pretty old.
Status: NEW → RESOLVED
Closed: 12 years ago → 7 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•