Education/Learning/ModifyBrowser: Difference between revisions

Jump to navigation Jump to search
Clarified how we identify the error in second attempt
(Clarified how we identify the error in second attempt)
 
Line 185: Line 185:
  chrome://global/content/bindings/tabbrowser.xml :: addTab :: line 1161"  data: no]
  chrome://global/content/bindings/tabbrowser.xml :: addTab :: line 1161"  data: no]


Now we know how to find errors our JavaScript produces.  Looking back at our code, it's clear that that '''childNodes.length''' is not zero, but 1 by default (i.e., there is always at least one tab, even if it isn't visible).  A quick modification to the code, and we get:
Now we know how to find errors our JavaScript produces.  The line number in the source file may be larger than the one in the error message (download '''chrome://global/content/bindings/tabbrowser.xml''' in your new copy of Firefox to see the line numbers the browser is using). Since the error is in the '''else''' clause, it's clear that that '''childNodes.length''' is not zero, but 1 by default (i.e., every window contains at least one tab, even if the tab controls are not visible).  A quick modification to the code, and we get:


  if (this.mTabContainer.childNodes.length '''== 1''') {  
  if (this.mTabContainer.childNodes.length '''== 1''') {  
2

edits

Navigation menu