Skip to content

Commit 77e5999

Browse files
authored
test: should serialize storageState with lone surrogates (microsoft#1464)
1 parent c4e1f89 commit 77e5999

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

playwright/src/test/java/com/microsoft/playwright/TestBrowserContextStorageState.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,20 @@ void shouldRoundTripThroughTheFile(@TempDir Path tempDir) throws IOException {
139139
}
140140
context2.close();
141141
}
142+
143+
@Test
144+
void shouldSerialiseStorageStateWithLoneSurrogates() {
145+
page.navigate(server.EMPTY_PAGE);
146+
page.evaluate("chars => window.localStorage.setItem('foo', String.fromCharCode(55934))");
147+
String storageState = context.storageState();
148+
assertJsonEquals("{" +
149+
"cookies:[]," +
150+
"origins:[{\n" +
151+
" origin: 'http://localhost:" + server.PORT + "',\n" +
152+
" localStorage: [{\n" +
153+
" name: 'foo',\n" +
154+
" value: '" + (char)55934 + "'\n" +
155+
" }]\n" +
156+
"}]}", new Gson().fromJson(storageState, JsonObject.class));
157+
}
142158
}

0 commit comments

Comments
 (0)