Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fixup! Bug #15502, Part 2: Regression tests for blob URL isolation
- Loading branch information
Showing
with
94 additions
and 19 deletions.
- +2 −1 dom/base/test/bug15502_page_blobify.html
- +2 −1 dom/base/test/bug15502_page_deblobify.html
- +3 −2 dom/base/test/bug15502_tab.html
- +7 −8 dom/base/test/bug15502_utils.js
- +2 −1 dom/base/test/bug15502_worker_blobify.html
- +2 −1 dom/base/test/bug15502_worker_deblobify.html
- +1 −0 dom/base/test/mochitest.ini
- +63 −0 dom/base/test/task_spawn.js
- +12 −5 dom/base/test/test_tor_bug15502.html
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| @@ -244,6 +244,7 @@ support-files = | ||
| send_gzip_content.sjs | ||
| somedatas.resource | ||
| somedatas.resource^headers^ | ||
| task_spawn.js | ||
| variable_style_sheet.sjs | ||
| viewport_helpers.js | ||
| w3element_traversal.svg | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| @@ -0,0 +1,63 @@ | ||
| // # task_spawn.js | ||
| // A simple implementation of Task.spawn. For detailed usage instructions, | ||
| // see https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Task.jsm | ||
|
|
||
| /* jshint esnext: true */ | ||
|
|
||
| // __spawn(generatorFunction)__. | ||
| // Expose only the spawn function, very similar to Task.spawn in Task.jsm. | ||
| let spawn = (function () { | ||
|
|
||
| // Declare ahead | ||
| let promiseFromGenerator; | ||
|
|
||
| // Returns true if aValue is a generator object. | ||
| let isGenerator = aValue => { | ||
| return Object.prototype.toString.call(aValue) === "[object Generator]"; | ||
| }; | ||
|
|
||
| // Converts the right-hand argument of yield or return values to a Promise, | ||
| // according to Task.jsm semantics. | ||
| let asPromise = yieldArgument => { | ||
| if (yieldArgument instanceof Promise) { | ||
| return yieldArgument; | ||
| } else if (isGenerator(yieldArgument)) { | ||
| return promiseFromGenerator(yieldArgument); | ||
| } else if (yieldArgument instanceof Function) { | ||
| return asPromise(yieldArgument()); | ||
| } else if (yieldArgument instanceof Error) { | ||
| return Promise.reject(yieldArgument); | ||
| } else { | ||
| return Promise.resolve(yieldArgument); | ||
| } | ||
| }; | ||
|
|
||
| // Takes a generator object and runs it as an asynchronous task, | ||
| // returning a Promise with the result of that task. | ||
| promiseFromGenerator = generator => { | ||
| return new Promise((resolve, reject) => { | ||
| let processPromise; | ||
| let processPromiseResult = (success, result) => { | ||
| try { | ||
| let {value, done} = success ? generator.next(result) | ||
| : generator.throw(result); | ||
| if (done) { | ||
| asPromise(value).then(resolve, reject); | ||
| } else { | ||
| processPromise(asPromise(value)); | ||
| } | ||
| } catch (error) { | ||
| reject(error); | ||
| } | ||
| }; | ||
| processPromise = promise => { | ||
| promise.then(result => processPromiseResult(true, result), | ||
| error => processPromiseResult(false, error)); | ||
| }; | ||
| processPromise(asPromise(undefined)); | ||
| }); | ||
| }; | ||
|
|
||
| // __spawn(generatorFunction)__. | ||
| return generatorFunction => promiseFromGenerator(generatorFunction()); | ||
| })(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters