I have a simple method which captures current tab, and it works only when this method triggered by click on extension button (i.e. browserAction).
But when I use this method in setTimeout event it fails with following error:
Unchecked runtime.lastError while running tabCapture.capture: Extension has not been invoked for the current page (see activeTab permission). Chrome pages cannot be captured.
My simple capture method is:
function captureTab() {
var constraints = ...
chrome.tabCapture.capture(constraints, function (stream) {
if (!stream) {
console.error("couldn't record tab");
return;
}
// recording succeeded
});
}
And it works when it triggered as follows:
chrome.browserAction.onClicked.addListener(function () {
chrome.tabs.getSelected(null, function (tab) {
captureTab();
});
});
But doesn't work when it triggered as follows:
setTimeout(function () {
chrome.tabs.getSelected(1, function (tab) {
captureTab();
});
}, 1 * 30 * 1000);
Important note: My extension isn't a public extension and it runs only on my browser so I can add any command line switch on start (in order to disable this limitation), if needed.