Education/Learning/ModifyBrowser: Difference between revisions

Jump to navigation Jump to search
Line 174: Line 174:
Clearly this code has some problems, since we've completely broken addTab.  Let's look for clues in the '''Error Console''' (Tools > Error Console).  Notice the following exception appear whenever we try to add a new tab:
Clearly this code has some problems, since we've completely broken addTab.  Let's look for clues in the '''Error Console''' (Tools > Error Console).  Notice the following exception appear whenever we try to add a new tab:


<code>Error: uncaught exception: [Exception... "Could not convert JavaScript argument"  nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS frame :: chrome://global/content/bindings/tabbrowser.xml :: addTab :: line 1161"  data: no]</code>
Error: uncaught exception: [Exception... "Could not convert JavaScript argument"
  nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS frame ::
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.  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:
Confirmed users
656

edits

Navigation menu