browser.tabs.get(Number('5'), callback) doesn't work in Edge

Issue #11183879 • Assigned to Sebastian P.

Details

Author
Adolf D.
Created
Mar 6, 2017
Privacy
This issue is public.
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

browser.tabs.get() API is treating Number(‘5’) different than parseInt('5’, 10).

In our code, we were converting a “string” number (like ‘5’) to an integer using Number(string) but it fails with “Invalid Input” error for browser.tabs.get() API. It works fine only if we use parseInt('5’, 10).

// this works
browser.tabs.getCurrent(function(tab) {
// works
browser.tabs.get(tab.id, function(tab) {
console.log("tab Id: " + tab.id);
});
var strTabId = “” + tab.id;
// works
browser.tabs.get(parseInt(strTabId, 10), function(tab) {
console.log("tab Id: " + tab.id);
});

// doesn't work. throws "invalid input" error
browser.tabs.get(Number(strTabId), function(tab) {
  console.log("tab Id: " + tab.id);
});

});

What is the difference between the two usage in terms of browser.tabs.get()?

Attachments

1 attachment

Comments and activity

  • Microsoft Edge Team

    Changed Status to “By design”

  • Hi Adolf,

     

    Both usages are
    the same.  This function does not support method overloading and requires
    an ‘integer’ for the ‘tabId’ as a parameter.  The second usage you listed
    is passing a JavaScript ‘Number’ object and not an integer.  This is why
    you are seeing the “Invalid Input” error. More information on the Number object
    in Javascript

    https://docs.microsoft.com/en-us/scripting/javascript/reference/number-object-javascript

     

     

    Here are more
    details and an example.

    https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/Tabs/get

    you could also use Number.parseInt()

    [from:

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt

    ]

    All the best,

    The MS Edge Team  

  • Microsoft Edge Team

    Changed Assigned To to “Sebastian P.”

  • I ran a test, and Chrome supports this, so this is a minor interop issue we should be tracking. 

  • Microsoft Edge Team

    Changed Status from “By design”

    Changed Status to “Confirmed”

    Changed Status from “Confirmed”

You need to sign in to your Microsoft account to add a comment.

Sign in