“SECURITY_ERR: DOM Exception 18” o…

1 min read Original article ↗

This error occurs when the history.pushState() or history.replaceState() method is called more than 100 times.

This error occurs in “iOS9.3 Beta3” Safari, but does not occur in “iOS9.3 Beta1” Safari.

The following is a test method.

1. Open xcode7.3 beta3, launch the iOS simulator.

2. Open Safari in iOS simulator.

3. Enter address of “http://www.apple.com” on Safari.

4. Open Safari on Mac, and then link to the simulator.

5. Type the following test program to the console.

for (var i=0 ; i<=100; i++) { window.history.pushState(null, null, "http://www.apple.com/"); }

for (var i=0 ; i<=100; i++) { window.history.replaceState(null, null, "http:/www.apple.com/"); }

I get the following error when “i = 100".

▼In the case of history.replaceState() method.

=======================================

Error: SecurityError: DOM Exception 18

code: 18

column: 124

line: 1

message: "SecurityError: DOM Exception 18"

name: "SecurityError"

stack: "replaceState@[native code]↵eval code↵eval@[native code]↵_evaluateOn↵_evaluateAndWrap↵evaluate"

DOMException prototype

=======================================

▼In the case of history.pushState() method.

=======================================

Error: SecurityError: DOM Exception 18

code: 18

column: 175

line: 1

message: "SecurityError: DOM Exception 18"

name: "SecurityError"

stack: "pushState@[native code]↵eval code↵eval@[native code]↵_evaluateOn↵_evaluateAndWrap↵evaluate"

DOMException prototype

=======================================

My question, which is true, a bug or spec?

Thank you guys