1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
"use strict";
// Here we want to test that blob URLs are not available between private and
// non-private browsing.
const BASE_URI =
"http://mochi.test:8888/browser/browser/components/" +
"privatebrowsing/test/browser/empty_file.html";
add_task(async function test() {
const loaded = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
BASE_URI
);
BrowserTestUtils.loadURIString(gBrowser.selectedBrowser, BASE_URI);
await loaded;
let blobURL;
info("Creating a blob URL...");
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
return Promise.resolve(
content.window.URL.createObjectURL(
new Blob([123], { type: "text/plain" })
)
);
}).then(newURL => {
blobURL = newURL;
});
info("Blob URL: " + blobURL);
info("Creating a private window...");
let privateWin = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
let privateTab = privateWin.gBrowser.selectedBrowser;
const privateTabLoaded = BrowserTestUtils.browserLoaded(
privateTab,
false,
BASE_URI
);
BrowserTestUtils.loadURIString(privateTab, BASE_URI);
await privateTabLoaded;
await SpecialPowers.spawn(privateTab, [blobURL], function (url) {
return new Promise(resolve => {
var xhr = new content.window.XMLHttpRequest();
xhr.onerror = function () {
resolve("SendErrored");
};
xhr.onload = function () {
resolve("SendLoaded");
};
xhr.open("GET", url);
xhr.send();
});
}).then(status => {
is(
status,
"SendErrored",
"Using a blob URI from one user context id in another should not work"
);
});
await BrowserTestUtils.closeWindow(privateWin);
});
|