firebug fails to report error like "if(maxi - 1 = i)..." - syntax

I missed a "=",
should be:
if(maxi - 1 == i)...
but firebug didn't report anything.
And it took quite a while for me to found it.
Is it a bug of firebug?

It works perfectly for me. I am using Firebug v1.4.2.
Additional add-ons: Google Page Speed, YSlow, Firecookies
My code:
<script type="text/javascript">
var max = 5;
if(max - 1 = 4){
alert(true);
}
</script>
Screenshot:
screenshot http://img12.imageshack.us/img12/451/21986504.th.jpg
I have a "Invalid assignment left-hand side" error for the example you've provided.
EDIT:
As described by Asker - the error was in a JS file. I've done an include like this. Same thing, the error was also tracked.
screenshot http://img17.imageshack.us/img17/8462/31594029.th.jpg
Conclusion
I think its that, when you load the page, Firebug is not activated. When you activate after page has loaded, the error was not captured. Thus you see no error. If you keep Firebug activated and open the page, you might just see the error logged.
Hope this helps!

Firebug is not necessarily the be-all-end-all of code problems. It is only a tool to help you find bugs. It's impossible to write a tool to find every single bug in a program (if only...).

To be fair, nothing in your toolbox found it -- why place the blame only on Firebug? You missed it, your text editor missed it, and your unit tests missed it, at least.
For example, if I type that expression in my editor, it's underlined in orange, and the status bar says:
Test for equality (==) mistyped as assignment (=)? (parenthesize to suppress warning)
Why wait until your code gets to your web browser to see if it worked? There are many steps before that which are great for verification and testing. The sooner you identify problems, the easier they are to fix.

Related

kendo grid works fine when javaScript alert exist but not working without javaScript alert

