Skip to content

Commit 5e4d79a

Browse files
committed
fix behavior of _top and _parent
1 parent ef2fe16 commit 5e4d79a

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/client/dom/open.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { rewriteUrl } from "../../shared";
22
import { ScramjetClient } from "../client";
3-
import { SCRAMJETCLIENT } from "../../symbols";
3+
import {
4+
SCRAMJETCLIENT,
5+
SCRAMJETCLIENTNAME,
6+
SCRAMJETFRAMENAME,
7+
} from "../../symbols";
48

59
export default function (client: ScramjetClient) {
610
client.Proxy("window.open", {
711
apply(ctx) {
812
if (ctx.args[0]) ctx.args[0] = rewriteUrl(ctx.args[0], client.meta);
913

1014
if (["_parent", "_top", "_unfencedTop"].includes(ctx.args[1]))
11-
ctx.args[1] = "_self";
15+
ctx.args[1] = SCRAMJETFRAMENAME; // TODO: this is still technically the wrong behavior
1216

1317
const realwin = ctx.call();
1418

src/controller/frame.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { ScramjetController } from ".";
22
import type { ScramjetClient } from "../client/client";
3-
import { SCRAMJETCLIENT, SCRAMJETFRAME } from "../symbols";
3+
import { SCRAMJETCLIENT, SCRAMJETFRAME, SCRAMJETFRAMENAME } from "../symbols";
44

55
export class ScramjetFrame extends EventTarget {
66
constructor(
77
private controller: ScramjetController,
88
public frame: HTMLIFrameElement
99
) {
1010
super();
11+
frame.name = SCRAMJETFRAMENAME;
1112
frame[SCRAMJETFRAME] = this;
1213
}
1314

src/shared/rewriters/html.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { CookieStore } from "../cookie";
88
import { unrewriteBlob } from "../../shared/rewriters/url";
99
import { $scramjet } from "../../scramjet";
1010
import { getRewriter } from "./wasm";
11+
import { SCRAMJETCLIENTNAME, SCRAMJETFRAMENAME } from "../../symbols";
1112

1213
const encoder = new TextEncoder();
1314
function rewriteHtmlInner(
@@ -231,7 +232,8 @@ export const htmlRules: {
231232
},
232233
{
233234
fn: (value: string) => {
234-
if (["_parent", "_top", "_unfencedTop"].includes(value)) return "_self";
235+
if (["_parent", "_top", "_unfencedTop"].includes(value))
236+
return SCRAMJETFRAMENAME; // TODO: ...
235237
else return value;
236238
},
237239
target: ["a", "base"],

src/symbols.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
export const SCRAMJETCLIENTNAME = "scramjet client global";
33
export const SCRAMJETCLIENT = Symbol.for(SCRAMJETCLIENTNAME);
44
export const SCRAMJETFRAME = Symbol.for("scramjet frame handle");
5+
export const SCRAMJETFRAMENAME = "scramjet_frame";

0 commit comments

Comments
 (0)