history API throws NS_UNEXPECTED-ERROR when used from addons, scratchpad and Web console

NEW
Unassigned

Status

()

Core
Document Navigation
6 years ago
4 years ago

People

(Reporter: Louis-Rémi BABE, Unassigned)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
using history.pushState or history.replaceState from an addon, the Web console or scratchpad return such errors:

[16:59:17.753] [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIDOMHistory.pushState]"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: Web Console :: <TOP_LEVEL> :: line 1"  data: no]

test case:
1. Open the Web console
2. paste> history.pushState({}, "", "?bug")
3. there is no 3. unfortunately

Note: Doing the same in Firebug works fine.
(Reporter)

Comment 1

6 years ago
BTW, the workaround for addons is to create a script tag with the call to history API in its innerHTML and then append that tag to the document body.
Is this specific to pushstate?  history.back() also doesn't work for me.
(Reporter)

Comment 3

6 years ago
As the bug title says, the problem is expected to affect the whole history API.
I've only tested pushState() and replaceState() methods, though.
history.back() is working fine for me, but I can reproduce this with history.pushState(...).

Comment 5

6 years ago
From a Greasemonkey script this I get this error only when I give a URL to history.pushState (giving only state object and title works fine). But from Scratchpad and Web Console I get this error also when I don't give a URL.

Comment 6

6 years ago
*From a Greasemonkey script I get this error only when I give a URL to history.pushState
The error has an explanation now:

[Exception... "The operation is insecure."  code: "18" nsresult: "0x80530012 (SecurityError)"  location: "debugger eval code Line: 1"]
You need to log in before you can comment on or make changes to this bug.