-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: trust new notebooks and notebooks with new cells (#275)
Creating a new notebook or adding a new cell to a notebook should not remove the trust status of the notebook.
- Loading branch information
1 parent
5c85fee
commit 9913614
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from .utils import EDITOR_PAGE | ||
|
||
trust_test_code = """ | ||
import IPython.display | ||
IPython.display.Javascript("window.javascriptExecuted = true") | ||
""" | ||
|
||
|
||
def test_trust(notebook_frontend): | ||
def save_notebook(): | ||
notebook_frontend.evaluate("() => Jupyter.notebook.save_notebook()", page=EDITOR_PAGE) | ||
|
||
# Add a cell that executes javascript | ||
notebook_frontend.add_cell(index=0, content=trust_test_code) | ||
notebook_frontend.execute_cell(0) | ||
notebook_frontend.wait_for_cell_output(0) | ||
# Make sure the JavaScript executed | ||
assert notebook_frontend.evaluate("() => window.javascriptExecuted", page=EDITOR_PAGE) == True | ||
# Check that we see the 'Trusted' text on the page | ||
trusted = notebook_frontend.locate("#notification_trusted", page=EDITOR_PAGE) | ||
assert trusted.get_inner_text() == "Trusted" | ||
save_notebook() | ||
|
||
# refresh the page, should be trusted | ||
notebook_frontend.reload(EDITOR_PAGE) | ||
notebook_frontend.wait_for_kernel_ready() | ||
trusted = notebook_frontend.locate("#notification_trusted", page=EDITOR_PAGE) | ||
assert trusted.get_inner_text() == "Trusted" | ||
notebook_frontend.wait_for_cell_output(0) | ||
assert notebook_frontend.evaluate("() => window.javascriptExecuted", page=EDITOR_PAGE) == True |