When I add a new row kendo ui grid it does not move to next page even I set page number dynamically.
But when there is a javaScrip alert it's working fine.
Has any one faced this issue before. Please suggest me a solution.
Thank you.
The problem is that when you add a new row there are a series of actions that happen in parallel and they are not immediate. If you try to move to the end but the row still is being created, if fails.
When you add an alert, you delay the fact of moving and creation now have time.
If you really need to do it, you can add a timeout (delay) it is not nice/clean but should work.
Do something like:
setTimeout(function() {
grid.page(3);
}, 500);
for introducing half second (500 ms) delay, should be enough.
We had sort of similar issue in IE - onchange fired twice with alert in the event handler. According to what you saying, it sounds like when the alert is NOT in you are getting correct behaviour. Review your code without having the alert in or post a fiddle. Below is an answer from Kendo support in regards to alerts while debugging. Do not use alerts with kendo to stay safe.
Basically this behavior is caused by using "alert" method for debugging purposes - please note that this is not recommended because it can lead to unexpected behavior when interacting with focusing elements. After replacing the "alert" method and with "debbuger" command or "console.log()" function the change event is working as expected - please check this screencast(http://screencast.com/t/7qIAdK6hZ5kD).
Hope it helps.

Discrepancy between PhantomJS and Qunit test in Grunt?

I'm writing my first jQuery plugin with Grunt and TDD, and its been awesome so far. All of my tests are passing in the browser, and all but this one are passing in phantomjs/qunit.
But I'm sure I'm just missing something here. I have a test that gets the css value of the margin that is added with jQuery.
test('adds appropriate styles to image', 1, function() {
this.simpleString.adaminNumReplace();
var newMargin = this.simpleString.find('> img:first').css('margin');
strictEqual(newMargin, '0px', 'margin is equal to default');
});
The test passes when I use the runner to test in browser. And when I visually check in the inspector. And if I console.log the value. Everything appears to be fine and points to '0px'.
But in the terminal window, the test fails:
$.fn.adaminNumReplace() - adds appropriate styles to image
Message: margin is equal to default
Actual: ""
Expected: "0px"
at file:///Applications/MAMP/htdocs/adamin_number_replace/libs/qunit/qunit.js:357
Is there any reason that phantomjs wouldn't be able to grab the css margin value? It says Actual is "". But it is definitely '0px'.
Any insight or thought would really be appreciated!
The full repo is here, in case it helps: Github Repo
Okay. So I was able to figure this out. I'm not totally sure as to why. But calling the css shortcut
.css('margin')
returns nil in the terminal. But does work in the spec runner.
However, calling the specific:
.css('margin-top')
Does in fact return '0px' which is what i was going for here.
So it looks like the answer, in case anyone else might run into this:
I am not able to return css values when using a shortcut like 'margin' or 'padding'.
Use specifics like 'margin-top', 'padding-left' etc...
hope that helps someone else...

Firefox WebDriver does not find the element of the page

I would like to use WebDriver (Firefox) to test my webpage, but I always get this message:
Unable to locate element: {"method":"xpath","selector":"//li[#id='something_spicy']"}
But, the really strange thing is that if I copy the element locator "//li[#id='something_spicy']" and paste it into Firefinder then it works. Basically, I ran out of thoughts about what could be the root cause.
I use C# and here is the code:
movedElement = driver.FindElement(By.XPath("//li[#id='" + originalOrderOfSportContainers[1] + "']"));
Did I do something wrong? Have I missed something?
provide a snippet of the html code of your page.
There is a chance that element is not there immediately after the page is loaded,
but appears a bit later as a result of some javascript function execution.
If this is the case, use explicit wait to wait for element to appear before using it.

Using fb:request-form "Something's gone wrong. We're working to get it fixed as soon as we can."

I have been using fb:request-form for my "Friend invite form" for a while now, but all of a sudden I am having problems. It renders everything perfectly. However, when I am all done and I submit it says something went wrong and it shows me a little dialog:
"Something's gone wrong. We're working to get it fixed as soon as we can.".
I have this in all my applications (live and test), and I am using the following code (from one of my test applications).
<fb:serverFbml width= "750">
<script type="text/fbml" >
<fb:fbml width = "750">
<fb:request-form type="Pannemantest" type="XFBML" invite="true" method="POST" action="http://michaelp.dev.gamepoint.net/framework/mainsite/facebookfriendinvite.php?&submit=1 " content="Hi! Come and join me in PartyDice: The most exciting dicegame on Facebook. Roll the dice, mark your score and beat your opponent. Use your FREE Daily Credits to play NOW!<fb:req-choice url="http://apps.facebook.com/pannemantest/" label="Join the fun!" >">
<fb:multi-friend-selector style='width: 650px;' actiontext="Have even more fun by inviting your friends!" showborder="true" exclude_ids="" />
</fb:request-form>
</fb:fbml>
</script>
</fb:serverFbml>
I am not sure what caused this behavior, and I can't find anything wrong with my code (since this exact code has been online for a really long time, and nothing goes wrong with the rendering). Maybe I didn't look properly, but I couldn't find any changes announced or anything like that either for this form.
What should I do? Is there another way of producing the same form?
Here's the solution, from:
http://developers.facebook.com/bugs/288168691208443?browse=search_4e9fc696c07fd0895788720
"add import_external_friends=false to your and it will resolve the issue."

HTMLUnit click() on HtmlElement does not work

I'm trying to get HTMLUnit to perform a click action on a span, which doesn't work for some reason. Please take a peek at the code below.
HtmlElement clickable = (HtmlElement) page.getByXPath("//div[10]/div/div/span").get(0);
clickable.click();
By doing this I get a really long error message. The interesting bit seems to be the following:
TypeError: Cannot find function setCapture in object [object].(script in [some long url here])
The same thing happens when i try to call on mouseDown() or dblClick() or any other mousey method. This is really frustrating since the code snippet is something that worked fine some time ago. I simply uncommented it today and now it won't co-operate.
HtmlUnit doesn't currently support .setCapture()/.releaseCapture(), please open a bug report in its tracker

Resources