| 1 | /**
|
|---|
| 2 | * Copyright 2018 Google Inc. All Rights Reserved.
|
|---|
| 3 | * Licensed under the Apache License, Version 2.0 (the "License");
|
|---|
| 4 | * you may not use this file except in compliance with the License.
|
|---|
| 5 | * You may obtain a copy of the License at
|
|---|
| 6 | * http://www.apache.org/licenses/LICENSE-2.0
|
|---|
| 7 | * Unless required by applicable law or agreed to in writing, software
|
|---|
| 8 | * distributed under the License is distributed on an "AS IS" BASIS,
|
|---|
| 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|---|
| 10 | * See the License for the specific language governing permissions and
|
|---|
| 11 | * limitations under the License.
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | describe("Module Worker", function() {
|
|---|
| 15 | const blob = new Blob([""], { type: "text/javascript" });
|
|---|
| 16 | const url = URL.createObjectURL(blob);
|
|---|
| 17 | let supportsModuleWorker = false;
|
|---|
| 18 | const options = {
|
|---|
| 19 | get type() {
|
|---|
| 20 | supportsModuleWorker = true;
|
|---|
| 21 | }
|
|---|
| 22 | };
|
|---|
| 23 | new Worker(url, options).terminate();
|
|---|
| 24 | URL.revokeObjectURL(url);
|
|---|
| 25 |
|
|---|
| 26 | beforeEach(function() {
|
|---|
| 27 | if (!supportsModuleWorker) {
|
|---|
| 28 | return this.skip();
|
|---|
| 29 | }
|
|---|
| 30 | this.ifr = document.createElement("iframe");
|
|---|
| 31 | document.body.append(this.ifr);
|
|---|
| 32 | });
|
|---|
| 33 |
|
|---|
| 34 | afterEach(function() {
|
|---|
| 35 | this.ifr.remove();
|
|---|
| 36 | });
|
|---|
| 37 |
|
|---|
| 38 | it("work", function(done) {
|
|---|
| 39 | window.addEventListener("message", function l(ev) {
|
|---|
| 40 | if (ev.data === "a") {
|
|---|
| 41 | window.removeEventListener("message", l);
|
|---|
| 42 | done();
|
|---|
| 43 | }
|
|---|
| 44 | });
|
|---|
| 45 | this.ifr.src = "/base/tests/fixtures/module-worker/build/runner.html";
|
|---|
| 46 | });
|
|---|
| 47 | });
|
|---|