browser.windows.create({ url: "google.com", }, function (window) { var tabid = window.tabs[0].id; var makeItGreen = 'document.body.style.border = "20px solid green"'; browser.tabs.executeScript( tabid, { code: makeItGreen }); The code does not want to work, stops at opening the window, and if you run the same code in the console, but divide it into 2 parts, everything works out, if I understand correctly, this is because the callback starts to run when the window itself opens, but the tab is still not loaded, but then the question arises how to execute the code after the tab has loaded.