I have a button in my extension that triggers the following code:
chrome.tabs.create({url: \'data:text;base64,\'+btoa(data), active:false});
For all who try to preserve newline characters in a data URI without base64 encryption: this is not possible, you have to use base64 encoding.