Skip to content

Commit 5238a86

Browse files
authored
Merge pull request #1169 from asurdej-comcast/RWI_har
wpe-2.38: [WebInspectorUI] Implemented Web Inspector Save Function
2 parents abc2c80 + ee5c447 commit 5238a86

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

Source/WebInspectorUI/UserInterface/Base/BrowserInspectorFrontendHost.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,27 @@ if (!window.InspectorFrontendHost) {
226226

227227
canSave(saveMode)
228228
{
229-
return false;
229+
return true;
230230
}
231231

232232
save(saveDatas, forceSaveAs)
233233
{
234-
// FIXME: Create a Blob from the content, get an object URL, open it to trigger a download.
235-
throw "unimplemented";
234+
for (let saveData of saveDatas) {
235+
var blob = new Blob([saveData.content], {type: "octet/stream"});
236+
var blobURL = window.URL.createObjectURL(blob);
237+
238+
var a = document.createElement("a");
239+
a.href = blobURL;
240+
a.style.display = "none";
241+
// url looks like "web-inspector:///file.ext" use filename only
242+
a.download = saveData.url.split('/').pop();
243+
// Don't add this element to the DOM to skip custom click handler
244+
// that will remove target file name ('download' attr)
245+
a.click();
246+
setTimeout(()=>{
247+
window.URL.revokeObjectURL(blob);
248+
}, 0);
249+
}
236250
}
237251

238252
canLoad()

0 commit comments

Comments
 (0)