javascript - Why isn't chrome.pageCapture.saveAsMHTML working in my Google Chrome Extension? -


in google chrome extension, background.js defines function:

function submitmhtml() {   console.log("entered submitmhtml()");   chrome.tabs.query(     {active: true, lastfocusedwindow: true},     function(array_of_tabs) {       if (array_of_tabs.length > 0) {         var tab = array_of_tabs[0];         console.log("submitmhtml() found active tab has id of " + tab.id);         chrome.pagecapture.saveasmhtml(           tab.id,           function(mhtml) {             var xhr = new xmlhttprequest(), formdata = new formdata();               formdata.append("mhtml", mhtml);             formdata.append("surveyid", localstorage["id"]);             xhr.open("post", "http://localhost:3000/task/mhtml", true);             xhr.setrequestheader('authorization', 'token token=<redacted>');             xhr.send(formdata);             console.log("submitmhtml() sent mhtml server");           }         )       }     }   ); } 

why, then, seeing in console?

entered submitmhtml() submitmhtml() found active tab has id of 450 extensions::uncaught_exception_handler:8 error in response tabs.query: error: invocation of form pagecapture.saveasmhtml(integer, function) doesn't match definition pagecapture.saveasmhtml(object details, function callback)     @ object.callback (chrome-extension://nmlggmkodifcibdmpdaohpmhljbkgpdb/background.js:194:28)     @ submitmhtml (chrome-extension://nmlggmkodifcibdmpdaohpmhljbkgpdb/background.js:188:15)     @ submitresult (chrome-extension://nmlggmkodifcibdmpdaohpmhljbkgpdb/background.js:249:5)     @ htmlbuttonelement.<anonymous> (chrome-extension://nmlggmkodifcibdmpdaohpmhljbkgpdb/popup.js:25:78) 

btw, line numbers in console log line this:

  • 194: chrome.pagecapture.saveasmhtml(
  • 188: chrome.tabs.query
  • 249: submitmthml(); (inside function)

chrome.pagecapture.saveasmhtml() defined here. function returns blob, should able attach form in way. i've provided necessary permissions in manifest.

the error explains it. instead of chrome.pagecapture.saveasmhtml(tab.id, callback), use chrome.pagecapture.saveasmhtml({ tabid: tab.id }, callback)


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -